From 29d15734695abd06ad49f35086455a6177334e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A9=8D=E4=B8=B9=E5=B0=BC=20Dan=20Jacobson?= Date: Sun, 3 Sep 2023 13:13:24 -0500 Subject: [PATCH 001/132] Update gpsbabel_man.xml (#1170) Without a dash this will resemble the "tar" command! --- xmldoc/gpsbabel_man.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmldoc/gpsbabel_man.xml b/xmldoc/gpsbabel_man.xml index ce0757504..d4854a6d3 100644 --- a/xmldoc/gpsbabel_man.xml +++ b/xmldoc/gpsbabel_man.xml @@ -24,7 +24,7 @@ gpsbabel - + file From 1ccfdb66ac38a0e7a8f596eff62ab544f01f2e59 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 4 Sep 2023 14:13:40 -0600 Subject: [PATCH 002/132] convert mkshort from char* to QByteArray (#1171) * convert mkshort from char* to QByteArray. and store conflict count directly in hash. * fix potential detach and rename vars * tweak whitespace removal. * don't split codepoints that comprise a grapheme. * enhance mkshort test * fix enhanced test * test mkshort replacements * remformat mkshort with astyle * add mkshort test to cmake --- CMakeLists.txt | 1 + mkshort.cc | 557 ++++++++++------------------------------ reference/mkshort.style | 6 +- reference/mkshort4.csv | 300 +++++++++++----------- reference/mkshort4.log | 18 ++ reference/mkshort5.csv | 300 +++++++++++----------- reference/mkshort6.csv | 300 +++++++++++----------- testo.d/mkshort.test | 28 ++ 8 files changed, 635 insertions(+), 875 deletions(-) create mode 100644 reference/mkshort4.log diff --git a/CMakeLists.txt b/CMakeLists.txt index 28d131c5c..12a6c11c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -396,6 +396,7 @@ set(TESTS kml-read kml lowranceusr + mkshort mtk multiurlgpx nmea diff --git a/mkshort.cc b/mkshort.cc index ef6c4b697..4ad3fc47f 100644 --- a/mkshort.cc +++ b/mkshort.cc @@ -1,7 +1,7 @@ /* Generate unique short names. - Copyright (C) 2003, 2004, 2005, 2006 Robert Lipe, robertlipe+source@gpsbabel.org + Copyright (C) 2003-2006, 2023 Robert Lipe, robertlipe+source@gpsbabel.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,16 +20,15 @@ */ #include // for assert -#include // for isspace, toupper, isdigit -#include // for INT_MAX -#include // for strlen, memmove, strchr, strcpy, strncmp, strcat, strncpy +#include // for isspace, isdigit #include // for QByteArray #include // for QChar, QChar::ReplacementCharacter #include // for QHash, QHash<>::iterator, qHash, QHash<>::size_type #include // for QString +#include // for QVector #include // for CaseInsensitive -#include // for foreach +#include // for qAsConst #include "defs.h" #include "geocache.h" // for Geocache @@ -37,22 +36,18 @@ #define MYNAME "mkshort" -static const char vowels[] = "aeiouAEIOU"; - -static constexpr unsigned int default_target_len = 8U; -static const char* DEFAULT_BADCHARS = "\"$.,'!-"; - -struct uniq_shortname { - int conflictctr{0}; -}; +static const QByteArray vowels("aeiouAEIOU"); +static constexpr int default_target_len = 8; +static constexpr const char default_badchars[] = "\"$.,'!-"; class ShortNameKey; -using ShortNameHash = QHash; -class ShortNameKey { +using ShortNameHash = QHash; +class ShortNameKey +{ public: ShortNameKey(const QByteArray& name) : shortname(name) {} /* converting constructor */ - friend qhash_result_t qHash(const ShortNameKey &key, qhash_result_t seed = 0) noexcept + friend qhash_result_t qHash(const ShortNameKey& key, qhash_result_t seed = 0) noexcept { // We hash all strings as upper case. return qHash(key.shortname.toUpper(), seed); @@ -61,16 +56,16 @@ class ShortNameKey { QByteArray shortname; }; -inline bool operator==(const ShortNameKey& lhs, const ShortNameKey &rhs) noexcept +inline bool operator==(const ShortNameKey& lhs, const ShortNameKey& rhs) noexcept { return lhs.shortname.compare(rhs.shortname, Qt::CaseInsensitive) == 0; } struct mkshort_handle_imp { - unsigned int target_len{default_target_len}; - char* badchars{nullptr}; - char* goodchars{nullptr}; - char* defname{nullptr}; + int target_len{default_target_len}; + QByteArray badchars{default_badchars}; + QByteArray goodchars; + QByteArray defname{"WPT"}; ShortNameHash namelist; /* Various internal flags */ @@ -80,78 +75,56 @@ struct mkshort_handle_imp { bool must_uniq{true}; }; -static struct replacements { - const char* orig; - const char* replacement; -} replacements[] = { - {"zero", "0"}, - {"one", "1"}, - {"two", "2"}, - {"three", "3"}, - {"four", "4"}, - {"five", "5"}, - {"six", "6"}, - {"seven", "7"}, - {"eight", "8"}, - {"nine", "9"}, - {nullptr, nullptr} +struct replacement_t { + QByteArray orig; + QByteArray replacement; +}; +static const QVector replacements = { + {"zero", "0"}, + {"one", "1"}, + {"two", "2"}, + {"three", "3"}, + {"four", "4"}, + {"five", "5"}, + {"six", "6"}, + {"seven", "7"}, + {"eight", "8"}, + {"nine", "9"} }; short_handle mkshort_new_handle() { - auto* h = new mkshort_handle_imp; - - h->badchars = xstrdup(DEFAULT_BADCHARS); - h->defname = xstrdup("WPT"); - - return h; -} - -static -uniq_shortname* -is_unique(mkshort_handle_imp* h, const QByteArray& name) -{ - if (h->namelist.contains(name)) { - return h->namelist.value(name); - } - return (uniq_shortname*) nullptr; + return new mkshort_handle_imp; } static void -add_to_hashlist(mkshort_handle_imp* h, const QByteArray& name) +mkshort_add_to_list(mkshort_handle_imp* h, QByteArray& name, bool is_utf8) { - h->namelist.insert(name, new uniq_shortname); -} - -static -void -mkshort_add_to_list(mkshort_handle_imp* h, QByteArray& name) -{ - static_assert(!std::is_signedtarget_len)>::value, - "simplify the following logic if target length is signed."); - assert(h->target_len <= INT_MAX); - int target_len = h->target_len; - - uniq_shortname* s; - while ((s = is_unique(h, name))) { + while (h->namelist.contains(name)) { + auto& conflictctr = h->namelist[name]; QByteArray suffix("."); - suffix.append(QByteArray::number(++s->conflictctr)); + suffix.append(QByteArray::number(++conflictctr)); + int suffixcnt = suffix.size(); - if (name.size() + suffix.size() <= target_len) { - name.append(suffix); - } else if (suffix.size() <= target_len) { - // FIXME: utf8 => grapheme truncate - name.truncate(target_len - suffix.size()); + if (name.size() + suffixcnt <= h->target_len) { name.append(suffix); + } else if (int keepcnt = h->target_len - suffixcnt; keepcnt >= 0) { + if (is_utf8) { + QString result = grapheme_truncate(QString::fromUtf8(name), keepcnt); + name = result.toUtf8().append(suffix); + } else { + name.truncate(keepcnt); + name.append(suffix); + } } else { fatal("mkshort failure, the specified short length is insufficient.\n"); } } - add_to_hashlist(h, name); + h->namelist.insert(name, 0); } void @@ -167,25 +140,14 @@ mkshort_del_handle(short_handle* h) return; } - for (auto it = hdr->namelist.cbegin(), end = hdr->namelist.cend(); it != end; ++it) { #if 0 + for (auto it = hdr->namelist.cbegin(), end = hdr->namelist.cend(); it != end; ++it) { if (global_opts.verbose_status >= 2 && it.value()->conflictctr) { fprintf(stderr, "%d Output name conflicts: '%s'\n", it.value()->conflictctr, it.key().shortname.constData()); } -#endif - delete it.value(); - } - hdr->namelist.clear(); - hdr->namelist.squeeze(); - /* setshort_badchars(*h, NULL); ! currently setshort_badchars() always allocates something ! */ - if (hdr->badchars != nullptr) { - xfree(hdr->badchars); - } - setshort_goodchars(*h, nullptr); - if (hdr->defname) { - xfree(hdr->defname); } +#endif delete hdr; *h = nullptr; @@ -196,29 +158,26 @@ mkshort_del_handle(short_handle* h) */ static -char* -delete_last_vowel(int start, char* istring, int* replaced) +bool +delete_last_vowel(int start, QByteArray& iostring) { /* * Basically implement strrchr. */ - *replaced = 0; - for (int l = strlen(istring); l > start; l--) { - if (strchr(vowels, istring[l-1])) { + assert(start >= 1); + bool replaced = false; + for (int l = iostring.size(); l > start; --l) { + if (vowels.contains(iostring.at(l - 1))) { /* If vowel is the first letter of a word, keep it.*/ - if (istring[l-2] == ' ') { + if (iostring.at(l - 2) == ' ') { continue; } - char* ostring = xstrdup(istring); - strncpy(&ostring[l-1], &istring[l], 1+strlen(istring)-l); - ostring[strlen(istring)-1] = 0; - *replaced = 1; - strcpy(istring, ostring); - xfree(ostring); + iostring.remove(l - 1, 1); + replaced = true; break; } } - return istring; + return replaced; } /* @@ -226,21 +185,19 @@ delete_last_vowel(int start, char* istring, int* replaced) * are made only at the end of the string. */ void -replace_constants(char* s) +replace_constants(QByteArray& s) { - int origslen = strlen(s); - - for (struct replacements* r = replacements; r->orig; r++) { - int rl = strlen(r->orig); + for (const auto& r : replacements) { /* * If word is in replacement list and preceded by a * space, replace it. */ - if ((origslen - rl > 1) && - (0 == case_ignore_strcmp(r->orig, &s[origslen - rl])) && - (s[origslen - rl - 1] == ' ')) { - strcpy(&s[origslen - rl], r->replacement); - return ; + if ((s.size() > r.orig.size()) && + (0 == r.orig.compare(s.mid(s.size() - r.orig.size()), Qt::CaseInsensitive)) && + (s.at(s.size() - r.orig.size() - 1) == ' ')) { + s.truncate(s.size() - r.orig.size()); + s.append(r.replacement); + return; } } } @@ -297,10 +254,7 @@ setshort_defname(short_handle h, const char* s) if (s == nullptr) { fatal("setshort_defname called without a valid name."); } - if (hdl->defname != nullptr) { - xfree(hdl->defname); - } - hdl->defname = xstrdup(s); + hdl->defname = s; } /* @@ -313,10 +267,7 @@ setshort_badchars(short_handle h, const char* s) { auto* hdl = (mkshort_handle_imp*) h; - if ((hdl->badchars != nullptr)) { - xfree(hdl->badchars); - } - hdl->badchars = xstrdup(s ? s : DEFAULT_BADCHARS); + hdl->badchars = s ? s : default_badchars; } /* @@ -328,13 +279,10 @@ setshort_goodchars(short_handle h, const char* s) { auto* hdl = (mkshort_handle_imp*) h; - if (hdl->goodchars != nullptr) { - xfree(hdl->goodchars); - } if (s != nullptr) { - hdl->goodchars = xstrdup(s); + hdl->goodchars = s; } else { - hdl->goodchars = nullptr; + hdl->goodchars.clear(); } } @@ -363,10 +311,7 @@ setshort_mustuniq(short_handle h, int i) QByteArray mkshort(short_handle h, const QByteArray& istring, bool is_utf8) { - char* ostring; - char* tstring; - char* cp; - int i, l, replaced; + QByteArray ostring; auto* hdl = (mkshort_handle_imp*) h; if (is_utf8) { @@ -375,9 +320,9 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) // QString::fromUtf8() doesn't quite promise to use QChar::ReplacementCharacter, // but if it did toss them. result.remove(QChar::ReplacementCharacter); - ostring = xstrdup(result.toUtf8().constData()); + ostring = result.toUtf8(); } else { - ostring = xstrdup(istring.constData()); + ostring = istring; } /* @@ -387,51 +332,37 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) * the new seven digit geocache numbers and special case whacking * the 'G' off the front. */ - if ((hdl->target_len == 6) && (strlen(ostring) == 7) && - (ostring[0] == 'G') && (ostring[1] == 'C')) { - memmove(&ostring[0], &ostring[1], strlen(ostring)); + if ((hdl->target_len == 6) && (ostring.size() == 7) && + ostring.startsWith("GC")) { + ostring.remove(0, 1); } /* - * Whack leading "[Tt]he", + * Whack leading "[Tt]he " */ - if ((strlen(ostring) > hdl->target_len + 4) && - (strncmp(ostring, "The ", 4) == 0 || - strncmp(ostring, "the ", 4) == 0)) { - char* nstring = xstrdup(ostring + 4); - xfree(ostring); - ostring = nstring; + if ((ostring.size() > (hdl->target_len + 4)) && + (ostring.startsWith("The ") || ostring.startsWith("the "))) { + ostring.remove(0, 4); } - /* Eliminate leading whitespace in all cases */ - while (ostring[0] && isspace(ostring[0])) { - /* If orig string has N bytes, we want to copy N-1 bytes - * of the string itself plus the string terminator (which - * matters if the string consists of nothing but spaces) - */ - memmove(&ostring[0], &ostring[1], strlen(ostring)); - } + /* In all cases eliminate leading and trailing whitespace */ + ostring = ostring.trimmed(); if (!hdl->whitespaceok) { /* * Eliminate Whitespace */ - tstring = xstrdup(ostring); - l = strlen(tstring); - cp = ostring; - for (i=0; imustupper) { - for (tstring = ostring; *tstring; tstring++) { - *tstring = toupper(*tstring); - } + ostring = ostring.toUpper(); } /* Before we do any of the vowel or character removal, look for @@ -443,54 +374,34 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) /* * Eliminate chars on the blacklist. */ - tstring = xstrdup(ostring); - l = strlen(tstring); - cp = ostring; - for (i=0; ibadchars, tstring[i])) { - continue; - } - if (hdl->goodchars && (!strchr(hdl->goodchars, tstring[i]))) { - continue; + { + QByteArray tstring; + ostring.swap(tstring); + for (const auto ch : qAsConst(tstring)) { + if (hdl->badchars.contains(ch)) { + continue; + } + if (!hdl->goodchars.isEmpty() && (!hdl->goodchars.contains(ch))) { + continue; + } + ostring.append(ch); } -// FIXME(robertl): we need a way to not return partial UTF-8, but this isn't it. -// if (!isascii(tstring[i])) -// continue; - *cp++ = tstring[i]; } - *cp = 0; - xfree(tstring); /* - * Eliminate repeated whitespace. This can only shorten the string - * so we do it in place. + * Eliminate whitespace. + * In all cases remove leading and trailing whitespace. + * Leading and/or trailing whitespace may have been created by earlier + * operations that removed character(s) before and/or after whitespace. + * Conditionally simplify embedded whitespace. */ - if (!hdl->repeating_whitespaceok) { - for (i = 0; i < l-1; i++) { - if (ostring[i] == ' ' && ostring[i+1] == ' ') { - memmove(&ostring[i], &ostring[i+1], l-i); - } - } - } - - /* Eliminate trailing whitespace in all cases. This is done late because - earlier operations may have vacated characters after the space. */ - - char *end = ostring + strlen(ostring) - 1; - while (end > ostring && isspace(*end)) { - *end-- = 0; - } - + ostring = hdl->repeating_whitespaceok? ostring.trimmed() : ostring.simplified(); /* * Toss vowels to approach target length, but don't toss them * if we don't have to. We always keep the leading two letters * to preserve leading vowels and some semblance of pronouncability. * - * FIXME: There's a boundary case here where we're too aggressive. - * If the target length is "6" we will shorten "Trolley" to "Trlly", - * when we really don't have to. We should throw away one vowel, not - * both. */ /* @@ -503,14 +414,10 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) * * It also helps units with speech synthesis. */ - if (hdl->target_len < 15) { - replaced = 1; - } else { - replaced = 0; - } + bool replaced = hdl->target_len < 15; - while (replaced && strlen(ostring) > hdl->target_len) { - ostring = delete_last_vowel(2, ostring, &replaced); + while (replaced && (ostring.size() > hdl->target_len)) { + replaced = delete_last_vowel(2, ostring); } /* @@ -520,54 +427,49 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) * Walk in the Woods 2. */ - char* np = ostring + strlen(ostring); - while ((np != ostring) && *(np-1) && isdigit(*(np-1))) { - np--; - } - size_t nlen = strlen(np); - /* * Now brutally truncate the resulting string, preserve trailing * numeric data. * If the numeric component alone is longer than our target string - * length, use only what'll fit. + * length, use the trailing part of the the numeric component. */ - if (is_utf8) { - /* ToDo: Keep trailing numeric data as described above! */ - QString result = grapheme_truncate(QString::fromUtf8(ostring), hdl->target_len); - xfree(ostring); - ostring = xstrdup(result.toUtf8().constData()); - } else if ((/*i = */strlen(ostring)) > hdl->target_len) { - char* dp = &ostring[hdl->target_len] - nlen; - if (dp < ostring) { - dp = ostring; - } - memmove(dp, np, nlen); - dp[nlen] = 0; - // Essentially ostring.rtrim() from here down. - if (ostring && ostring[0] != 0) { // Empty output string? Bail. - char *end = ostring + strlen(ostring) - 1; - while (end > ostring && isspace(*end)) { - *end-- = 0; + if (int delcnt = ostring.size() - hdl->target_len; delcnt > 0) { + int suffixcnt = 0; + for (auto it = ostring.crbegin(); it != ostring.crend(); ++it) { + if (isdigit(*it)) { + ++suffixcnt; + } + if (suffixcnt == hdl->target_len) { + break; } } + + int keepcnt = hdl->target_len - suffixcnt; + assert(keepcnt >= 0); + + if (is_utf8) { + QString result = grapheme_truncate(QString::fromUtf8(ostring), keepcnt); + ostring = result.toUtf8().append(ostring.right(suffixcnt)); + } else { + ostring.remove(keepcnt, delcnt); + } + while (isspace(ostring.back())) { + ostring.chop(1); + } } /* * If, after all that, we have an empty string, punt and * let the must_uniq code handle it. */ - if (ostring && ostring[0] == '\0') { - xfree(ostring); - ostring = xstrdup(hdl->defname); + if (ostring.isEmpty()) { + ostring = hdl->defname; } - QByteArray rval(ostring); - xfree(ostring); if (hdl->must_uniq) { - mkshort_add_to_list(hdl, rval); + mkshort_add_to_list(hdl, ostring, is_utf8); } - return rval; + return ostring; } QString @@ -607,192 +509,3 @@ mkshort_from_wpt(short_handle h, const Waypoint* wpt) return mkshort(h, wpt->shortname); } - - -#if TEST_MKSHORT -const char* foo[] = { - "VwthPst# 3700.706N 08627.588W 0000000m View the Past #2 ", - "PilotRoc 3655.270N 08717.173W 0000000m Pilot Rock by CacheAdvance ", - "MrCycsNg 3652.407N 08728.890W 0000000m Mr. Cayces Neighborhood by Ca", - "SOLDIER 3640.691N 08726.660W 0000000m SOLDIER’S TRIBUTE ", - "ZOOMZOOM 3636.659N 08721.793W 0000000m ZOOM ZOOM ZOOM by Feros Family", - "SOCLOSEB 3636.494N 08722.086W 0000000m SO CLOSE BUT YET by Kyle of Fe", - "InSrchfS 3636.363N 08636.363W 0000000m In Search of Steam by BigHank ", - "RdBlngSp 3632.119N 08550.956W 0000000m Red Boiling Springs by Firedog", - "HelngWtr 3631.729N 08550.481W 0000000m Healing Waters by FiredogPotte", - "AHHtheVi 3629.020N 08533.891W 0000000m ogPotter ", - "LstCrkCc 3628.167N 08801.656W 0000000m Lost Creek Cache by Paul Kathy", - "DlvrncTr 3626.412N 08729.249W 0000000m Deliverance Train by Team Skay", - "FrQrtrRn 3438.502N 08646.926W 0000000m Four Quarter Rendezvous by Zay", - "Jstlttlc 3620.647N 08814.298W 0000000m Just a little cache by Paul Ka", - "BrryPtch 3618.786N 08616.344W 0000000m Berry Patch Cache by White Dog", - "AStrllDw 3342.752N 08630.829W 0000000m A Stroll Down Memory Lane by t", - "QunfTnns 3606.413N 08651.962W 0000000m Queen of Tennessee by A182pilo", - "GoneFish 3618.199N 08655.171W 0000000m Gone Fishin' by White Dog Pack", - "GrnwysFn 3610.942N 08642.061W 0000000m Greenways Fence by Ukulele And", - "AStnsThr 3611.240N 08638.324W 0000000m A Stone's Throw by Murrcat & S", - "Nashvlls 3617.112N 08642.359W 0000000m Nashville's Zoo by White Dog P", - "BltzMcr4 3517.127N 08622.211W 0000000m Blitz Micro Number 4 by IHTFP ", - "NkdnthWn 3437.145N 08651.693W 0000000m Naked in the Wind by Zaybex ", - "ANcPlctR 3603.389N 08654.418W 0000000m A Nice Place to Rest by JoGPS ", - "welcomtT 3638.155N 08720.130W 0000000m welcome to TN by Raf of the se", - "welcomtK 3638.956N 08721.011W 0000000m welcome to KY by raf of the se", - "BltzMcr5 3506.191N 08634.277W 0000000m Blitz Micro Number 5 by IHTFP ", - "JmsFmlyG 3615.887N 08649.846W 0000000m James Family Grocery by White ", - "seekngrf 3629.262N 08742.333W 0000000m seekeing refuge by raf of the ", - "SecrtFll 3614.927N 08534.180W 0000000m Secret Falls ", - "ApstlcTh 3613.870N 08645.108W 0000000m Apostolic Thistle Walk by Jame", - "WllIllBD 3609.258N 08637.268W 0000000m Well....I'll Be \"Dammed\" byi", - "BettysBt 3608.857N 08550.564W 0000000m Betty's Booty by White Dog Pac", - "SmthngSm 3439.748N 08643.522W 0000000m Something Smells Fishy by Zayb", - "RckyRd(C 3605.315N 08549.326W 0000000m Rocky Road (Center Hill Lake) ", - "Brdwtchr 3436.605N 08651.243W 0000000m Birdwatcher's Dream by Zaybex ", - "JcksnsHl 3605.185N 08619.439W 0000000m Jackson's Halls by White Dog P", - "FrgttnP2 3509.599N 08633.282W 0000000m Forgotten Park 2 by mdawg & mu", - "SOLDIERS 3640.691N 08726.660W 0000000m SOLDIERS TRIBUTE by Feros Fami", - "EndofRop 3433.820N 08650.460W 0000000m End of Rope by Big Rock ", - "VwthPst1 3659.263N 08627.114W 0000000m View the Past #1 by wkgraham ", - "VwthPst2 3700.706N 08627.588W 0000000m View the Past #2 by wkgraham ", - "Trash#8 3603.102N 08655.144W 0000000m Cache In Trash Out # 8 ", - "SlwwwwCc 3602.543N 08535.953W 0000000m Sloowwww Cache by Tntcacher ", - "Leavttbv 3602.514N 08638.686W 0000000m Leave it to beaver by A182pilo", - "WhrrthHr 3436.594N 08654.759W 0000000m Where are the Horses? by Zaybe", - "ButtonCc 3433.401N 08645.294W 0000000m Button Cache by Zaybex ", - "MrcsLbrr 3436.842N 08655.972W 0000000m Marco's Library by Marco ", - "Octopus 3526.743N 08534.757W 0000000m Octopus by White Dog Pack ", - "WtrFllsV 3544.140N 08527.861W 0000000m Water Falls Valley by Cave Rat", - "DeddrpPn 3448.126N 08719.696W 0000000m Dead-drop Pink by Marco ", - "JWhlrRvr 3448.157N 08719.914W 0000000m Joe Wheeler River Walk by Marc", - "CvSprngs 3432.797N 08651.084W 0000000m Cave Springs Cache by Marco.. ", - "CnyFrkOv 3550.876N 08518.446W 0000000m Fork Overlook ", - "SheepsCa 3550.527N 08519.480W 0000000m Sheep's Cave ", - "VrgnFlls 3550.308N 08519.904W 0000000m Virgin Falls Cache ", - "ShrtctVr 3550.170N 08519.590W 0000000m Shortcut Virtual ", - "KlylFlls 3549.105N 08539.814W 0000000m Klaylee Falls Cache by pattytr", - "FshngfrB 3548.923N 08538.558W 0000000m BADGER by M&Mk ", - "TpfthHll 3548.808N 08601.722W 0000000m Top of the Hill Pet Cache by M", - "TwnFllsC 3548.560N 08537.996W 0000000m Twin Falls Cache by SLCREW a", - "WtchsCst 3548.197N 08537.673W 0000000m Witch's Castle Keys by SLCREW ", - "ThatCave 3544.901N 08522.854W 0000000m That Cave by JaDan150 and AprJ", - "BssltwnW 3541.174N 08801.489W 0000000m Busseltown Wildlife Refuge by ", - "Riverfrn 3540.968N 08546.995W 0000000m Riverfront by SLCREW and M&M", - "Basement 3540.086N 08521.304W 0000000m The Basement ", - "EfflTwrC 3617.132N 08818.371W 0000000m Eiffel Tower Cache by Dick Wan", - "KeyholeC 3544.562N 08524.098W 0000000m Keyhole Cave by Cave Rat ", - "(MC^2)Mn 3444.990N 08630.218W 0000000m (MC^2) Monte Sano Cuts Cache b", - "WildctCc 3636.823N 08808.087W 0000000m Wildcat Cache by The Storm ", - "NAlbm/Tn 3444.365N 08632.688W 0000000m N. Alabama / Tennessee Valley ", - "CalebsCa 3444.215N 08633.103W 0000000m Caleb's Cave by Papaw and Cale", - "MntSnPrs 3444.201N 08632.591W 0000000m Monte Sano Preserve by Evan & ", - "FltRckFl 3444.475N 08629.958W 0000000m Flat Rock Falls Cache by Jason", - "PanormCc 3443.961N 08631.638W 0000000m The Panorama Cache by IHTFP an", - "TnnssScv 3602.861N 08652.751W 0000000m Tennessee Scavenger Hunt Cache", - "Geocache 3435.209N 08655.968W 0000000m Geocache by Papaw & Caleb ", - "Skellig 3444.100N 08656.566W 0000000m Skellig by Zaybex ", - "Deceptio 3433.450N 08655.711W 0000000m Deception by Papaw and Caleb ", - "AwlknthD 3433.310N 08655.635W 0000000m A walk in the Desert by Papa", - "MiniMsQs 3558.934N 08650.674W 0000000m Mini Me's Quest by CrotalusRex", - "BakrsBlf 3541.891N 08717.300W 0000000m Bakers Bluff by Flower Child &", - "GoFlyAKi 3435.664N 08659.267W 0000000m Go Fly A Kite by Marco.. ", - "FlntCrkA 3432.028N 08656.806W 0000000m Flint Creek Adventure by Marco", - "HonordMn 3534.680N 08612.557W 0000000m Honored Mount by Southpaw ", - "SafariZo 3440.697N 08700.774W 0000000m Safari Zone by Zaybex ", - "JckDnlsC 3517.077N 08622.260W 0000000m Jack Daniels Cache by Rmearse ", - "FrgttnPr 3509.599N 08633.282W 0000000m Forgotten Park by mdawg & muff", - "DntOvrlk 3513.326N 08616.031W 0000000m Dont Overlook Me Cache ", - "ArYStmpd 3513.039N 08615.110W 0000000m Are You Stumped Yet? cache ", - "CchtthBn 3512.532N 08614.691W 0000000m Cache at the Bend ", - "Thtsnkng 3609.009N 08530.314W 0000000m That sinking feeling by Tntcac", - "GamersCc 3449.136N 08635.836W 0000000m mer's Cache by avoral ", - "CchMIfYC 3452.455N 08620.648W 0000000m Cache Me If You Can! by Glen H", - "SavageVs 3526.915N 08535.136W 0000000m Savage Vista by White Dog Pack", - "PrtrnG15 3555.479N 08653.274W 0000000m Praetorian Guards Hail Caesar #15!", - "WtrlnAmp 3443.722N 08632.535W 0000000m Waterline Amphitheater by Fath", - "BysLttlC 3447.569N 08638.448W 0000000m Boys' Little Cache by Zaybex ", - "DrgnsBrt 3443.779N 08635.188W 0000000m Dragon's Breath by Zaybex ", - "CryBbyHl 3430.733N 08657.362W 0000000m Cry Baby Hollow Cache by La Pa", - "Parmer 3606.218N 08651.590W 0000000m Parmer by A182pilot & Family ", - "JnnfrndJ 3438.141N 08632.991W 0000000m Jennifer and Jonathans Cliff C", - "ALDRIDGE 3435.305N 08632.868W 0000000m ALDRIDGE CREEK LOTTA LOOT!! by", - "RcktCtyS 3440.032N 08631.352W 0000000m Rocket City Stash by David Upt", - "TrgcAccd 3608.561N 08648.381W 0000000m Tragic Accident by Campaholics", - "FALLENTR 3439.210N 08631.104W 0000000m FALLEN TREE 4 MILE POST by zac", - "TrshOt15 3558.964N 08646.064W 0000000m Cache In Trash Out # 15 by Jo", - "TrshOt13 3602.214N 08650.428W 0000000m Cache In Trash Out #13 by JoGP", - "PrcysDrp 3604.312N 08653.465W 0000000m Percys Dripping Springs by KLi", - "TrshOt14 3605.292N 08648.560W 0000000m Cache In Trash Out # 14 by JoG", - "PrtrnGr5 3557.621N 08640.278W 0000000m Praetorian Guards Hail Caesar #5!", - "PrtrnGr4 3557.370N 08640.201W 0000000m Praetorian Guards Hail Caesar #4!", - "PrtrnGr3 3557.250N 08640.047W 0000000m Praetorian Guards Hail Caesar #3!", - "GrnMntnC 3439.120N 08631.100W 0000000m Green Mountain Cache by Steve ", - "TrshOt12 3605.330N 08635.817W 0000000m Cache In Trash Out #12 by JoGP", - "BlncngAc 3608.579N 08648.120W 0000000m Balancing Act by Campaholics ", - "DittoCac 3434.652N 08633.310W 0000000m Ditto Cache by mookey ", - "EraserCc 3431.888N 08633.024W 0000000m Eraser Cache by Zaybex ", - "FrMlPstE 3439.440N 08630.180W 0000000m Four Mile Post Extension Cache", - "MllrdFxC 3439.578N 08706.552W 0000000m Mallard-Fox Creek Cache by bam", - "FireCach 3443.908N 08630.318W 0000000m he by Glen Pam Chase M ", - "FlntRvrC 3443.170N 08625.990W 0000000m Flint River Canoe Cache by Ran", - "ArabinCc 3419.104N 08628.765W 0000000m The Arabian Cache by WesNSpace", - "CvrdBrdg 3412.406N 08659.392W 0000000m Covered Bridge Cache by pmarkh", - "MilesTCc 3424.470N 08611.720W 0000000m Miles Too Cache by Rmearse ", - "MbryOvrl 3423.803N 08611.922W 0000000m Mabrey Overlook Me by DDVaughn", - "LwEnfrcm 3423.218N 08612.258W 0000000m Law Enforcement Cache by DDVau", - "GrndDddy 3423.128N 08612.025W 0000000m Grand Daddys Home by Rmearse ", - "BamaCach 3421.459N 08611.686W 0000000m The Bama Cache by DDVaughn & T", - "Canyons 3440.085N 08600.910W 0000000m The Canyons by Aubrey and Josh", - "ADamGodV 3511.677N 08616.587W 0000000m A Dam Good View by mdawg & muf", - "UNDERTHE 3446.918N 08739.790W 0000000m UNDER THE ROCK by RUNNINGWILD ", - "SQUIRREL 3448.712N 08741.681W 0000000m SQUIRREL'S NEST by RUNNINGWILD", - "WlknthPr 3448.273N 08741.844W 0000000m Walk in the Park by Runningwil", - "NetsClue 3448.494N 08741.977W 0000000m Net's Clues by Runningwild Adv", - "NatrlBrd 3405.583N 08736.909W 0000000m Natural Bridge by Southeast Xt", - "TrnglPrk 3341.448N 08640.980W 0000000m Triangle Park Cache by Charles", - "LttlRvrI 3421.855N 08539.597W 0000000m Little River Initiative by spa", - "GimmShlt 3430.087N 08536.834W 0000000m Gimme Shelter by Big Rock & Po", - "GnomeTrs 3433.081N 08535.849W 0000000m Gnome Treasure by Big Rock ", - "FlyingTr 3608.594N 08648.179W 0000000m Flying Torso by Campaholics ", - "CultivtC 3608.582N 08648.064W 0000000m Cultivate a Cure by Campahol", - __nullptr -} -; - -int main() -{ - int r; - - auto h = mkshort_new_handle(); -// setshort_whitespace_ok(h, false); - - printf("%s\n", mkshort(h, "The Troll", false)); - printf("%s\n", mkshort(h, "EFI", false)); - printf("%s\n", mkshort(h, "the Troll", false)); - printf("%s\n", mkshort(h, "the Trolley", false)); - printf("%s\n", mkshort(h, "The Troll Lives Under The Bridge", false)); - printf("%s\n", mkshort(h, "The \"Troll\" Lives Under $$ The Bridge!", false)); - printf("%s\n", mkshort(h, "The Trolley Goes Round", false)); - printf("%s\n", mkshort(h, "Cache In / Trash Out #1", false)); - printf("%s\n", mkshort(h, "Cache In / Trash Out #2", false)); - printf("%s\n", mkshort(h, "Cache In / Trash Out #137", false)); - printf("|%s|\n", mkshort(h, "Cache .", false)); - printf("|%s|\n", mkshort(h, "Cache .", false)); - printf("|%s|\n", mkshort(h, "Cache .", false)); - printf("|%s|\n", mkshort(h, " Cache .", false)); - -#if 0 - const char** foop = foo; - while (*foop) { - printf("%s | %s\n", mkshort(h, *foop+39, false), *foop+39); - foop++; - } -#endif - - printf("%s\n", delete_last_vowel(0, xstrdup("the quick brown foo"), &r)); - printf("%s\n", delete_last_vowel(0, xstrdup("the quick brown fox"), &r)); - printf("%s\n", delete_last_vowel(0, xstrdup("xxx"), &r)); - printf("%s\n", delete_last_vowel(0, xstrdup("ixxx"), &r)); - printf("%s\n", delete_last_vowel(0, xstrdup("aexxx"), &r)); - - return 0; -} -#endif diff --git a/reference/mkshort.style b/reference/mkshort.style index 52ef14f4a..c48ede002 100644 --- a/reference/mkshort.style +++ b/reference/mkshort.style @@ -6,12 +6,12 @@ SHORTLEN 4 # FILE LAYOUT DEFINITIIONS: # FIELD_ENCLOSER DOUBLEQUOTE -FIELD_DELIMITER COMMASPACE +FIELD_DELIMITER COMMA RECORD_DELIMITER NEWLINE BADCHARS COMMA # # INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE: # -IFIELD LAT_DECIMAL, "", "%8.5f" -IFIELD LON_DECIMAL, "", "%8.5f" +IFIELD LAT_DECIMAL, "", "%.5f" +IFIELD LON_DECIMAL, "", "%.5f" IFIELD SHORTNAME, "", "%s" diff --git a/reference/mkshort4.csv b/reference/mkshort4.csv index 831e6b686..205db9850 100644 --- a/reference/mkshort4.csv +++ b/reference/mkshort4.csv @@ -1,150 +1,150 @@ -"0.00000", "0.00000", "wp" -"0.00000", "0.00000", "wp.1" -"0.00000", "0.00000", "wp.2" -"0.00000", "0.00000", "wp.3" -"0.00000", "0.00000", "wp.4" -"0.00000", "0.00000", "wp.5" -"0.00000", "0.00000", "wp.6" -"0.00000", "0.00000", "wp.7" -"0.00000", "0.00000", "wp.8" -"0.00000", "0.00000", "wp.9" -"0.00000", "0.00000", "w.10" -"0.00000", "0.00000", "w.11" -"0.00000", "0.00000", "w.12" -"0.00000", "0.00000", "w.13" -"0.00000", "0.00000", "w.14" -"0.00000", "0.00000", "w.15" -"0.00000", "0.00000", "w.16" -"0.00000", "0.00000", "w.17" -"0.00000", "0.00000", "w.18" -"0.00000", "0.00000", "w.19" -"0.00000", "0.00000", "w.20" -"0.00000", "0.00000", "w.21" -"0.00000", "0.00000", "w.22" -"0.00000", "0.00000", "w.23" -"0.00000", "0.00000", "w.24" -"0.00000", "0.00000", "w.25" -"0.00000", "0.00000", "w.26" -"0.00000", "0.00000", "w.27" -"0.00000", "0.00000", "w.28" -"0.00000", "0.00000", "w.29" -"0.00000", "0.00000", "w.30" -"0.00000", "0.00000", "w.31" -"0.00000", "0.00000", "w.32" -"0.00000", "0.00000", "w.33" -"0.00000", "0.00000", "w.34" -"0.00000", "0.00000", "w.35" -"0.00000", "0.00000", "w.36" -"0.00000", "0.00000", "w.37" -"0.00000", "0.00000", "w.38" -"0.00000", "0.00000", "w.39" -"0.00000", "0.00000", "w.40" -"0.00000", "0.00000", "w.41" -"0.00000", "0.00000", "w.42" -"0.00000", "0.00000", "w.43" -"0.00000", "0.00000", "w.44" -"0.00000", "0.00000", "w.45" -"0.00000", "0.00000", "w.46" -"0.00000", "0.00000", "w.47" -"0.00000", "0.00000", "w.48" -"0.00000", "0.00000", "w.49" -"0.00000", "0.00000", "w.50" -"0.00000", "0.00000", "w.51" -"0.00000", "0.00000", "w.52" -"0.00000", "0.00000", "w.53" -"0.00000", "0.00000", "w.54" -"0.00000", "0.00000", "w.55" -"0.00000", "0.00000", "w.56" -"0.00000", "0.00000", "w.57" -"0.00000", "0.00000", "w.58" -"0.00000", "0.00000", "w.59" -"0.00000", "0.00000", "w.60" -"0.00000", "0.00000", "w.61" -"0.00000", "0.00000", "w.62" -"0.00000", "0.00000", "w.63" -"0.00000", "0.00000", "w.64" -"0.00000", "0.00000", "w.65" -"0.00000", "0.00000", "w.66" -"0.00000", "0.00000", "w.67" -"0.00000", "0.00000", "w.68" -"0.00000", "0.00000", "w.69" -"0.00000", "0.00000", "w.70" -"0.00000", "0.00000", "w.71" -"0.00000", "0.00000", "w.72" -"0.00000", "0.00000", "w.73" -"0.00000", "0.00000", "w.74" -"0.00000", "0.00000", "w.75" -"0.00000", "0.00000", "w.76" -"0.00000", "0.00000", "w.77" -"0.00000", "0.00000", "w.78" -"0.00000", "0.00000", "w.79" -"0.00000", "0.00000", "w.80" -"0.00000", "0.00000", "w.81" -"0.00000", "0.00000", "w.82" -"0.00000", "0.00000", "w.83" -"0.00000", "0.00000", "w.84" -"0.00000", "0.00000", "w.85" -"0.00000", "0.00000", "w.86" -"0.00000", "0.00000", "w.87" -"0.00000", "0.00000", "w.88" -"0.00000", "0.00000", "w.89" -"0.00000", "0.00000", "w.90" -"0.00000", "0.00000", "w.91" -"0.00000", "0.00000", "w.92" -"0.00000", "0.00000", "w.93" -"0.00000", "0.00000", "w.94" -"0.00000", "0.00000", "w.95" -"0.00000", "0.00000", "w.96" -"0.00000", "0.00000", "w.97" -"0.00000", "0.00000", "w.98" -"0.00000", "0.00000", "w.99" -"0.00000", "0.00000", ".100" -"0.00000", "0.00000", ".101" -"0.00000", "0.00000", ".102" -"0.00000", "0.00000", ".103" -"0.00000", "0.00000", ".104" -"0.00000", "0.00000", ".105" -"0.00000", "0.00000", ".106" -"0.00000", "0.00000", ".107" -"0.00000", "0.00000", ".108" -"0.00000", "0.00000", ".109" -"0.00000", "0.00000", ".110" -"0.00000", "0.00000", ".111" -"0.00000", "0.00000", ".112" -"0.00000", "0.00000", ".113" -"0.00000", "0.00000", ".114" -"0.00000", "0.00000", ".115" -"0.00000", "0.00000", ".116" -"0.00000", "0.00000", ".117" -"0.00000", "0.00000", ".118" -"0.00000", "0.00000", ".119" -"0.00000", "0.00000", ".120" -"0.00000", "0.00000", ".121" -"0.00000", "0.00000", ".122" -"0.00000", "0.00000", ".123" -"0.00000", "0.00000", ".124" -"0.00000", "0.00000", ".125" -"0.00000", "0.00000", ".126" -"0.00000", "0.00000", ".127" -"0.00000", "0.00000", ".128" -"0.00000", "0.00000", ".129" -"0.00000", "0.00000", ".130" -"0.00000", "0.00000", ".131" -"0.00000", "0.00000", ".132" -"0.00000", "0.00000", ".133" -"0.00000", "0.00000", ".134" -"0.00000", "0.00000", ".135" -"0.00000", "0.00000", ".136" -"0.00000", "0.00000", ".137" -"0.00000", "0.00000", ".138" -"0.00000", "0.00000", ".139" -"0.00000", "0.00000", ".140" -"0.00000", "0.00000", ".141" -"0.00000", "0.00000", ".142" -"0.00000", "0.00000", ".143" -"0.00000", "0.00000", ".144" -"0.00000", "0.00000", ".145" -"0.00000", "0.00000", ".146" -"0.00000", "0.00000", ".147" -"0.00000", "0.00000", ".148" -"0.00000", "0.00000", ".149" +"0.00000","0.00000","wp" +"0.00000","0.00000","wp.1" +"0.00000","0.00000","wp.2" +"0.00000","0.00000","wp.3" +"0.00000","0.00000","wp.4" +"0.00000","0.00000","wp.5" +"0.00000","0.00000","wp.6" +"0.00000","0.00000","wp.7" +"0.00000","0.00000","wp.8" +"0.00000","0.00000","wp.9" +"0.00000","0.00000","w.10" +"0.00000","0.00000","w.11" +"0.00000","0.00000","w.12" +"0.00000","0.00000","w.13" +"0.00000","0.00000","w.14" +"0.00000","0.00000","w.15" +"0.00000","0.00000","w.16" +"0.00000","0.00000","w.17" +"0.00000","0.00000","w.18" +"0.00000","0.00000","w.19" +"0.00000","0.00000","w.20" +"0.00000","0.00000","w.21" +"0.00000","0.00000","w.22" +"0.00000","0.00000","w.23" +"0.00000","0.00000","w.24" +"0.00000","0.00000","w.25" +"0.00000","0.00000","w.26" +"0.00000","0.00000","w.27" +"0.00000","0.00000","w.28" +"0.00000","0.00000","w.29" +"0.00000","0.00000","w.30" +"0.00000","0.00000","w.31" +"0.00000","0.00000","w.32" +"0.00000","0.00000","w.33" +"0.00000","0.00000","w.34" +"0.00000","0.00000","w.35" +"0.00000","0.00000","w.36" +"0.00000","0.00000","w.37" +"0.00000","0.00000","w.38" +"0.00000","0.00000","w.39" +"0.00000","0.00000","w.40" +"0.00000","0.00000","w.41" +"0.00000","0.00000","w.42" +"0.00000","0.00000","w.43" +"0.00000","0.00000","w.44" +"0.00000","0.00000","w.45" +"0.00000","0.00000","w.46" +"0.00000","0.00000","w.47" +"0.00000","0.00000","w.48" +"0.00000","0.00000","w.49" +"0.00000","0.00000","w.50" +"0.00000","0.00000","w.51" +"0.00000","0.00000","w.52" +"0.00000","0.00000","w.53" +"0.00000","0.00000","w.54" +"0.00000","0.00000","w.55" +"0.00000","0.00000","w.56" +"0.00000","0.00000","w.57" +"0.00000","0.00000","w.58" +"0.00000","0.00000","w.59" +"0.00000","0.00000","w.60" +"0.00000","0.00000","w.61" +"0.00000","0.00000","w.62" +"0.00000","0.00000","w.63" +"0.00000","0.00000","w.64" +"0.00000","0.00000","w.65" +"0.00000","0.00000","w.66" +"0.00000","0.00000","w.67" +"0.00000","0.00000","w.68" +"0.00000","0.00000","w.69" +"0.00000","0.00000","w.70" +"0.00000","0.00000","w.71" +"0.00000","0.00000","w.72" +"0.00000","0.00000","w.73" +"0.00000","0.00000","w.74" +"0.00000","0.00000","w.75" +"0.00000","0.00000","w.76" +"0.00000","0.00000","w.77" +"0.00000","0.00000","w.78" +"0.00000","0.00000","w.79" +"0.00000","0.00000","w.80" +"0.00000","0.00000","w.81" +"0.00000","0.00000","w.82" +"0.00000","0.00000","w.83" +"0.00000","0.00000","w.84" +"0.00000","0.00000","w.85" +"0.00000","0.00000","w.86" +"0.00000","0.00000","w.87" +"0.00000","0.00000","w.88" +"0.00000","0.00000","w.89" +"0.00000","0.00000","w.90" +"0.00000","0.00000","w.91" +"0.00000","0.00000","w.92" +"0.00000","0.00000","w.93" +"0.00000","0.00000","w.94" +"0.00000","0.00000","w.95" +"0.00000","0.00000","w.96" +"0.00000","0.00000","w.97" +"0.00000","0.00000","w.98" +"0.00000","0.00000","w.99" +"0.00000","0.00000",".100" +"0.00000","0.00000",".101" +"0.00000","0.00000",".102" +"0.00000","0.00000",".103" +"0.00000","0.00000",".104" +"0.00000","0.00000",".105" +"0.00000","0.00000",".106" +"0.00000","0.00000",".107" +"0.00000","0.00000",".108" +"0.00000","0.00000",".109" +"0.00000","0.00000",".110" +"0.00000","0.00000",".111" +"0.00000","0.00000",".112" +"0.00000","0.00000",".113" +"0.00000","0.00000",".114" +"0.00000","0.00000",".115" +"0.00000","0.00000",".116" +"0.00000","0.00000",".117" +"0.00000","0.00000",".118" +"0.00000","0.00000",".119" +"0.00000","0.00000",".120" +"0.00000","0.00000",".121" +"0.00000","0.00000",".122" +"0.00000","0.00000",".123" +"0.00000","0.00000",".124" +"0.00000","0.00000",".125" +"0.00000","0.00000",".126" +"0.00000","0.00000",".127" +"0.00000","0.00000",".128" +"0.00000","0.00000",".129" +"0.00000","0.00000",".130" +"0.00000","0.00000",".131" +"0.00000","0.00000",".132" +"0.00000","0.00000",".133" +"0.00000","0.00000",".134" +"0.00000","0.00000",".135" +"0.00000","0.00000",".136" +"0.00000","0.00000",".137" +"0.00000","0.00000",".138" +"0.00000","0.00000",".139" +"0.00000","0.00000",".140" +"0.00000","0.00000",".141" +"0.00000","0.00000",".142" +"0.00000","0.00000",".143" +"0.00000","0.00000",".144" +"0.00000","0.00000",".145" +"0.00000","0.00000",".146" +"0.00000","0.00000",".147" +"0.00000","0.00000",".148" +"0.00000","0.00000",".149" diff --git a/reference/mkshort4.log b/reference/mkshort4.log new file mode 100644 index 000000000..8937cc8ea --- /dev/null +++ b/reference/mkshort4.log @@ -0,0 +1,18 @@ +"0.00000","0.00000","a e" +"0.00000","0.00000","abc0123" +"0.00000","0.00000","ab0123" +"0.00000","0.00000","a0123" +"0.00000","0.00000","0123" +"0.00000","0.00000","123" +"0.00000","0.00000","23" +"0.00000","0.00000","3" +"0.00000","0.00000","xxaeiouzz" +"0.00000","0.00000","xxaeiozz" +"0.00000","0.00000","xxaeizz" +"0.00000","0.00000","xxaezz" +"0.00000","0.00000","xxazz" +"0.00000","0.00000","xxzz" +"0.00000","0.00000","abcd" +"0.00000","0.00000","abc" +"0.00000","0.00000","ab" +"0.00000","0.00000","abcd 1" diff --git a/reference/mkshort5.csv b/reference/mkshort5.csv index e87dca0c1..66d071a2b 100644 --- a/reference/mkshort5.csv +++ b/reference/mkshort5.csv @@ -1,150 +1,150 @@ -"0.00000", "0.00000", "wp" -"0.00000", "0.00000", "wp.1" -"0.00000", "0.00000", "wp.2" -"0.00000", "0.00000", "wp.3" -"0.00000", "0.00000", "wp.4" -"0.00000", "0.00000", "wp.5" -"0.00000", "0.00000", "wp.6" -"0.00000", "0.00000", "wp.7" -"0.00000", "0.00000", "wp.8" -"0.00000", "0.00000", "wp.9" -"0.00000", "0.00000", "wp.10" -"0.00000", "0.00000", "wp.11" -"0.00000", "0.00000", "wp.12" -"0.00000", "0.00000", "wp.13" -"0.00000", "0.00000", "wp.14" -"0.00000", "0.00000", "wp.15" -"0.00000", "0.00000", "wp.16" -"0.00000", "0.00000", "wp.17" -"0.00000", "0.00000", "wp.18" -"0.00000", "0.00000", "wp.19" -"0.00000", "0.00000", "wp.20" -"0.00000", "0.00000", "wp.21" -"0.00000", "0.00000", "wp.22" -"0.00000", "0.00000", "wp.23" -"0.00000", "0.00000", "wp.24" -"0.00000", "0.00000", "wp.25" -"0.00000", "0.00000", "wp.26" -"0.00000", "0.00000", "wp.27" -"0.00000", "0.00000", "wp.28" -"0.00000", "0.00000", "wp.29" -"0.00000", "0.00000", "wp.30" -"0.00000", "0.00000", "wp.31" -"0.00000", "0.00000", "wp.32" -"0.00000", "0.00000", "wp.33" -"0.00000", "0.00000", "wp.34" -"0.00000", "0.00000", "wp.35" -"0.00000", "0.00000", "wp.36" -"0.00000", "0.00000", "wp.37" -"0.00000", "0.00000", "wp.38" -"0.00000", "0.00000", "wp.39" -"0.00000", "0.00000", "wp.40" -"0.00000", "0.00000", "wp.41" -"0.00000", "0.00000", "wp.42" -"0.00000", "0.00000", "wp.43" -"0.00000", "0.00000", "wp.44" -"0.00000", "0.00000", "wp.45" -"0.00000", "0.00000", "wp.46" -"0.00000", "0.00000", "wp.47" -"0.00000", "0.00000", "wp.48" -"0.00000", "0.00000", "wp.49" -"0.00000", "0.00000", "wp.50" -"0.00000", "0.00000", "wp.51" -"0.00000", "0.00000", "wp.52" -"0.00000", "0.00000", "wp.53" -"0.00000", "0.00000", "wp.54" -"0.00000", "0.00000", "wp.55" -"0.00000", "0.00000", "wp.56" -"0.00000", "0.00000", "wp.57" -"0.00000", "0.00000", "wp.58" -"0.00000", "0.00000", "wp.59" -"0.00000", "0.00000", "wp.60" -"0.00000", "0.00000", "wp.61" -"0.00000", "0.00000", "wp.62" -"0.00000", "0.00000", "wp.63" -"0.00000", "0.00000", "wp.64" -"0.00000", "0.00000", "wp.65" -"0.00000", "0.00000", "wp.66" -"0.00000", "0.00000", "wp.67" -"0.00000", "0.00000", "wp.68" -"0.00000", "0.00000", "wp.69" -"0.00000", "0.00000", "wp.70" -"0.00000", "0.00000", "wp.71" -"0.00000", "0.00000", "wp.72" -"0.00000", "0.00000", "wp.73" -"0.00000", "0.00000", "wp.74" -"0.00000", "0.00000", "wp.75" -"0.00000", "0.00000", "wp.76" -"0.00000", "0.00000", "wp.77" -"0.00000", "0.00000", "wp.78" -"0.00000", "0.00000", "wp.79" -"0.00000", "0.00000", "wp.80" -"0.00000", "0.00000", "wp.81" -"0.00000", "0.00000", "wp.82" -"0.00000", "0.00000", "wp.83" -"0.00000", "0.00000", "wp.84" -"0.00000", "0.00000", "wp.85" -"0.00000", "0.00000", "wp.86" -"0.00000", "0.00000", "wp.87" -"0.00000", "0.00000", "wp.88" -"0.00000", "0.00000", "wp.89" -"0.00000", "0.00000", "wp.90" -"0.00000", "0.00000", "wp.91" -"0.00000", "0.00000", "wp.92" -"0.00000", "0.00000", "wp.93" -"0.00000", "0.00000", "wp.94" -"0.00000", "0.00000", "wp.95" -"0.00000", "0.00000", "wp.96" -"0.00000", "0.00000", "wp.97" -"0.00000", "0.00000", "wp.98" -"0.00000", "0.00000", "wp.99" -"0.00000", "0.00000", "w.100" -"0.00000", "0.00000", "w.101" -"0.00000", "0.00000", "w.102" -"0.00000", "0.00000", "w.103" -"0.00000", "0.00000", "w.104" -"0.00000", "0.00000", "w.105" -"0.00000", "0.00000", "w.106" -"0.00000", "0.00000", "w.107" -"0.00000", "0.00000", "w.108" -"0.00000", "0.00000", "w.109" -"0.00000", "0.00000", "w.110" -"0.00000", "0.00000", "w.111" -"0.00000", "0.00000", "w.112" -"0.00000", "0.00000", "w.113" -"0.00000", "0.00000", "w.114" -"0.00000", "0.00000", "w.115" -"0.00000", "0.00000", "w.116" -"0.00000", "0.00000", "w.117" -"0.00000", "0.00000", "w.118" -"0.00000", "0.00000", "w.119" -"0.00000", "0.00000", "w.120" -"0.00000", "0.00000", "w.121" -"0.00000", "0.00000", "w.122" -"0.00000", "0.00000", "w.123" -"0.00000", "0.00000", "w.124" -"0.00000", "0.00000", "w.125" -"0.00000", "0.00000", "w.126" -"0.00000", "0.00000", "w.127" -"0.00000", "0.00000", "w.128" -"0.00000", "0.00000", "w.129" -"0.00000", "0.00000", "w.130" -"0.00000", "0.00000", "w.131" -"0.00000", "0.00000", "w.132" -"0.00000", "0.00000", "w.133" -"0.00000", "0.00000", "w.134" -"0.00000", "0.00000", "w.135" -"0.00000", "0.00000", "w.136" -"0.00000", "0.00000", "w.137" -"0.00000", "0.00000", "w.138" -"0.00000", "0.00000", "w.139" -"0.00000", "0.00000", "w.140" -"0.00000", "0.00000", "w.141" -"0.00000", "0.00000", "w.142" -"0.00000", "0.00000", "w.143" -"0.00000", "0.00000", "w.144" -"0.00000", "0.00000", "w.145" -"0.00000", "0.00000", "w.146" -"0.00000", "0.00000", "w.147" -"0.00000", "0.00000", "w.148" -"0.00000", "0.00000", "w.149" +"0.00000","0.00000","wp" +"0.00000","0.00000","wp.1" +"0.00000","0.00000","wp.2" +"0.00000","0.00000","wp.3" +"0.00000","0.00000","wp.4" +"0.00000","0.00000","wp.5" +"0.00000","0.00000","wp.6" +"0.00000","0.00000","wp.7" +"0.00000","0.00000","wp.8" +"0.00000","0.00000","wp.9" +"0.00000","0.00000","wp.10" +"0.00000","0.00000","wp.11" +"0.00000","0.00000","wp.12" +"0.00000","0.00000","wp.13" +"0.00000","0.00000","wp.14" +"0.00000","0.00000","wp.15" +"0.00000","0.00000","wp.16" +"0.00000","0.00000","wp.17" +"0.00000","0.00000","wp.18" +"0.00000","0.00000","wp.19" +"0.00000","0.00000","wp.20" +"0.00000","0.00000","wp.21" +"0.00000","0.00000","wp.22" +"0.00000","0.00000","wp.23" +"0.00000","0.00000","wp.24" +"0.00000","0.00000","wp.25" +"0.00000","0.00000","wp.26" +"0.00000","0.00000","wp.27" +"0.00000","0.00000","wp.28" +"0.00000","0.00000","wp.29" +"0.00000","0.00000","wp.30" +"0.00000","0.00000","wp.31" +"0.00000","0.00000","wp.32" +"0.00000","0.00000","wp.33" +"0.00000","0.00000","wp.34" +"0.00000","0.00000","wp.35" +"0.00000","0.00000","wp.36" +"0.00000","0.00000","wp.37" +"0.00000","0.00000","wp.38" +"0.00000","0.00000","wp.39" +"0.00000","0.00000","wp.40" +"0.00000","0.00000","wp.41" +"0.00000","0.00000","wp.42" +"0.00000","0.00000","wp.43" +"0.00000","0.00000","wp.44" +"0.00000","0.00000","wp.45" +"0.00000","0.00000","wp.46" +"0.00000","0.00000","wp.47" +"0.00000","0.00000","wp.48" +"0.00000","0.00000","wp.49" +"0.00000","0.00000","wp.50" +"0.00000","0.00000","wp.51" +"0.00000","0.00000","wp.52" +"0.00000","0.00000","wp.53" +"0.00000","0.00000","wp.54" +"0.00000","0.00000","wp.55" +"0.00000","0.00000","wp.56" +"0.00000","0.00000","wp.57" +"0.00000","0.00000","wp.58" +"0.00000","0.00000","wp.59" +"0.00000","0.00000","wp.60" +"0.00000","0.00000","wp.61" +"0.00000","0.00000","wp.62" +"0.00000","0.00000","wp.63" +"0.00000","0.00000","wp.64" +"0.00000","0.00000","wp.65" +"0.00000","0.00000","wp.66" +"0.00000","0.00000","wp.67" +"0.00000","0.00000","wp.68" +"0.00000","0.00000","wp.69" +"0.00000","0.00000","wp.70" +"0.00000","0.00000","wp.71" +"0.00000","0.00000","wp.72" +"0.00000","0.00000","wp.73" +"0.00000","0.00000","wp.74" +"0.00000","0.00000","wp.75" +"0.00000","0.00000","wp.76" +"0.00000","0.00000","wp.77" +"0.00000","0.00000","wp.78" +"0.00000","0.00000","wp.79" +"0.00000","0.00000","wp.80" +"0.00000","0.00000","wp.81" +"0.00000","0.00000","wp.82" +"0.00000","0.00000","wp.83" +"0.00000","0.00000","wp.84" +"0.00000","0.00000","wp.85" +"0.00000","0.00000","wp.86" +"0.00000","0.00000","wp.87" +"0.00000","0.00000","wp.88" +"0.00000","0.00000","wp.89" +"0.00000","0.00000","wp.90" +"0.00000","0.00000","wp.91" +"0.00000","0.00000","wp.92" +"0.00000","0.00000","wp.93" +"0.00000","0.00000","wp.94" +"0.00000","0.00000","wp.95" +"0.00000","0.00000","wp.96" +"0.00000","0.00000","wp.97" +"0.00000","0.00000","wp.98" +"0.00000","0.00000","wp.99" +"0.00000","0.00000","w.100" +"0.00000","0.00000","w.101" +"0.00000","0.00000","w.102" +"0.00000","0.00000","w.103" +"0.00000","0.00000","w.104" +"0.00000","0.00000","w.105" +"0.00000","0.00000","w.106" +"0.00000","0.00000","w.107" +"0.00000","0.00000","w.108" +"0.00000","0.00000","w.109" +"0.00000","0.00000","w.110" +"0.00000","0.00000","w.111" +"0.00000","0.00000","w.112" +"0.00000","0.00000","w.113" +"0.00000","0.00000","w.114" +"0.00000","0.00000","w.115" +"0.00000","0.00000","w.116" +"0.00000","0.00000","w.117" +"0.00000","0.00000","w.118" +"0.00000","0.00000","w.119" +"0.00000","0.00000","w.120" +"0.00000","0.00000","w.121" +"0.00000","0.00000","w.122" +"0.00000","0.00000","w.123" +"0.00000","0.00000","w.124" +"0.00000","0.00000","w.125" +"0.00000","0.00000","w.126" +"0.00000","0.00000","w.127" +"0.00000","0.00000","w.128" +"0.00000","0.00000","w.129" +"0.00000","0.00000","w.130" +"0.00000","0.00000","w.131" +"0.00000","0.00000","w.132" +"0.00000","0.00000","w.133" +"0.00000","0.00000","w.134" +"0.00000","0.00000","w.135" +"0.00000","0.00000","w.136" +"0.00000","0.00000","w.137" +"0.00000","0.00000","w.138" +"0.00000","0.00000","w.139" +"0.00000","0.00000","w.140" +"0.00000","0.00000","w.141" +"0.00000","0.00000","w.142" +"0.00000","0.00000","w.143" +"0.00000","0.00000","w.144" +"0.00000","0.00000","w.145" +"0.00000","0.00000","w.146" +"0.00000","0.00000","w.147" +"0.00000","0.00000","w.148" +"0.00000","0.00000","w.149" diff --git a/reference/mkshort6.csv b/reference/mkshort6.csv index 230f75523..ceecf9ba0 100644 --- a/reference/mkshort6.csv +++ b/reference/mkshort6.csv @@ -1,150 +1,150 @@ -"0.00000", "0.00000", "wp" -"0.00000", "0.00000", "wp.1" -"0.00000", "0.00000", "wp.2" -"0.00000", "0.00000", "wp.3" -"0.00000", "0.00000", "wp.4" -"0.00000", "0.00000", "wp.5" -"0.00000", "0.00000", "wp.6" -"0.00000", "0.00000", "wp.7" -"0.00000", "0.00000", "wp.8" -"0.00000", "0.00000", "wp.9" -"0.00000", "0.00000", "wp.10" -"0.00000", "0.00000", "wp.11" -"0.00000", "0.00000", "wp.12" -"0.00000", "0.00000", "wp.13" -"0.00000", "0.00000", "wp.14" -"0.00000", "0.00000", "wp.15" -"0.00000", "0.00000", "wp.16" -"0.00000", "0.00000", "wp.17" -"0.00000", "0.00000", "wp.18" -"0.00000", "0.00000", "wp.19" -"0.00000", "0.00000", "wp.20" -"0.00000", "0.00000", "wp.21" -"0.00000", "0.00000", "wp.22" -"0.00000", "0.00000", "wp.23" -"0.00000", "0.00000", "wp.24" -"0.00000", "0.00000", "wp.25" -"0.00000", "0.00000", "wp.26" -"0.00000", "0.00000", "wp.27" -"0.00000", "0.00000", "wp.28" -"0.00000", "0.00000", "wp.29" -"0.00000", "0.00000", "wp.30" -"0.00000", "0.00000", "wp.31" -"0.00000", "0.00000", "wp.32" -"0.00000", "0.00000", "wp.33" -"0.00000", "0.00000", "wp.34" -"0.00000", "0.00000", "wp.35" -"0.00000", "0.00000", "wp.36" -"0.00000", "0.00000", "wp.37" -"0.00000", "0.00000", "wp.38" -"0.00000", "0.00000", "wp.39" -"0.00000", "0.00000", "wp.40" -"0.00000", "0.00000", "wp.41" -"0.00000", "0.00000", "wp.42" -"0.00000", "0.00000", "wp.43" -"0.00000", "0.00000", "wp.44" -"0.00000", "0.00000", "wp.45" -"0.00000", "0.00000", "wp.46" -"0.00000", "0.00000", "wp.47" -"0.00000", "0.00000", "wp.48" -"0.00000", "0.00000", "wp.49" -"0.00000", "0.00000", "wp.50" -"0.00000", "0.00000", "wp.51" -"0.00000", "0.00000", "wp.52" -"0.00000", "0.00000", "wp.53" -"0.00000", "0.00000", "wp.54" -"0.00000", "0.00000", "wp.55" -"0.00000", "0.00000", "wp.56" -"0.00000", "0.00000", "wp.57" -"0.00000", "0.00000", "wp.58" -"0.00000", "0.00000", "wp.59" -"0.00000", "0.00000", "wp.60" -"0.00000", "0.00000", "wp.61" -"0.00000", "0.00000", "wp.62" -"0.00000", "0.00000", "wp.63" -"0.00000", "0.00000", "wp.64" -"0.00000", "0.00000", "wp.65" -"0.00000", "0.00000", "wp.66" -"0.00000", "0.00000", "wp.67" -"0.00000", "0.00000", "wp.68" -"0.00000", "0.00000", "wp.69" -"0.00000", "0.00000", "wp.70" -"0.00000", "0.00000", "wp.71" -"0.00000", "0.00000", "wp.72" -"0.00000", "0.00000", "wp.73" -"0.00000", "0.00000", "wp.74" -"0.00000", "0.00000", "wp.75" -"0.00000", "0.00000", "wp.76" -"0.00000", "0.00000", "wp.77" -"0.00000", "0.00000", "wp.78" -"0.00000", "0.00000", "wp.79" -"0.00000", "0.00000", "wp.80" -"0.00000", "0.00000", "wp.81" -"0.00000", "0.00000", "wp.82" -"0.00000", "0.00000", "wp.83" -"0.00000", "0.00000", "wp.84" -"0.00000", "0.00000", "wp.85" -"0.00000", "0.00000", "wp.86" -"0.00000", "0.00000", "wp.87" -"0.00000", "0.00000", "wp.88" -"0.00000", "0.00000", "wp.89" -"0.00000", "0.00000", "wp.90" -"0.00000", "0.00000", "wp.91" -"0.00000", "0.00000", "wp.92" -"0.00000", "0.00000", "wp.93" -"0.00000", "0.00000", "wp.94" -"0.00000", "0.00000", "wp.95" -"0.00000", "0.00000", "wp.96" -"0.00000", "0.00000", "wp.97" -"0.00000", "0.00000", "wp.98" -"0.00000", "0.00000", "wp.99" -"0.00000", "0.00000", "wp.100" -"0.00000", "0.00000", "wp.101" -"0.00000", "0.00000", "wp.102" -"0.00000", "0.00000", "wp.103" -"0.00000", "0.00000", "wp.104" -"0.00000", "0.00000", "wp.105" -"0.00000", "0.00000", "wp.106" -"0.00000", "0.00000", "wp.107" -"0.00000", "0.00000", "wp.108" -"0.00000", "0.00000", "wp.109" -"0.00000", "0.00000", "wp.110" -"0.00000", "0.00000", "wp.111" -"0.00000", "0.00000", "wp.112" -"0.00000", "0.00000", "wp.113" -"0.00000", "0.00000", "wp.114" -"0.00000", "0.00000", "wp.115" -"0.00000", "0.00000", "wp.116" -"0.00000", "0.00000", "wp.117" -"0.00000", "0.00000", "wp.118" -"0.00000", "0.00000", "wp.119" -"0.00000", "0.00000", "wp.120" -"0.00000", "0.00000", "wp.121" -"0.00000", "0.00000", "wp.122" -"0.00000", "0.00000", "wp.123" -"0.00000", "0.00000", "wp.124" -"0.00000", "0.00000", "wp.125" -"0.00000", "0.00000", "wp.126" -"0.00000", "0.00000", "wp.127" -"0.00000", "0.00000", "wp.128" -"0.00000", "0.00000", "wp.129" -"0.00000", "0.00000", "wp.130" -"0.00000", "0.00000", "wp.131" -"0.00000", "0.00000", "wp.132" -"0.00000", "0.00000", "wp.133" -"0.00000", "0.00000", "wp.134" -"0.00000", "0.00000", "wp.135" -"0.00000", "0.00000", "wp.136" -"0.00000", "0.00000", "wp.137" -"0.00000", "0.00000", "wp.138" -"0.00000", "0.00000", "wp.139" -"0.00000", "0.00000", "wp.140" -"0.00000", "0.00000", "wp.141" -"0.00000", "0.00000", "wp.142" -"0.00000", "0.00000", "wp.143" -"0.00000", "0.00000", "wp.144" -"0.00000", "0.00000", "wp.145" -"0.00000", "0.00000", "wp.146" -"0.00000", "0.00000", "wp.147" -"0.00000", "0.00000", "wp.148" -"0.00000", "0.00000", "wp.149" +"0.00000","0.00000","wp" +"0.00000","0.00000","wp.1" +"0.00000","0.00000","wp.2" +"0.00000","0.00000","wp.3" +"0.00000","0.00000","wp.4" +"0.00000","0.00000","wp.5" +"0.00000","0.00000","wp.6" +"0.00000","0.00000","wp.7" +"0.00000","0.00000","wp.8" +"0.00000","0.00000","wp.9" +"0.00000","0.00000","wp.10" +"0.00000","0.00000","wp.11" +"0.00000","0.00000","wp.12" +"0.00000","0.00000","wp.13" +"0.00000","0.00000","wp.14" +"0.00000","0.00000","wp.15" +"0.00000","0.00000","wp.16" +"0.00000","0.00000","wp.17" +"0.00000","0.00000","wp.18" +"0.00000","0.00000","wp.19" +"0.00000","0.00000","wp.20" +"0.00000","0.00000","wp.21" +"0.00000","0.00000","wp.22" +"0.00000","0.00000","wp.23" +"0.00000","0.00000","wp.24" +"0.00000","0.00000","wp.25" +"0.00000","0.00000","wp.26" +"0.00000","0.00000","wp.27" +"0.00000","0.00000","wp.28" +"0.00000","0.00000","wp.29" +"0.00000","0.00000","wp.30" +"0.00000","0.00000","wp.31" +"0.00000","0.00000","wp.32" +"0.00000","0.00000","wp.33" +"0.00000","0.00000","wp.34" +"0.00000","0.00000","wp.35" +"0.00000","0.00000","wp.36" +"0.00000","0.00000","wp.37" +"0.00000","0.00000","wp.38" +"0.00000","0.00000","wp.39" +"0.00000","0.00000","wp.40" +"0.00000","0.00000","wp.41" +"0.00000","0.00000","wp.42" +"0.00000","0.00000","wp.43" +"0.00000","0.00000","wp.44" +"0.00000","0.00000","wp.45" +"0.00000","0.00000","wp.46" +"0.00000","0.00000","wp.47" +"0.00000","0.00000","wp.48" +"0.00000","0.00000","wp.49" +"0.00000","0.00000","wp.50" +"0.00000","0.00000","wp.51" +"0.00000","0.00000","wp.52" +"0.00000","0.00000","wp.53" +"0.00000","0.00000","wp.54" +"0.00000","0.00000","wp.55" +"0.00000","0.00000","wp.56" +"0.00000","0.00000","wp.57" +"0.00000","0.00000","wp.58" +"0.00000","0.00000","wp.59" +"0.00000","0.00000","wp.60" +"0.00000","0.00000","wp.61" +"0.00000","0.00000","wp.62" +"0.00000","0.00000","wp.63" +"0.00000","0.00000","wp.64" +"0.00000","0.00000","wp.65" +"0.00000","0.00000","wp.66" +"0.00000","0.00000","wp.67" +"0.00000","0.00000","wp.68" +"0.00000","0.00000","wp.69" +"0.00000","0.00000","wp.70" +"0.00000","0.00000","wp.71" +"0.00000","0.00000","wp.72" +"0.00000","0.00000","wp.73" +"0.00000","0.00000","wp.74" +"0.00000","0.00000","wp.75" +"0.00000","0.00000","wp.76" +"0.00000","0.00000","wp.77" +"0.00000","0.00000","wp.78" +"0.00000","0.00000","wp.79" +"0.00000","0.00000","wp.80" +"0.00000","0.00000","wp.81" +"0.00000","0.00000","wp.82" +"0.00000","0.00000","wp.83" +"0.00000","0.00000","wp.84" +"0.00000","0.00000","wp.85" +"0.00000","0.00000","wp.86" +"0.00000","0.00000","wp.87" +"0.00000","0.00000","wp.88" +"0.00000","0.00000","wp.89" +"0.00000","0.00000","wp.90" +"0.00000","0.00000","wp.91" +"0.00000","0.00000","wp.92" +"0.00000","0.00000","wp.93" +"0.00000","0.00000","wp.94" +"0.00000","0.00000","wp.95" +"0.00000","0.00000","wp.96" +"0.00000","0.00000","wp.97" +"0.00000","0.00000","wp.98" +"0.00000","0.00000","wp.99" +"0.00000","0.00000","wp.100" +"0.00000","0.00000","wp.101" +"0.00000","0.00000","wp.102" +"0.00000","0.00000","wp.103" +"0.00000","0.00000","wp.104" +"0.00000","0.00000","wp.105" +"0.00000","0.00000","wp.106" +"0.00000","0.00000","wp.107" +"0.00000","0.00000","wp.108" +"0.00000","0.00000","wp.109" +"0.00000","0.00000","wp.110" +"0.00000","0.00000","wp.111" +"0.00000","0.00000","wp.112" +"0.00000","0.00000","wp.113" +"0.00000","0.00000","wp.114" +"0.00000","0.00000","wp.115" +"0.00000","0.00000","wp.116" +"0.00000","0.00000","wp.117" +"0.00000","0.00000","wp.118" +"0.00000","0.00000","wp.119" +"0.00000","0.00000","wp.120" +"0.00000","0.00000","wp.121" +"0.00000","0.00000","wp.122" +"0.00000","0.00000","wp.123" +"0.00000","0.00000","wp.124" +"0.00000","0.00000","wp.125" +"0.00000","0.00000","wp.126" +"0.00000","0.00000","wp.127" +"0.00000","0.00000","wp.128" +"0.00000","0.00000","wp.129" +"0.00000","0.00000","wp.130" +"0.00000","0.00000","wp.131" +"0.00000","0.00000","wp.132" +"0.00000","0.00000","wp.133" +"0.00000","0.00000","wp.134" +"0.00000","0.00000","wp.135" +"0.00000","0.00000","wp.136" +"0.00000","0.00000","wp.137" +"0.00000","0.00000","wp.138" +"0.00000","0.00000","wp.139" +"0.00000","0.00000","wp.140" +"0.00000","0.00000","wp.141" +"0.00000","0.00000","wp.142" +"0.00000","0.00000","wp.143" +"0.00000","0.00000","wp.144" +"0.00000","0.00000","wp.145" +"0.00000","0.00000","wp.146" +"0.00000","0.00000","wp.147" +"0.00000","0.00000","wp.148" +"0.00000","0.00000","wp.149" diff --git a/testo.d/mkshort.test b/testo.d/mkshort.test index 51007a3ff..b48cd14eb 100644 --- a/testo.d/mkshort.test +++ b/testo.d/mkshort.test @@ -11,3 +11,31 @@ ${VALGRIND} "${PNAME}" -s -i unicsv -f ${REFERENCE}/mkshort.csv -o xcsv,style=${ echo "${PNAME} succeeded! (it shouldn't have with this input...)" } compare ${REFERENCE}/mkshort3.log ${TMPDIR}/mkshort3.log + +rm -f ${TMPDIR}/mkshort4.log +# whitespace +echo '0,0," a e "' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=8,snwhite=1 -F - >> ${TMPDIR}/mkshort4.log +# trailing numbers +echo '0,0,"abcd0123"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=7 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"abcd0123"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=6 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"abcd0123"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=5 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"abcd0123"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=4 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"abcd0123"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=3 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"abcd0123"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=2 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"abcd0123"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=1 -F - >>${TMPDIR}/mkshort4.log +# vowels +echo '0,0,"xxaeiouzz"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=9 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"xxaeiouzz"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=8 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"xxaeiouzz"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=7 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"xxaeiouzz"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=6 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"xxaeiouzz"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=5 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"xxaeiouzz"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=4 -F - >>${TMPDIR}/mkshort4.log +#truncation +echo '0,0,"abcd"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=4 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"abcd"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=3 -F - >>${TMPDIR}/mkshort4.log +echo '0,0,"abcd"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=2 -F - >>${TMPDIR}/mkshort4.log +#replacements +echo '0,0,"abcd one"' | gpsbabel -s -i unicsv,fields=lat+long+name -f - -o xcsv,style=reference/mkshort.style,snlen=8 -F - >>${TMPDIR}/mkshort4.log + +compare ${REFERENCE}/mkshort4.log ${TMPDIR}/mkshort4.log + From 45268f7ea7829a34b67ec0a83019bc82b6d34bd2 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 6 Sep 2023 07:34:56 -0600 Subject: [PATCH 003/132] mkshort becomes a class (#1173) * make mkshort a class * add new file mkshort.h * refactor names * use bools with mkshort setters --- CMakeLists.txt | 1 + defs.h | 23 ------ garmin.cc | 44 +++++----- garmin_gpi.cc | 21 ++--- garmin_gpi.h | 5 +- gdb.cc | 36 ++++---- gdb.h | 5 +- gpx.cc | 20 ++--- gpx.h | 3 +- html.cc | 10 ++- html.h | 3 +- humminbird.cc | 74 +++++++++-------- humminbird.h | 5 +- lowranceusr.cc | 9 +- lowranceusr.h | 3 +- main.cc | 13 +-- mkshort.cc | 220 +++++++++++++------------------------------------ mkshort.h | 109 ++++++++++++++++++++++++ nmea.cc | 12 +-- nmea.h | 3 +- ozi.cc | 23 +++--- text.cc | 9 +- text.h | 3 +- tpg.cc | 15 ++-- vcf.cc | 4 - xcsv.cc | 20 ++--- xcsv.h | 24 ++---- 27 files changed, 349 insertions(+), 368 deletions(-) create mode 100644 mkshort.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 12a6c11c4..476883cca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,6 +226,7 @@ set(HEADERS legacyformat.h igc.h lowranceusr.h + mkshort.h nmea.h osm.h qstarz_bl_1000.h diff --git a/defs.h b/defs.h index 59529761a..2a337c319 100644 --- a/defs.h +++ b/defs.h @@ -838,29 +838,6 @@ using ff_exit = void (*)(); using ff_writeposn = void (*)(Waypoint*); using ff_readposn = Waypoint* (*)(posn_status*); -/* - * All shortname functions take a shortname handle as the first arg. - * This is an opaque pointer. Callers must not fondle the contents of it. - */ -// This is a crutch until the new C++ shorthandle goes in. - -struct mkshort_handle_imp; // forward declare, definition in mkshort.cc -using short_handle = mkshort_handle_imp*; - -QByteArray mkshort(short_handle, const QByteArray&, bool); -QString mkshort(short_handle, const QString&); -short_handle mkshort_new_handle(); -QString mkshort_from_wpt(short_handle h, const Waypoint* wpt); -void mkshort_del_handle(short_handle* h); -void setshort_length(short_handle, int n); -void setshort_badchars(short_handle, const char*); -void setshort_goodchars(short_handle, const char*); -void setshort_mustupper(short_handle, int n); -void setshort_mustuniq(short_handle, int n); -void setshort_whitespace_ok(short_handle, int n); -void setshort_repeating_whitespace_ok(short_handle, int n); -void setshort_defname(short_handle, const char* s); - #define ARGTYPE_UNKNOWN 0x00000000U #define ARGTYPE_INT 0x00000001U #define ARGTYPE_FLOAT 0x00000002U diff --git a/garmin.cc b/garmin.cc index 976033291..159d3c02d 100644 --- a/garmin.cc +++ b/garmin.cc @@ -51,11 +51,12 @@ #include "jeeps/gpsserial.h" // for DEFAULT_BAUD #include "jeeps/gpsutil.h" // for GPS_User, GPS_Enable_Diagnose, GPS_E... #include "src/core/datetime.h" // for DateTime +#include "mkshort.h" // for MakeShort #define MYNAME "GARMIN" static const char* portname; -static short_handle mkshort_handle; +static MakeShort* mkshort_handle; static GPS_PWay* tx_waylist; static GPS_PWay* tx_routelist; static GPS_PWay* cur_tx_routelist_entry; @@ -75,7 +76,7 @@ static char* baudopt = nullptr; static char* opt_codec = nullptr; static int baud = 0; static int categorybits; -static int receiver_must_upper = 1; +static bool receiver_must_upper = true; static QTextCodec* codec{nullptr}; #define MILITANT_VALID_WAYPT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" @@ -155,11 +156,11 @@ write_char_string(char* dest, const char* source, size_t destsize) static void rw_init(const QString& fname) { - receiver_must_upper = 1; + receiver_must_upper = true; const char* receiver_charset = "US-ASCII"; if (!mkshort_handle) { - mkshort_handle = mkshort_new_handle(); + mkshort_handle = new MakeShort; } if (global_opts.debug_level > 0) { @@ -218,7 +219,7 @@ rw_init(const QString& fname) } /* - * Grope the unit we're talking to to set setshort_length to + * Grope the unit we're talking to to set set_length to * 20 for the V, * 10 for Street Pilot, (old) Rhino, 76 * 6 for the III, 12, emap, and etrex @@ -260,7 +261,7 @@ rw_init(const QString& fname) case 574: /* Geko 201 */ receiver_short_length = 6; valid_waypt_chars = MILITANT_VALID_WAYPT_CHARS " +-"; - setshort_badchars(mkshort_handle, "\"$.,'!"); + mkshort_handle->set_badchars("\"$.,'!"); break; case 155: /* Garmin V */ @@ -270,7 +271,7 @@ rw_init(const QString& fname) break; case 382: /* C320 */ receiver_short_length = 30; - receiver_must_upper = 0; + receiver_must_upper = false; break; case 292: /* (60|76)C[S]x series */ case 421: /* Vista|Legend Cx */ @@ -280,7 +281,7 @@ rw_init(const QString& fname) case 957: /* Legend HC */ receiver_short_length = 14; snwhiteopt = xstrdup("1"); - receiver_must_upper = 0; + receiver_must_upper = false; /* This might be 8859-1 */ receiver_charset = "windows-1252"; break; @@ -288,20 +289,20 @@ rw_init(const QString& fname) case 1095: /* GPS 72H */ receiver_short_length = 10; valid_waypt_chars = MILITANT_VALID_WAYPT_CHARS " +-"; - setshort_badchars(mkshort_handle, "\"$.,'!"); + mkshort_handle->set_badchars("\"$.,'!"); break; case 231: /* Quest */ case 463: /* Quest 2 */ - receiver_must_upper = 0; + receiver_must_upper = false; receiver_short_length = 30; receiver_charset = "windows-1252"; break; case 577: // Rino 530HCx Version 2.50 - receiver_must_upper = 0; + receiver_must_upper = false; receiver_short_length = 14; break; case 429: // Streetpilot i3 - receiver_must_upper = 0; + receiver_must_upper = false; receiver_charset = "windows-1252"; receiver_short_length = 30; break; @@ -332,13 +333,13 @@ rw_init(const QString& fname) * If the user provided a short_length, override the calculated value. */ if (snlen) { - setshort_length(mkshort_handle, xstrtoi(snlen, nullptr, 10)); + mkshort_handle->set_length(xstrtoi(snlen, nullptr, 10)); } else { - setshort_length(mkshort_handle, receiver_short_length); + mkshort_handle->set_length(receiver_short_length); } if (snwhiteopt) { - setshort_whitespace_ok(mkshort_handle, xstrtoi(snwhiteopt, nullptr, 10)); + mkshort_handle->set_whitespace_ok(xstrtoi(snwhiteopt, nullptr, 10)); } /* @@ -346,12 +347,12 @@ rw_init(const QString& fname) * for the new models, we just release this safety check manually. */ if (receiver_must_upper) { - setshort_goodchars(mkshort_handle, valid_waypt_chars); + mkshort_handle->set_goodchars(valid_waypt_chars); } else { - setshort_badchars(mkshort_handle, ""); + mkshort_handle->set_badchars(""); } - setshort_mustupper(mkshort_handle, receiver_must_upper); + mkshort_handle->set_mustupper(receiver_must_upper); /* * This used to mean something when we used cet, but these days this @@ -398,9 +399,8 @@ rw_deinit() } } - if (mkshort_handle) { - mkshort_del_handle(&mkshort_handle); - } + delete mkshort_handle; + mkshort_handle = nullptr; xfree(portname); portname = nullptr; @@ -888,7 +888,7 @@ waypoint_prepare() * mkshort will do collision detection and namespace * cleaning */ - QByteArray ident = mkshort(mkshort_handle, + QByteArray ident = mkshort_handle->mkshort( global_opts.synthesize_shortnames ? str_from_unicode(src) : str_from_unicode(wpt->shortname), diff --git a/garmin_gpi.cc b/garmin_gpi.cc index 473871bb2..793c3c117 100644 --- a/garmin_gpi.cc +++ b/garmin_gpi.cc @@ -1044,7 +1044,7 @@ GarminGPIFormat::enum_waypt_cb(const Waypoint* ref) const auto* wpt = new Waypoint(*ref); if (*opt_unique == '1') { - wpt->shortname = mkshort(short_h, wpt->shortname); + wpt->shortname = short_h->mkshort(wpt->shortname); } wdata_add_wpt(wdata, wpt); @@ -1252,15 +1252,15 @@ GarminGPIFormat::wr_init(const QString& fname) fout = gbfopen_le(fname, "wb", MYNAME); - short_h = mkshort_new_handle(); + short_h = new MakeShort; - setshort_length(short_h, 1024); - setshort_badchars(short_h, "\r\n"); - setshort_mustupper(short_h, 0); - setshort_mustuniq(short_h, 1); - setshort_whitespace_ok(short_h, 1); - setshort_repeating_whitespace_ok(short_h, 0); - setshort_defname(short_h, "POI"); + short_h->set_length(1024); + short_h->set_badchars("\r\n"); + short_h->set_mustupper(false); + short_h->set_mustuniq(true); + short_h->set_whitespace_ok(true); + short_h->set_repeating_whitespace_ok(false); + short_h->set_defname("POI"); codepage = 0; @@ -1325,7 +1325,8 @@ void GarminGPIFormat::wr_deinit() { wdata_free(wdata); - mkshort_del_handle(&short_h); + delete short_h; + short_h = nullptr; gbfclose(fout); if ((opt_sleep) && !gpsbabel_testmode()) { /* don't sleep during 'testo' */ diff --git a/garmin_gpi.h b/garmin_gpi.h index d13920184..5594f6ffc 100644 --- a/garmin_gpi.h +++ b/garmin_gpi.h @@ -55,10 +55,11 @@ #include // for int32_t, int16_t, uint16_t #include // for time_t -#include "defs.h" // for arglist_t, ARG_NOMINMAX, ff_cap, Waypoint, ARGTYPE_BOOL, ARGTYPE_STRING, ff_cap_none, ARGTYPE_FILE, ARGTYPE_INT, bounds, ff_cap_read, ff_cap_write, ff_type, ff_type_file, short_handle +#include "defs.h" // for arglist_t, ARG_NOMINMAX, ff_cap, Waypoint, ARGTYPE_BOOL, ARGTYPE_STRING, ff_cap_none, ARGTYPE_FILE, ARGTYPE_INT, bounds, ff_cap_read, ff_cap_write, ff_type, ff_type_file #include "format.h" // for Format #include "garmin_fs.h" // for garmin_fs_t #include "gbfile.h" // for gbfile +#include "mkshort.h" // for MakeShort class GarminGPIFormat : public Format @@ -377,7 +378,7 @@ class GarminGPIFormat : public Format uint16_t codepage{}; /* code-page, e.g. 1252, 65001 */ reader_data_t* rdata{}; writer_data_t* wdata{}; - short_handle short_h{}; + MakeShort* short_h{}; char units{}; time_t gpi_timestamp = 0; QTextCodec* codec{nullptr}; diff --git a/gdb.cc b/gdb.cc index 347af342f..5efbb55f3 100644 --- a/gdb.cc +++ b/gdb.cc @@ -40,13 +40,14 @@ #include // for memset, strstr, strcmp #include // for next -#include "defs.h" // for Waypoint, warning, route_head, fatal, UrlLink, bounds, mkshort, UrlList, unknown_alt, xfree, waypt_add_to_bounds, waypt_init_bounds, xstrtoi, mkshort_del_handle, route_add_wpt, route_disp_all, waypt_bounds_valid, xmalloc, gb_color, WaypointList, find_wa... +#include "defs.h" // for Waypoint, warning, route_head, fatal, UrlLink, bounds, UrlList, unknown_alt, xfree, waypt_add_to_bounds, waypt_init_bounds, xstrtoi, route_add_wpt, route_disp_all, waypt_bounds_valid, xmalloc, gb_color, WaypointList, find_wa... #include "formspec.h" // for FormatSpecificDataList #include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t, garmin_fs_alloc #include "garmin_tables.h" // for gt_waypt_class_map_point, gt_color_index_by_rgb, gt_color_value, gt_waypt_classes_e, gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, gt_gdb_display_mode_symbol, gt_get_icao_country, gt_waypt_class_user_waypoint, GDB, gt_display_mode_symbol #include "gbfile.h" // for gbfgetint32, gbfputint32, gbfgetc, gbfread, gbfwrite, gbfgetdbl, gbfputc, gbfgetcstr, gbfclose, gbfgetnativecstr, gbfopen_le, gbfputint16, gbfile, gbfcopyfrom, gbfputcstr, gbfrewind, gbfseek, gbftell, gbfgetcstr_old, gbfgetint16, gbfgetuint32, gbfputdbl #include "grtcirc.h" // for RAD, gcdist, radtometers #include "jeeps/gpsmath.h" // for GPS_Math_Deg_To_Semi, GPS_Math_Semi_To_Deg +#include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime @@ -1113,19 +1114,17 @@ GdbFormat::read() void GdbFormat::reset_short_handle(const char* defname) { - if (short_h != nullptr) { - mkshort_del_handle(&short_h); - } + delete short_h; - short_h = mkshort_new_handle(); + short_h = new MakeShort; - setshort_length(short_h, kGDBNameBufferLen); - setshort_badchars(short_h, "\r\n\t"); - setshort_mustupper(short_h, 0); - setshort_mustuniq(short_h, 1); - setshort_whitespace_ok(short_h, 1); - setshort_repeating_whitespace_ok(short_h, 1); - setshort_defname(short_h, defname); + short_h->set_length(kGDBNameBufferLen); + short_h->set_badchars("\r\n\t"); + short_h->set_mustupper(false); + short_h->set_mustuniq(true); + short_h->set_whitespace_ok(true); + short_h->set_repeating_whitespace_ok(true); + short_h->set_defname(defname); } /* ----------------------------------------------------------------------------*/ @@ -1613,7 +1612,7 @@ GdbFormat::write_waypoint_cb(const Waypoint* refpt) } } - name = mkshort(short_h, name); + name = short_h->mkshort(name); wpt->extra_data = new QString(name); write_waypoint(wpt, name, gmsd, icon, display); @@ -1630,9 +1629,9 @@ GdbFormat::write_route_cb(const route_head* rte) QString name; if (rte->rte_name.isNull()) { - name = mkshort(short_h, QString::asprintf("Route%04d", rte->rte_num)); + name = short_h->mkshort(QString::asprintf("Route%04d", rte->rte_num)); } else { - name = mkshort(short_h, rte->rte_name); + name = short_h->mkshort(rte->rte_name); } rte_ct++; /* increase informational number of written routes */ @@ -1652,9 +1651,9 @@ GdbFormat::write_track_cb(const route_head* trk) QString name; if (trk->rte_name.isNull()) { - name = mkshort(short_h, QString::asprintf("Track%04d", trk->rte_num)); + name = short_h->mkshort(QString::asprintf("Track%04d", trk->rte_num)); } else { - name = mkshort(short_h, trk->rte_name); + name = short_h->mkshort(trk->rte_name); } trk_ct++; /* increase informational number of written tracks */ @@ -1704,7 +1703,8 @@ GdbFormat::wr_deinit() { disp_summary(fout); gdb_flush_waypt_queue(waypt_nameposn_out_hash); - mkshort_del_handle(&short_h); + delete short_h; + short_h = nullptr; gbfclose(fout); gbfclose(ftmp); } diff --git a/gdb.h b/gdb.h index b418a51a1..1e30b7b6c 100644 --- a/gdb.h +++ b/gdb.h @@ -32,11 +32,12 @@ #include // for QVector #include // for QT_VERSION, QT_VERSION_CHECK -#include "defs.h" // for arglist_t, Waypoint, route_head, ARGTYPE_BOOL, ARGTYPE_INT, ARG_NOMINMAX, bounds, FF_CAP_RW_ALL, ff_cap, ff_type, ff_type_file, short_handle +#include "defs.h" // for arglist_t, Waypoint, route_head, ARGTYPE_BOOL, ARGTYPE_INT, ARG_NOMINMAX, bounds, FF_CAP_RW_ALL, ff_cap, ff_type, ff_type_file #include "format.h" // for Format #include "garmin_fs.h" // for garmin_fs_t #include "garmin_tables.h" // for gt_waypt_classes_e #include "gbfile.h" // for gbfile +#include "mkshort.h" // for MakeShort class GdbFormat : public Format @@ -172,7 +173,7 @@ class GdbFormat : public Format WptNamePosnHash waypt_nameposn_in_hidden_hash; WptNameHash waypt_name_in_hidden_hash; WptNamePosnHash waypt_nameposn_out_hash; - short_handle short_h{}; + MakeShort* short_h{}; char* gdb_opt_category{}; char* gdb_opt_ver{}; diff --git a/gpx.cc b/gpx.cc index 4e591b33e..6d0a4c042 100644 --- a/gpx.cc +++ b/gpx.cc @@ -49,6 +49,7 @@ #include "garmin_fs.h" // for garmin_fs_xml_convert, garmin_fs_xml_fprint, GMSD_FIND #include "garmin_tables.h" // for gt_color_index_by_rgb, gt_color_name, gt_color_value_by_name #include "geocache.h" // for Geocache, Geocache::UtfSt... +#include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime #include "src/core/file.h" // for File #include "src/core/logging.h" // for Warning, Fatal @@ -90,17 +91,15 @@ inline QString GpxFormat::toString(float f) void GpxFormat::gpx_reset_short_handle() { - if (mkshort_handle != nullptr) { - mkshort_del_handle(&mkshort_handle); - } + delete mkshort_handle; - mkshort_handle = mkshort_new_handle(); + mkshort_handle = new MakeShort; if (suppresswhite) { - setshort_whitespace_ok(mkshort_handle, 0); + mkshort_handle->set_whitespace_ok(false); } - setshort_length(mkshort_handle, xstrtoi(snlen, nullptr, 10)); + mkshort_handle->set_length(xstrtoi(snlen, nullptr, 10)); } void @@ -971,7 +970,8 @@ GpxFormat::wr_deinit() delete oqfile; oqfile = nullptr; - mkshort_del_handle(&mkshort_handle); + delete mkshort_handle; + mkshort_handle = nullptr; } QString @@ -1323,7 +1323,7 @@ GpxFormat::gpx_waypt_pr(const Waypoint* waypointp) const writer->writeAttribute(QStringLiteral("lon"), toString(waypointp->longitude)); QString oname = global_opts.synthesize_shortnames ? - mkshort_from_wpt(mkshort_handle, waypointp) : + mkshort_handle->mkshort_from_wpt(waypointp) : waypointp->shortname; gpx_write_common_position(waypointp, gpxpt_waypoint); gpx_write_common_description(waypointp, oname); @@ -1402,7 +1402,7 @@ GpxFormat::gpx_track_disp(const Waypoint* waypointp) const gpx_write_common_position(waypointp, gpxpt_track); QString oname = global_opts.synthesize_shortnames ? - mkshort_from_wpt(mkshort_handle, waypointp) : + mkshort_handle->mkshort_from_wpt(waypointp) : waypointp->shortname; gpx_write_common_description(waypointp, waypointp->wpt_flags.shortname_is_synthetic ? @@ -1491,7 +1491,7 @@ GpxFormat::gpx_route_disp(const Waypoint* waypointp) const writer->writeAttribute(QStringLiteral("lon"), toString(waypointp->longitude)); QString oname = global_opts.synthesize_shortnames ? - mkshort_from_wpt(mkshort_handle, waypointp) : + mkshort_handle->mkshort_from_wpt(waypointp) : waypointp->shortname; gpx_write_common_position(waypointp, gpxpt_route); gpx_write_common_description(waypointp, oname); diff --git a/gpx.h b/gpx.h index f02da3b21..1fd5b9692 100644 --- a/gpx.h +++ b/gpx.h @@ -34,6 +34,7 @@ #include "defs.h" #include "format.h" // for Format #include "formspec.h" // for FormatSpecificData +#include "mkshort.h" // for MakeShort #include "src/core/file.h" // for File #include "src/core/xmlstreamwriter.h" // for XmlStreamWriter #include "src/core/xmltag.h" // for xml_tag @@ -243,7 +244,7 @@ class GpxFormat : public Format gpsbabel::File* iqfile{}; gpsbabel::File* oqfile{}; gpsbabel::XmlStreamWriter* writer{}; - short_handle mkshort_handle{}; + MakeShort* mkshort_handle{}; QString link_url; QString link_text; QString link_type; diff --git a/html.cc b/html.cc index 54ca38428..3273a1d96 100644 --- a/html.cc +++ b/html.cc @@ -33,6 +33,7 @@ #include "formspec.h" // for FormatSpecificDataList, kFsGpx #include "geocache.h" // for Geocache, Geocache::UtfString #include "jeeps/gpsmath.h" // for GPS_Math_WGS84_To_UTM_EN +#include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime #include "src/core/textstream.h" // for TextStream #include "src/core/xmltag.h" // for xml_findfirst, xml_tag, xml_attribute, fs_xml, xml_findnext @@ -45,7 +46,7 @@ HtmlFormat::wr_init(const QString& fname) { file_out = new gpsbabel::TextStream; file_out->open(fname, QIODevice::WriteOnly, MYNAME); - mkshort_handle = mkshort_new_handle(); + mkshort_handle = new MakeShort; } void @@ -54,7 +55,8 @@ HtmlFormat::wr_deinit() file_out->close(); delete file_out; file_out = nullptr; - mkshort_del_handle(&mkshort_handle); + delete mkshort_handle; + mkshort_handle = nullptr; } QString HtmlFormat::create_id(int sequence_number) @@ -78,7 +80,7 @@ HtmlFormat::html_disp(const Waypoint* wpt) const *file_out << "

\n"; *file_out << " \n"; - QString sn = global_opts.synthesize_shortnames ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname; + QString sn = global_opts.synthesize_shortnames ? mkshort_handle->mkshort_from_wpt(wpt) : wpt->shortname; *file_out << " \n"; *file_out << " + + + + + + + + +
\n"; *file_out << "

" << sn << " - "; @@ -216,7 +218,7 @@ HtmlFormat::html_index(const Waypoint* wpt) const void HtmlFormat::write() { - setshort_length(mkshort_handle, 6); + mkshort_handle->set_length(6); *file_out << "\n"; *file_out << "\n"; diff --git a/html.h b/html.h index 87ba8c0a9..0e930ba2f 100644 --- a/html.h +++ b/html.h @@ -26,6 +26,7 @@ #include "defs.h" #include "format.h" // for Format +#include "mkshort.h" // for MakeShort #include "src/core/textstream.h" // for TextStream @@ -62,7 +63,7 @@ class HtmlFormat : public Format /* Data Members */ gpsbabel::TextStream* file_out{nullptr}; - short_handle mkshort_handle{}; + MakeShort* mkshort_handle{}; int waypoint_number{}; diff --git a/humminbird.cc b/humminbird.cc index 95b4453ed..ea3f2f3a8 100644 --- a/humminbird.cc +++ b/humminbird.cc @@ -29,7 +29,8 @@ #include // for snprintf, SEEK_SET #include // for strncpy, memcpy, memset -#include "defs.h" // for Waypoint, be_read32, be_read16, be_write32, fatal, xfree, be_write16, route_head, xcalloc, track_add_wpt, xstrndup, mkshort, mkshort_del_handle, mkshort_new_handle, setshort_badchars, setshort_defname, setshort_length, setshort_mustuniq, setshort_... +#include "defs.h" // for Waypoint, be_read32, be_read16, be_write32, fatal, xfree, be_write16, route_head, xcalloc, track_add_wpt, xstrndup +#include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime @@ -582,33 +583,33 @@ HumminbirdBase::humminbird_wr_init(const QString& fname) { fout_ = gbfopen_be(fname, "wb", MYNAME); - wptname_sh = mkshort_new_handle(); - - setshort_length(wptname_sh, WPT_NAME_LEN - 1); - setshort_badchars(wptname_sh, BAD_CHARS); - setshort_mustupper(wptname_sh, 0); - setshort_mustuniq(wptname_sh, 0); - setshort_whitespace_ok(wptname_sh, 1); - setshort_repeating_whitespace_ok(wptname_sh, 1); - setshort_defname(wptname_sh, "WPT"); - - rtename_sh = mkshort_new_handle(); - setshort_length(rtename_sh, RTE_NAME_LEN - 1); - setshort_badchars(rtename_sh, BAD_CHARS); - setshort_mustupper(rtename_sh, 0); - setshort_mustuniq(rtename_sh, 0); - setshort_whitespace_ok(rtename_sh, 1); - setshort_repeating_whitespace_ok(rtename_sh, 1); - setshort_defname(rtename_sh, "Route"); - - trkname_sh = mkshort_new_handle(); - setshort_length(trkname_sh, RTE_NAME_LEN - 1); - setshort_badchars(trkname_sh, BAD_CHARS); - setshort_mustupper(trkname_sh, 0); - setshort_mustuniq(trkname_sh, 0); - setshort_whitespace_ok(trkname_sh, 1); - setshort_repeating_whitespace_ok(trkname_sh, 1); - setshort_defname(trkname_sh, "Track"); + wptname_sh = new MakeShort; + + wptname_sh->set_length(WPT_NAME_LEN - 1); + wptname_sh->set_badchars(BAD_CHARS); + wptname_sh->set_mustupper(false); + wptname_sh->set_mustuniq(false); + wptname_sh->set_whitespace_ok(true); + wptname_sh->set_repeating_whitespace_ok(true); + wptname_sh->set_defname("WPT"); + + rtename_sh = new MakeShort; + rtename_sh->set_length(RTE_NAME_LEN - 1); + rtename_sh->set_badchars(BAD_CHARS); + rtename_sh->set_mustupper(false); + rtename_sh->set_mustuniq(false); + rtename_sh->set_whitespace_ok(true); + rtename_sh->set_repeating_whitespace_ok(true); + rtename_sh->set_defname("Route"); + + trkname_sh = new MakeShort; + trkname_sh->set_length(RTE_NAME_LEN - 1); + trkname_sh->set_badchars(BAD_CHARS); + trkname_sh->set_mustupper(false); + trkname_sh->set_mustuniq(false); + trkname_sh->set_whitespace_ok(true); + trkname_sh->set_repeating_whitespace_ok(true); + trkname_sh->set_defname("Track"); waypoint_num = 0; rte_num_ = 0; @@ -617,9 +618,12 @@ HumminbirdBase::humminbird_wr_init(const QString& fname) void HumminbirdBase::humminbird_wr_deinit() { - mkshort_del_handle(&wptname_sh); - mkshort_del_handle(&rtename_sh); - mkshort_del_handle(&trkname_sh); + delete wptname_sh; + wptname_sh = nullptr; + delete rtename_sh; + rtename_sh = nullptr; + delete trkname_sh; + trkname_sh = nullptr; gbfclose(fout_); } @@ -666,8 +670,8 @@ HumminbirdFormat::humminbird_write_waypoint(const Waypoint* wpt) be_write32(&hum.north, qRound(north)); QString name = (global_opts.synthesize_shortnames) - ? mkshort_from_wpt(wptname_sh, wpt) - : mkshort(wptname_sh, wpt->shortname); + ? wptname_sh->mkshort_from_wpt(wpt) + : wptname_sh->mkshort(wpt->shortname); memset(&hum.name, 0, sizeof(hum.name)); memcpy(&hum.name, CSTR(name), name.length()); @@ -686,7 +690,7 @@ HumminbirdHTFormat::humminbird_track_head(const route_head* trk) trk_head = (humminbird_trk_header_t*) xcalloc(1, sizeof(humminbird_trk_header_t)); trk_points = (humminbird_trk_point_t*) xcalloc(max_points, sizeof(humminbird_trk_point_t)); - QString name = mkshort(trkname_sh, trk->rte_name); + QString name = trkname_sh->mkshort(trk->rte_name); strncpy(trk_head->name, CSTR(name), sizeof(trk_head->name)-1); be_write16(&trk_head->trk_num, trk->rte_num); } @@ -835,7 +839,7 @@ HumminbirdFormat::humminbird_rte_tail(const route_head* rte) be_write16(&humrte->num, humrte->num); be_write32(&humrte->time, humrte->time); - QString name = mkshort(rtename_sh, rte->rte_name); + QString name = rtename_sh->mkshort(rte->rte_name); strncpy(humrte->name, CSTR(name), sizeof(humrte->name)-1); gbfputuint32(RTE_MAGIC, fout_); diff --git a/humminbird.h b/humminbird.h index 9e7a43bdc..17f0c44c8 100644 --- a/humminbird.h +++ b/humminbird.h @@ -30,6 +30,7 @@ #include "defs.h" // for ff_cap, arglist_t, ff_cap_read, Waypoint, route_head, ff_cap_write, short_handle, ff_type, ff_type_file #include "format.h" // for Format #include "gbfile.h" // for gbfile +#include "mkshort.h" // for MakeShort class HumminbirdBase @@ -102,7 +103,9 @@ class HumminbirdBase gbfile* fin_{}; gbfile* fout_{}; int waypoint_num{}; - short_handle wptname_sh{}, rtename_sh{}, trkname_sh{}; + MakeShort* wptname_sh{}; + MakeShort* rtename_sh{}; + MakeShort* trkname_sh{}; humminbird_rte_t* humrte{}; int rte_num_{}; QMap map; diff --git a/lowranceusr.cc b/lowranceusr.cc index 89a61585b..cbfd1f05c 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -342,7 +342,7 @@ void LowranceusrFormat::wr_init(const QString& fname) { file_out = gbfopen_le(fname, "wb", MYNAME); - mkshort_handle = mkshort_new_handle(); + mkshort_handle = new MakeShort; waypt_out_count = 0; writing_version = xstrtoi(opt_wversion, nullptr, 10); if ((writing_version < 2) || (writing_version > 4)) { @@ -356,7 +356,8 @@ void LowranceusrFormat::wr_deinit() { gbfclose(file_out); - mkshort_del_handle(&mkshort_handle); + delete mkshort_handle; + mkshort_handle = nullptr; utf16le_codec = nullptr; delete waypt_table; waypt_table = nullptr; @@ -1284,7 +1285,7 @@ LowranceusrFormat::lowranceusr_waypt_disp(const Waypoint* wpt) const QString name; if ((wpt->shortname.isEmpty()) || global_opts.synthesize_shortnames) { if (!wpt->description.isEmpty() && global_opts.synthesize_shortnames) { - name = mkshort_from_wpt(mkshort_handle, wpt); + name = mkshort_handle->mkshort_from_wpt(wpt); } else if (!wpt->shortname.isEmpty()) { name = wpt->shortname; } else if (!wpt->description.isEmpty()) { @@ -1835,7 +1836,7 @@ LowranceusrFormat::write() { QString buf; - setshort_length(mkshort_handle, 15); + mkshort_handle->set_length(15); gbfputint32(writing_version, file_out); diff --git a/lowranceusr.h b/lowranceusr.h index 6013fdb27..51b4dbeed 100644 --- a/lowranceusr.h +++ b/lowranceusr.h @@ -101,6 +101,7 @@ #include "format.h" #include "formspec.h" // for FsChainFind, FsChainAdd, kFsLowranceusr4, FormatSpecificData #include "gbfile.h" // for gbfgetint32, gbfputint32, gbfputint16, gbfgetc, gbfgetint16, gbfwrite, gbfputc, gbfeof, gbfgetflt, gbfclose, gbfgetdbl, gbfopen_le, gbfputdbl, gbfputs, gbfile, gbfputflt, gbfread, gbfseek +#include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime @@ -433,7 +434,7 @@ class LowranceusrFormat : public Format gbfile* file_in{}; gbfile* file_out{}; - short_handle mkshort_handle{}; + MakeShort* mkshort_handle{}; route_head* trk_head{}; route_head* rte_head{}; diff --git a/main.cc b/main.cc index 3c20a5d7b..f99f47903 100644 --- a/main.cc +++ b/main.cc @@ -50,6 +50,7 @@ #include "gbversion.h" // for VERSION_SHA #include "inifile.h" // for inifile_done, inifile_init #include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index +#include "mkshort.h" // for MakeShort #include "session.h" // for start_session, session_exit, session_init #include "src/core/datetime.h" // for DateTime #include "src/core/file.h" // for File @@ -213,14 +214,6 @@ signal_handler(int sig) class FallbackOutput { public: - FallbackOutput() : mkshort_handle(mkshort_new_handle()) {} - // delete copy and move constructors and assignment operators. - // The defaults are not appropriate, and we haven't implemented proper ones. - FallbackOutput(const FallbackOutput&) = delete; - FallbackOutput& operator=(const FallbackOutput&) = delete; - FallbackOutput(FallbackOutput&&) = delete; - FallbackOutput& operator=(FallbackOutput&&) = delete; - ~FallbackOutput() {mkshort_del_handle(&mkshort_handle);} void waypt_disp(const Waypoint* wpt) { @@ -232,7 +225,7 @@ class FallbackOutput if (!wpt->description.isEmpty()) { printf("%s/%s", global_opts.synthesize_shortnames ? - qPrintable(mkshort(mkshort_handle, wpt->description)) : + qPrintable(mkshort_handle.mkshort(wpt->description)) : qPrintable(wpt->shortname), qPrintable(wpt->description)); } @@ -244,7 +237,7 @@ class FallbackOutput } private: - short_handle mkshort_handle; + MakeShort mkshort_handle; }; static void diff --git a/mkshort.cc b/mkshort.cc index 4ad3fc47f..8bf839b41 100644 --- a/mkshort.cc +++ b/mkshort.cc @@ -19,12 +19,13 @@ */ +#include "mkshort.h" + #include // for assert #include // for isspace, isdigit #include // for QByteArray #include // for QChar, QChar::ReplacementCharacter -#include // for QHash, QHash<>::iterator, qHash, QHash<>::size_type #include // for QString #include // for QVector #include // for CaseInsensitive @@ -34,52 +35,9 @@ #include "geocache.h" // for Geocache -#define MYNAME "mkshort" - -static const QByteArray vowels("aeiouAEIOU"); -static constexpr int default_target_len = 8; -static constexpr const char default_badchars[] = "\"$.,'!-"; - -class ShortNameKey; -using ShortNameHash = QHash; -class ShortNameKey -{ -public: - ShortNameKey(const QByteArray& name) : shortname(name) {} /* converting constructor */ - - friend qhash_result_t qHash(const ShortNameKey& key, qhash_result_t seed = 0) noexcept - { - // We hash all strings as upper case. - return qHash(key.shortname.toUpper(), seed); - } - - QByteArray shortname; -}; +const QByteArray MakeShort::vowels = "aeiouAEIOU"; -inline bool operator==(const ShortNameKey& lhs, const ShortNameKey& rhs) noexcept -{ - return lhs.shortname.compare(rhs.shortname, Qt::CaseInsensitive) == 0; -} - -struct mkshort_handle_imp { - int target_len{default_target_len}; - QByteArray badchars{default_badchars}; - QByteArray goodchars; - QByteArray defname{"WPT"}; - ShortNameHash namelist; - - /* Various internal flags */ - bool mustupper{false}; - bool whitespaceok{true}; - bool repeating_whitespaceok{false}; - bool must_uniq{true}; -}; - -struct replacement_t { - QByteArray orig; - QByteArray replacement; -}; -static const QVector replacements = { +const QVector MakeShort::replacements = { {"zero", "0"}, {"one", "1"}, {"two", "2"}, @@ -92,26 +50,18 @@ static const QVector replacements = { {"nine", "9"} }; -short_handle -mkshort_new_handle() +void MakeShort::mkshort_add_to_list(QByteArray& name, bool is_utf8) { - return new mkshort_handle_imp; -} - -static -void -mkshort_add_to_list(mkshort_handle_imp* h, QByteArray& name, bool is_utf8) -{ - while (h->namelist.contains(name)) { - auto& conflictctr = h->namelist[name]; + while (namelist_.contains(name)) { + auto& conflictctr = namelist_[name]; QByteArray suffix("."); suffix.append(QByteArray::number(++conflictctr)); int suffixcnt = suffix.size(); - if (name.size() + suffixcnt <= h->target_len) { + if (name.size() + suffixcnt <= target_len_) { name.append(suffix); - } else if (int keepcnt = h->target_len - suffixcnt; keepcnt >= 0) { + } else if (int keepcnt = target_len_ - suffixcnt; keepcnt >= 0) { if (is_utf8) { QString result = grapheme_truncate(QString::fromUtf8(name), keepcnt); name = result.toUtf8().append(suffix); @@ -124,42 +74,14 @@ mkshort_add_to_list(mkshort_handle_imp* h, QByteArray& name, bool is_utf8) } } - h->namelist.insert(name, 0); -} - -void -mkshort_del_handle(short_handle* h) -{ - if (!h) { - return; - } - - auto* hdr = (mkshort_handle_imp*) *h; - - if (!hdr) { - return; - } - -#if 0 - for (auto it = hdr->namelist.cbegin(), end = hdr->namelist.cend(); it != end; ++it) { - if (global_opts.verbose_status >= 2 && it.value()->conflictctr) { - fprintf(stderr, "%d Output name conflicts: '%s'\n", - it.value()->conflictctr, it.key().shortname.constData()); - } - } -#endif - - delete hdr; - *h = nullptr; + namelist_.insert(name, 0); } /* * This is the stuff that makes me ashamed to be a C programmer... */ -static -bool -delete_last_vowel(int start, QByteArray& iostring) +bool MakeShort::delete_last_vowel(int start, QByteArray& iostring) { /* * Basically implement strrchr. @@ -184,8 +106,7 @@ delete_last_vowel(int start, QByteArray& iostring) * Open the slippery slope of literal replacement. Right now, replacements * are made only at the end of the string. */ -void -replace_constants(QByteArray& s) +void MakeShort::replace_constants(QByteArray& s) { for (const auto& r : replacements) { /* @@ -202,59 +123,50 @@ replace_constants(QByteArray& s) } } - /* * Externally callable function to set the max length of the * strings returned by mkshort(). 0 resets to default. */ -void -setshort_length(short_handle h, int l) +void MakeShort::set_length(int l) { - auto* hdl = (mkshort_handle_imp*) h; if (l < 0) { fatal("mkshort: short length must be non-negative.\n"); } else if (l == 0) { - hdl->target_len = default_target_len; + target_len_ = default_target_len; } else { - hdl->target_len = l; + target_len_ = l; } } /* - * Call with L nonzero if whitespace in the generated shortname is wanted. + * Call with ok = true if whitespace in the generated shortname is wanted. */ -void -setshort_whitespace_ok(short_handle h, int l) +void MakeShort::set_whitespace_ok(bool ok) { - auto* hdl = (mkshort_handle_imp*) h; - hdl->whitespaceok = l; + whitespaceok_ = ok; } /* - * Call with L nonzero if multiple consecutive whitespace in the + * Call with ok = true if multiple consecutive whitespace in the * generated shortname is wanted. */ -void -setshort_repeating_whitespace_ok(short_handle h, int l) +void MakeShort::set_repeating_whitespace_ok(bool ok) { - auto* hdl = (mkshort_handle_imp*) h; - hdl->repeating_whitespaceok = l; + repeating_whitespaceok_ = ok; } /* * Set default name given to a waypoint if no valid is possible * because it was filtered by charsets or null or whatever. */ -void -setshort_defname(short_handle h, const char* s) +void MakeShort::set_defname(const char* s) { - auto* hdl = (mkshort_handle_imp*) h; if (s == nullptr) { - fatal("setshort_defname called without a valid name."); + fatal("set_defname called without a valid name."); } - hdl->defname = s; + defname_ = s; } /* @@ -262,57 +174,45 @@ setshort_defname(short_handle h, const char* s) * that must never appear in a string returned by mkshort. NULL * resets to default. */ -void -setshort_badchars(short_handle h, const char* s) +void MakeShort::set_badchars(const char* s) { - auto* hdl = (mkshort_handle_imp*) h; - - hdl->badchars = s ? s : default_badchars; + badchars_ = (s == nullptr)? default_badchars : s; } /* * Only characters that appear in *s are "whitelisted" to appear * in generated names. */ -void -setshort_goodchars(short_handle h, const char* s) +void MakeShort::set_goodchars(const char* s) { - auto* hdl = (mkshort_handle_imp*) h; - - if (s != nullptr) { - hdl->goodchars = s; + if (s == nullptr) { + goodchars_.clear(); } else { - hdl->goodchars.clear(); + goodchars_ = s; } } /* - * Call with i non-zero if generated names must be uppercase only. + * Call with must = true if generated names must be uppercase only. */ -void -setshort_mustupper(short_handle h, int i) +void MakeShort::set_mustupper(bool must) { - auto* hdl = (mkshort_handle_imp*) h; - hdl->mustupper = i; + mustupper_ = must; } /* - * Call with i zero if the generated names don't have to be unique. + * Call with must = false if the generated names don't have to be unique. * (By default, they are.) */ -void -setshort_mustuniq(short_handle h, int i) +void MakeShort::set_mustuniq(bool must) { - auto* hdl = (mkshort_handle_imp*) h; - hdl->must_uniq = i; + must_uniq_ = must; } -QByteArray -mkshort(short_handle h, const QByteArray& istring, bool is_utf8) +QByteArray MakeShort::mkshort(const QByteArray& istring, bool is_utf8) { QByteArray ostring; - auto* hdl = (mkshort_handle_imp*) h; if (is_utf8) { /* clean UTF-8 string */ @@ -332,7 +232,7 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) * the new seven digit geocache numbers and special case whacking * the 'G' off the front. */ - if ((hdl->target_len == 6) && (ostring.size() == 7) && + if ((target_len_ == 6) && (ostring.size() == 7) && ostring.startsWith("GC")) { ostring.remove(0, 1); } @@ -340,7 +240,7 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) /* * Whack leading "[Tt]he " */ - if ((ostring.size() > (hdl->target_len + 4)) && + if ((ostring.size() > (target_len_ + 4)) && (ostring.startsWith("The ") || ostring.startsWith("the "))) { ostring.remove(0, 4); } @@ -348,7 +248,7 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) /* In all cases eliminate leading and trailing whitespace */ ostring = ostring.trimmed(); - if (!hdl->whitespaceok) { + if (!whitespaceok_) { /* * Eliminate Whitespace */ @@ -361,7 +261,7 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) } } - if (hdl->mustupper) { + if (mustupper_) { ostring = ostring.toUpper(); } @@ -378,10 +278,10 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) QByteArray tstring; ostring.swap(tstring); for (const auto ch : qAsConst(tstring)) { - if (hdl->badchars.contains(ch)) { + if (badchars_.contains(ch)) { continue; } - if (!hdl->goodchars.isEmpty() && (!hdl->goodchars.contains(ch))) { + if (!goodchars_.isEmpty() && (!goodchars_.contains(ch))) { continue; } ostring.append(ch); @@ -395,7 +295,7 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) * operations that removed character(s) before and/or after whitespace. * Conditionally simplify embedded whitespace. */ - ostring = hdl->repeating_whitespaceok? ostring.trimmed() : ostring.simplified(); + ostring = repeating_whitespaceok_? ostring.trimmed() : ostring.simplified(); /* * Toss vowels to approach target length, but don't toss them @@ -414,9 +314,9 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) * * It also helps units with speech synthesis. */ - bool replaced = hdl->target_len < 15; + bool replaced = target_len_ < 15; - while (replaced && (ostring.size() > hdl->target_len)) { + while (replaced && (ostring.size() > target_len_)) { replaced = delete_last_vowel(2, ostring); } @@ -433,18 +333,18 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) * If the numeric component alone is longer than our target string * length, use the trailing part of the the numeric component. */ - if (int delcnt = ostring.size() - hdl->target_len; delcnt > 0) { + if (int delcnt = ostring.size() - target_len_; delcnt > 0) { int suffixcnt = 0; for (auto it = ostring.crbegin(); it != ostring.crend(); ++it) { if (isdigit(*it)) { ++suffixcnt; } - if (suffixcnt == hdl->target_len) { + if (suffixcnt == target_len_) { break; } } - int keepcnt = hdl->target_len - suffixcnt; + int keepcnt = target_len_ - suffixcnt; assert(keepcnt >= 0); if (is_utf8) { @@ -463,27 +363,25 @@ mkshort(short_handle h, const QByteArray& istring, bool is_utf8) * let the must_uniq code handle it. */ if (ostring.isEmpty()) { - ostring = hdl->defname; + ostring = defname_; } - if (hdl->must_uniq) { - mkshort_add_to_list(hdl, ostring, is_utf8); + if (must_uniq_) { + mkshort_add_to_list(ostring, is_utf8); } return ostring; } -QString -mkshort(short_handle h, const QString& istring) +QString MakeShort::mkshort(const QString& istring) { - return mkshort(h, istring.toUtf8(), true); + return mkshort(istring.toUtf8(), true); } /* * As above, but arg list is a waypoint so we can centralize * the code that considers the alternate sources. */ -QString -mkshort_from_wpt(short_handle h, const Waypoint* wpt) +QString MakeShort::mkshort_from_wpt(const Waypoint* wpt) { /* This probably came from a Groundspeak Pocket Query * so use the 'cache name' instead of the description field @@ -492,20 +390,20 @@ mkshort_from_wpt(short_handle h, const Waypoint* wpt) */ if (wpt->gc_data->diff && wpt->gc_data->terr && !wpt->notes.isEmpty()) { - return mkshort(h, wpt->notes); + return mkshort(wpt->notes); } if (!wpt->description.isEmpty()) { - return mkshort(h, wpt->description); + return mkshort(wpt->description); } if (!wpt->notes.isEmpty()) { - return mkshort(h, wpt->notes); + return mkshort(wpt->notes); } /* Should probably never actually happen... */ /* O.K.: But this can happen (waypoints transformed from trackpoints )! */ /* Now we return every time a valid entity." */ - return mkshort(h, wpt->shortname); + return mkshort(wpt->shortname); } diff --git a/mkshort.h b/mkshort.h new file mode 100644 index 000000000..a672a0d48 --- /dev/null +++ b/mkshort.h @@ -0,0 +1,109 @@ +/* + Generate unique short names. + + Copyright (C) 2003-2006, 2023 Robert Lipe, robertlipe+source@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ + +#ifndef MKSHORT_H_INCLUDED_ +#define MKSHORT_H_INCLUDED_ + +#include // for QByteArray +#include // for QHash, QHash<>::iterator, qHash, QHash<>::size_type +#include // for QString +#include // for QVector +#include // for CaseInsensitive + +#include "defs.h" + + +class MakeShort +{ +public: + + /* Member Functions */ + + void set_length(int l); + void set_whitespace_ok(bool ok); + void set_repeating_whitespace_ok(bool ok); + void set_defname(const char* s); + void set_badchars(const char* s); + void set_goodchars(const char* s); + void set_mustupper(bool must); + void set_mustuniq(bool must); + QByteArray mkshort(const QByteArray& istring, bool is_utf8); + QString mkshort(const QString& istring); + QString mkshort_from_wpt(const Waypoint* wpt); + +private: + + /* Types */ + + class ShortNameKey; + using ShortNameHash = QHash; + class ShortNameKey + { + public: + ShortNameKey(const QByteArray& name) : shortname(name) {} /* converting constructor */ + + friend qhash_result_t qHash(const ShortNameKey& key, qhash_result_t seed = 0) noexcept + { + // We hash all strings as upper case. + return qHash(key.shortname.toUpper(), seed); + } + bool operator==(const ShortNameKey& other) const + { + return shortname.compare(other.shortname, Qt::CaseInsensitive) == 0; + } + + private: + QByteArray shortname; + }; + + struct replacement_t { + QByteArray orig; + QByteArray replacement; + }; + + /* Constants */ + + static const QByteArray vowels; + static constexpr int default_target_len = 8; + static constexpr const char default_badchars[] = "\"$.,'!-"; + static const QVector replacements; + + /* Member Functions */ + + void mkshort_add_to_list(QByteArray& name, bool is_utf8); + static bool delete_last_vowel(int start, QByteArray& iostring); + static void replace_constants(QByteArray& s); + + /* Data Members */ + + int target_len_{default_target_len}; + QByteArray badchars_{default_badchars}; + QByteArray goodchars_; + QByteArray defname_{"WPT"}; + ShortNameHash namelist_; + + /* Various internal flags */ + bool mustupper_{false}; + bool whitespaceok_{true}; + bool repeating_whitespaceok_{false}; + bool must_uniq_{true}; +}; +#endif // MKSHORT_H_INCLUDED_ diff --git a/nmea.cc b/nmea.cc index 442d5857a..84129cd0a 100644 --- a/nmea.cc +++ b/nmea.cc @@ -45,6 +45,7 @@ #include "gbfile.h" // for gbfprintf, gbfflush, gbfclose, gbfopen, gbfgetstr, gbfile #include "gbser.h" // for gbser_set_speed, gbser_flush, gbser_read_line, gbser_deinit, gbser_init, gbser_write #include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M +#include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime #include "src/core/logging.h" // for Warning @@ -299,8 +300,8 @@ NmeaFormat::wr_init(const QString& fname) } } - mkshort_handle = mkshort_new_handle(); - setshort_length(mkshort_handle, xstrtoi(snlenopt, nullptr, 10)); + mkshort_handle = new MakeShort; + mkshort_handle->set_length(xstrtoi(snlenopt, nullptr, 10)); if (opt_gisteq) { opt_gpgga = nullptr; @@ -313,7 +314,8 @@ void NmeaFormat::wr_deinit() { gbfclose(file_out); - mkshort_del_handle(&mkshort_handle); + delete mkshort_handle; + mkshort_handle = nullptr; } void @@ -1164,9 +1166,9 @@ NmeaFormat::nmea_wayptpr(const Waypoint* wpt) const double lat = degrees2ddmm(wpt->latitude); double lon = degrees2ddmm(wpt->longitude); if (global_opts.synthesize_shortnames) { - s = mkshort_from_wpt(mkshort_handle, wpt); + s = mkshort_handle->mkshort_from_wpt(wpt); } else { - s = mkshort(mkshort_handle, wpt->shortname); + s = mkshort_handle->mkshort(wpt->shortname); } snprintf(obuf, sizeof(obuf), "GPWPL,%08.3f,%c,%09.3f,%c,%s", diff --git a/nmea.h b/nmea.h index d612abdbb..e265f051b 100644 --- a/nmea.h +++ b/nmea.h @@ -33,6 +33,7 @@ #include "defs.h" #include "format.h" // for Format #include "gbfile.h" // for gbfile +#include "mkshort.h" // for MakeShort class NmeaFormat : public Format @@ -121,7 +122,7 @@ class NmeaFormat : public Format gbfile* file_in{}, *file_out{}; route_head* trk_head{}; - short_handle mkshort_handle{}; + MakeShort* mkshort_handle{}; preferred_posn_type posn_type{}; read_mode_type read_mode{}; QDateTime prev_datetime; diff --git a/ozi.cc b/ozi.cc index 14473ac8a..74e33262a 100644 --- a/ozi.cc +++ b/ozi.cc @@ -55,6 +55,7 @@ #include "csv_util.h" // for csv_stringclean #include "formspec.h" // for FsChainAdd, FsChainFind, kFsOzi, FormatSpecificData #include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_WGS84_M +#include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime #include "src/core/textstream.h" // for TextStream @@ -77,7 +78,7 @@ struct ozi_fsdata : FormatSpecificData { static gpsbabel::TextStream* stream = nullptr; -static short_handle mkshort_handle; +static MakeShort* mkshort_handle; static route_head* trk_head; static route_head* rte_head; @@ -437,7 +438,6 @@ rd_init(const QString& fname) { ozi_open_io(fname, QFile::ReadOnly); - mkshort_handle = mkshort_new_handle(); ozi_init_units(0); } @@ -445,8 +445,6 @@ static void rd_deinit() { ozi_close_io(); - - mkshort_del_handle(&mkshort_handle); } static void @@ -460,26 +458,26 @@ wr_init(const QString& fname) ozi_ofname = fname; - mkshort_handle = mkshort_new_handle(); + mkshort_handle = new MakeShort; /* set mkshort options from the command line if applicable */ if (global_opts.synthesize_shortnames) { - setshort_length(mkshort_handle, xstrtoi(snlenopt, nullptr, 10)); + mkshort_handle->set_length(xstrtoi(snlenopt, nullptr, 10)); if (snwhiteopt) { - setshort_whitespace_ok(mkshort_handle, xstrtoi(snwhiteopt, nullptr, 10)); + mkshort_handle->set_whitespace_ok(xstrtoi(snwhiteopt, nullptr, 10)); } if (snupperopt) { - setshort_mustupper(mkshort_handle, xstrtoi(snupperopt, nullptr, 10)); + mkshort_handle->set_mustupper(xstrtoi(snupperopt, nullptr, 10)); } if (snuniqueopt) { - setshort_mustuniq(mkshort_handle, xstrtoi(snuniqueopt, nullptr, 10)); + mkshort_handle->set_mustuniq(xstrtoi(snuniqueopt, nullptr, 10)); } - setshort_badchars(mkshort_handle, "\","); + mkshort_handle->set_badchars("\","); } ozi_init_units(1); @@ -492,7 +490,8 @@ wr_deinit() ozi_close_io(); ozi_ofname.clear(); - mkshort_del_handle(&mkshort_handle); + delete mkshort_handle; + mkshort_handle = nullptr; } static void @@ -881,7 +880,7 @@ ozi_waypt_pr(const Waypoint* wpt) if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) { if (!wpt->description.isEmpty()) { if (global_opts.synthesize_shortnames) { - shortname = mkshort_from_wpt(mkshort_handle, wpt); + shortname = mkshort_handle->mkshort_from_wpt(wpt); } else { shortname = csv_stringclean(wpt->description, BADCHARS); } diff --git a/text.cc b/text.cc index b582abf5e..e4ed37892 100644 --- a/text.cc +++ b/text.cc @@ -48,7 +48,7 @@ TextFormat::wr_init(const QString& fname) file_out = new gpsbabel::TextStream; file_out->open(fname, QIODevice::WriteOnly, MYNAME); } - mkshort_handle = mkshort_new_handle(); + mkshort_handle = new MakeShort; } void @@ -59,7 +59,8 @@ TextFormat::wr_deinit() delete file_out; file_out = nullptr; } - mkshort_del_handle(&mkshort_handle); + delete mkshort_handle; + mkshort_handle = nullptr; output_name.clear(); } @@ -90,7 +91,7 @@ TextFormat::text_disp(const Waypoint* wpt) if (wpt->altitude != unknown_alt) { position += QStringLiteral(" alt:%1").arg((int)((altunits[0]=='f') ? METERS_TO_FEET(wpt->altitude) : wpt->altitude)); } - QString sn = global_opts.synthesize_shortnames ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname; + QString sn = global_opts.synthesize_shortnames ? mkshort_handle->mkshort_from_wpt(wpt) : wpt->shortname; *file_out << sn.leftJustified(16) << " " << position.rightJustified(59) << "\n"; if (wpt->description != wpt->shortname) { @@ -196,7 +197,7 @@ TextFormat::write() if (!suppresssep && !split_output) { *file_out << "-----------------------------------------------------------------------------\n"; } - setshort_length(mkshort_handle, 6); + mkshort_handle->set_length(6); auto text_disp_lambda = [this](const Waypoint* waypointp)->void { text_disp(waypointp); }; diff --git a/text.h b/text.h index 3305a92b0..37ad2b97d 100644 --- a/text.h +++ b/text.h @@ -26,6 +26,7 @@ #include "defs.h" #include "format.h" // for Format +#include "mkshort.h" // for MakeShort #include "src/core/textstream.h" // for TextStream @@ -60,7 +61,7 @@ class TextFormat : public Format /* Data Members */ gpsbabel::TextStream* file_out{nullptr}; - short_handle mkshort_handle{}; + MakeShort* mkshort_handle{}; char* suppresssep = nullptr; char* txt_encrypt = nullptr; diff --git a/tpg.cc b/tpg.cc index 4e1e337ba..615a08de2 100644 --- a/tpg.cc +++ b/tpg.cc @@ -32,6 +32,7 @@ #include "defs.h" #include "gbfile.h" // for gbfwrite, gbfgetint16, gbfputint16, gbfclose #include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index, GPS_Math_Known_Da... +#include "mkshort.h" // for MakeShort #define MYNAME "TPG" @@ -41,7 +42,7 @@ static gbfile* tpg_file_in; static gbfile* tpg_file_out; -static short_handle mkshort_handle; +static MakeShort* mkshort_handle; static char* tpg_datum_opt; static int tpg_datum_idx; @@ -94,14 +95,14 @@ tpg_wr_init(const QString& fname) { tpg_common_init(); tpg_file_out = gbfopen_le(fname, "wb", MYNAME); - mkshort_handle = mkshort_new_handle(); + mkshort_handle = new MakeShort; waypt_out_count = 0; } static void tpg_wr_deinit() { - mkshort_del_handle(&mkshort_handle); + delete mkshort_handle; gbfclose(tpg_file_out); } @@ -188,7 +189,7 @@ tpg_waypt_pr(const Waypoint* wpt) if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) { if (!wpt->description.isEmpty()) { if (global_opts.synthesize_shortnames) { - shortname = mkshort_from_wpt(mkshort_handle, wpt); + shortname = mkshort_handle->mkshort_from_wpt(wpt); } else { shortname = wpt->description; } @@ -291,9 +292,9 @@ tpg_write() int s = waypt_count(); if (global_opts.synthesize_shortnames) { - setshort_length(mkshort_handle, 32); - setshort_whitespace_ok(mkshort_handle, 1); - setshort_mustupper(mkshort_handle, 1); + mkshort_handle->set_length(32); + mkshort_handle->set_whitespace_ok(true); + mkshort_handle->set_mustupper(true); } if (s > MAXTPGOUTPUTPINS) { diff --git a/vcf.cc b/vcf.cc index ee48acbdf..fd3e90844 100644 --- a/vcf.cc +++ b/vcf.cc @@ -31,7 +31,6 @@ static gbfile* file_out; -static short_handle mkshort_handle; static char* vcf_encrypt = nullptr; @@ -49,14 +48,12 @@ static void wr_init(const QString& fname) { file_out = gbfopen(fname, "w", MYNAME); - mkshort_handle = mkshort_new_handle(); } static void wr_deinit() { gbfclose(file_out); - mkshort_del_handle(&mkshort_handle); } /* @@ -132,7 +129,6 @@ vcf_disp(const Waypoint* wpt) static void data_write() { - setshort_length(mkshort_handle, 6); waypt_disp_all(vcf_disp); } diff --git a/xcsv.cc b/xcsv.cc index fa7e6dbdc..2794c0f7d 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -1013,7 +1013,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) if (wpt->shortname.isEmpty() || global_opts.synthesize_shortnames) { if (!wpt->description.isEmpty()) { if (global_opts.synthesize_shortnames) { - shortname = mkshort_from_wpt(xcsv_file->mkshort_handle, wpt); + shortname = xcsv_file->mkshort_handle.mkshort_from_wpt(wpt); } else { shortname = csv_stringclean(wpt->description, xcsv_style->badchars); } @@ -1091,10 +1091,10 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) case XcsvStyle::XT_ANYNAME: { QString anyname = wpt->shortname; if (anyname.isEmpty()) { - anyname = mkshort(xcsv_file->mkshort_handle, wpt->description); + anyname = xcsv_file->mkshort_handle.mkshort(wpt->description); } if (anyname.isEmpty()) { - anyname = mkshort(xcsv_file->mkshort_handle, wpt->description); + anyname = xcsv_file->mkshort_handle.mkshort(wpt->description); } if (anyname.isEmpty()) { anyname = wpt->notes; @@ -1954,32 +1954,32 @@ XcsvFormat::wr_init(const QString& fname) xcsv_file->fname = fname; if (xcsv_style->shortlen) { - setshort_length(xcsv_file->mkshort_handle, *xcsv_style->shortlen); + xcsv_file->mkshort_handle.set_length(*xcsv_style->shortlen); } if (xcsv_style->whitespace_ok) { - setshort_whitespace_ok(xcsv_file->mkshort_handle, *xcsv_style->whitespace_ok); + xcsv_file->mkshort_handle.set_whitespace_ok(*xcsv_style->whitespace_ok); } /* set mkshort options from the command line */ if (global_opts.synthesize_shortnames) { if (snlenopt) { - setshort_length(xcsv_file->mkshort_handle, xstrtoi(snlenopt, nullptr, 10)); + xcsv_file->mkshort_handle.set_length(xstrtoi(snlenopt, nullptr, 10)); } if (snwhiteopt) { - setshort_whitespace_ok(xcsv_file->mkshort_handle, xstrtoi(snwhiteopt, nullptr, 10)); + xcsv_file->mkshort_handle.set_whitespace_ok(xstrtoi(snwhiteopt, nullptr, 10)); } if (snupperopt) { - setshort_mustupper(xcsv_file->mkshort_handle, xstrtoi(snupperopt, nullptr, 10)); + xcsv_file->mkshort_handle.set_mustupper(xstrtoi(snupperopt, nullptr, 10)); } if (snuniqueopt) { - setshort_mustuniq(xcsv_file->mkshort_handle, xstrtoi(snuniqueopt, nullptr, 10)); + xcsv_file->mkshort_handle.set_mustuniq(xstrtoi(snuniqueopt, nullptr, 10)); } - setshort_badchars(xcsv_file->mkshort_handle, CSTR(xcsv_style->badchars)); + xcsv_file->mkshort_handle.set_badchars(CSTR(xcsv_style->badchars)); } diff --git a/xcsv.h b/xcsv.h index 0cbfd1345..3a586c0c5 100644 --- a/xcsv.h +++ b/xcsv.h @@ -37,8 +37,9 @@ #include // for qRound64 #include "defs.h" -#include "format.h" -#include "garmin_fs.h" +#include "format.h" // for Format +#include "garmin_fs.h" // for garmin_fs_t +#include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime #include "src/core/textstream.h" // for TextStream @@ -239,7 +240,7 @@ class XcsvStyle std::optional shortlen; /* SHORTWHITE from style file */ - std::optional whitespace_ok; + std::optional whitespace_ok; private: /* Types */ @@ -298,28 +299,13 @@ class XcsvFormat : public Format class XcsvFile { public: - /* Special Member Functions */ - - XcsvFile() : mkshort_handle(mkshort_new_handle()) {} - // delete copy and move constructors and assignment operators. - // The defaults are not appropriate, and we haven't implemented proper ones. - XcsvFile(const XcsvFile&) = delete; - XcsvFile& operator=(const XcsvFile&) = delete; - XcsvFile(XcsvFile&&) = delete; - XcsvFile& operator=(XcsvFile&&) = delete; - ~XcsvFile() - { - if (mkshort_handle != nullptr) { - mkshort_del_handle(&mkshort_handle); - } - } /* Data Members */ gpsbabel::TextStream stream; QString fname; int gps_datum_idx{-1}; /* result of GPS_Lookup_Datum_Index */ - short_handle mkshort_handle{nullptr}; + MakeShort mkshort_handle; }; struct xcsv_parse_data { From d2ead0485361a60ce00f7df0def4ca9f9a2f88b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Sep 2023 08:13:05 -0600 Subject: [PATCH 004/132] Bump actions/checkout from 3 to 4 (#1172) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: tsteven4 <13596209+tsteven4@users.noreply.github.com> --- .github/workflows/codacy-analysis.yaml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/fedora.yml | 2 +- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 6 +++--- .github/workflows/windows.yml | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/codacy-analysis.yaml b/.github/workflows/codacy-analysis.yaml index 8ae2c2b20..acd19a832 100644 --- a/.github/workflows/codacy-analysis.yaml +++ b/.github/workflows/codacy-analysis.yaml @@ -29,7 +29,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: build_and_test run: | diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 079144551..98482780a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index 643d0c2c5..6c7388528 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: build_and_test run: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 300948e4f..353a38760 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -41,7 +41,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache Qt uses: actions/cache@v3 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index e5754277b..2cf8d4331 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: build_and_test run: | @@ -71,7 +71,7 @@ jobs: sudo apt-get install gcovr lcov libusb-1.0-0-dev qt5-default qtwebengine5-dev libqt5serialport5-dev ninja-build - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: script env: @@ -86,7 +86,7 @@ jobs: snap-file: ${{ steps.build-snap.outputs.snap }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build uses: snapcore/action-build@v1 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ee1452cf9..0a086dc5a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -71,7 +71,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache Qt uses: actions/cache@v3 From cd3cd130541f7a72706120511156c6a61e3bbcc8 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 8 Sep 2023 06:34:56 -0600 Subject: [PATCH 005/132] make all but the stack filter dynamic. (#1174) --- filter_vecs.cc | 72 ++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/filter_vecs.cc b/filter_vecs.cc index 6e0f23d67..ccb2e1a6b 100644 --- a/filter_vecs.cc +++ b/filter_vecs.cc @@ -65,47 +65,39 @@ Filter* fltfactory() } struct FilterVecs::Impl { - ArcDistanceFilter arcdist; - BendFilter bend; - DiscardFilter discard; - DuplicateFilter duplicate; - HeightFilter height; - InterpolateFilter interpolate; - PolygonFilter polygon; - PositionFilter position; - RadiusFilter radius; - ReverseRouteFilter reverse_route; - SimplifyRouteFilter routesimple; StackFilter stackfilt; - SwapDataFilter swapdata; - TrackFilter trackfilter; const QVector filter_vec_list = { #if FILTERS_ENABLED { - &arcdist, + nullptr, "arc", "Include Only Points Within Distance of Arc", + &fltfactory }, { - &bend, + nullptr, "bend", - "Add points before and after bends in routes" + "Add points before and after bends in routes", + &fltfactory }, { - &discard, + nullptr, "discard", - "Remove unreliable points with high hdop or vdop" + "Remove unreliable points with high hdop or vdop", + &fltfactory }, { - &duplicate, + nullptr, "duplicate", "Remove Duplicates", + &fltfactory }, { - &interpolate, + nullptr, "interpolate", - "Interpolate between trackpoints" + "Interpolate between trackpoints", + &fltfactory }, { nullptr, @@ -114,19 +106,22 @@ struct FilterVecs::Impl { &fltfactory }, { - &polygon, + nullptr, "polygon", "Include Only Points Inside Polygon", + &fltfactory }, { - &position, + nullptr, "position", "Remove Points Within Distance", + &fltfactory }, { - &radius, + nullptr, "radius", "Include Only Points Within Radius", + &fltfactory }, { nullptr, @@ -135,9 +130,10 @@ struct FilterVecs::Impl { &fltfactory }, { - &routesimple, + nullptr, "simplify", "Simplify routes", + &fltfactory }, { nullptr, @@ -148,17 +144,20 @@ struct FilterVecs::Impl { { &stackfilt, "stack", - "Save and restore waypoint lists" + "Save and restore waypoint lists", + nullptr }, { - &reverse_route, + nullptr, "reverse", "Reverse stops within routes", + &fltfactory }, { - &trackfilter, + nullptr, "track", - "Manipulate track lists" + "Manipulate track lists", + &fltfactory }, { nullptr, @@ -167,14 +166,16 @@ struct FilterVecs::Impl { &fltfactory }, { - &height, + nullptr, "height", - "Manipulate altitudes" + "Manipulate altitudes", + &fltfactory }, { - &swapdata, + nullptr, "swap", - "Swap latitude and longitude of all loaded points" + "Swap latitude and longitude of all loaded points", + &fltfactory }, { nullptr, @@ -184,9 +185,10 @@ struct FilterVecs::Impl { } #elif defined (MINIMAL_FILTERS) { - &trackfilter, + nullptr, "track", - "Manipulate track lists" + "Manipulate track lists", + &fltfactory } #endif }; From 8c50bb1bdbf3f2755366c825d540b4671c074e8f Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 8 Sep 2023 17:06:32 -0600 Subject: [PATCH 006/132] Apply new resharper refactoring "Redundant dereferencing and taking address" --- geojson.cc | 2 +- googletakeout.cc | 6 +++--- jeeps/gpsread.cc | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/geojson.cc b/geojson.cc index 1c914dcdf..6c5e60c51 100644 --- a/geojson.cc +++ b/geojson.cc @@ -249,7 +249,7 @@ void GeoJsonFormat::geojson_track_disp(const Waypoint* trackpoint) const if (trackpoint->altitude != unknown_alt && trackpoint->altitude != 0) { coords.append(trackpoint->altitude); } - (*track_coords).append(coords); + track_coords->append(coords); } void GeoJsonFormat::geojson_track_tlr(const route_head* /*unused*/) diff --git a/googletakeout.cc b/googletakeout.cc index a962aa49c..d4b82f882 100644 --- a/googletakeout.cc +++ b/googletakeout.cc @@ -68,13 +68,13 @@ static Waypoint* takeout_waypoint( Waypoint* waypoint = new Waypoint(); waypoint->latitude = lat_e7 / 1e7; waypoint->longitude = lon_e7 / 1e7; - if (shortname && (*shortname).length() > 0) { + if (shortname && shortname->length() > 0) { waypoint->shortname = *shortname; } - if (description && (*description).length() > 0) { + if (description && description->length() > 0) { waypoint->description = *description; } - if (start_str && (*start_str).length() > 0) { + if (start_str && start_str->length() > 0) { gpsbabel::DateTime start = QDateTime::fromString(*start_str, Qt::ISODate); waypoint->SetCreationTime(start); } diff --git a/jeeps/gpsread.cc b/jeeps/gpsread.cc index 7dbeb76ec..512c647af 100644 --- a/jeeps/gpsread.cc +++ b/jeeps/gpsread.cc @@ -79,7 +79,7 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) const char* m1; const char* m2; bool isDLE = false; - p = (*packet).data; + p = packet->data; start = GPS_Time_Now(); GPS_Diag("Rx Data:"); @@ -105,7 +105,7 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) } if (len == 1) { - (*packet).type = u; + packet->type = u; ++len; continue; } @@ -119,14 +119,14 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) } if (len == 2) { - (*packet).n = u; + packet->n = u; len = -1; continue; } if (u == ETX) if (isDLE) { - if (p - (*packet).data - 2 != (*packet).n) { + if (p - packet->data - 2 != packet->n) { GPS_Error("GPS_Packet_Read: Bad count"); gps_errno = FRAMING_ERROR; return 0; @@ -134,7 +134,7 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) chk_read = *(p - 2); unsigned int i; - for (i = 0, p = (*packet).data; i < (*packet).n; ++i) { + for (i = 0, p = packet->data; i < packet->n; ++i) { chk -= *p++; } chk -= packet->type; @@ -145,17 +145,17 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) return 0; } - m1 = Get_Pkt_Type((*packet).type, (*packet).data[0], &m2); + m1 = Get_Pkt_Type(packet->type, packet->data[0], &m2); if (gps_show_bytes) { GPS_Diag(" "); for (unsigned j = 0; j < packet->n; j++) { - char c = (*packet).data[j]; + char c = packet->data[j]; GPS_Diag("%c", isascii(c) && isalnum(c) ? c : '.'); } GPS_Diag(" "); } GPS_Diag("(%-8s%s)\n", m1, m2 ? m2 : ""); - return (*packet).n; + return packet->n; } if (p - packet->data >= MAX_GPS_PACKET_SIZE) { @@ -193,12 +193,12 @@ bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_PPacket *tra, GPS_PPacket *rec) return false; } - if (LINK_ID[0].Pid_Ack_Byte != (*rec).type) { + if (LINK_ID[0].Pid_Ack_Byte != rec->type) { gps_error = FRAMING_ERROR; /* rjl return 0; */ } - if (*(*rec).data != (*tra).type) { + if (*rec->data != tra->type) { gps_error = FRAMING_ERROR; return false; } From ce31fa84792faf047a628ae97b2c7aacd6ef0652 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 8 Sep 2023 18:18:16 -0600 Subject: [PATCH 007/132] remove obsolete declarations --- xcsv.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/xcsv.h b/xcsv.h index 3a586c0c5..838c60c07 100644 --- a/xcsv.h +++ b/xcsv.h @@ -352,11 +352,8 @@ class XcsvFormat : public Format static QDate yyyymmdd_to_time(const QString& s); QDateTime xcsv_adjust_time(const QDate date, const QTime time, bool is_localtime) const; static void sscanftime(const char* s, const char* format, QDate& date, QTime& time); - static QTime addhms(const char* s, const char* format); static QString writetime(const char* format, time_t t, bool gmt); static QString writetime(const char* format, const gpsbabel::DateTime& t, bool gmt); - static QString writehms(const char* format, time_t t, bool gmt); - static QString writehms(const char* format, const gpsbabel::DateTime& t, bool gmt); static long int time_to_yyyymmdd(const QDateTime& t); static garmin_fs_t* gmsd_init(Waypoint* wpt); static void xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle::field_map& fmp, xcsv_parse_data* parse_data, int line_no); From 056749a1c2e1d931e4964d8e383d9ea6a7ff3660 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 9 Sep 2023 06:59:44 -0600 Subject: [PATCH 008/132] don't use posix but non-iso argument reordering in print specifiers. --- garmin_gpi.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/garmin_gpi.cc b/garmin_gpi.cc index 793c3c117..340c823be 100644 --- a/garmin_gpi.cc +++ b/garmin_gpi.cc @@ -235,7 +235,7 @@ GarminGPIFormat::read_poi(const int sz, const int tag) len = gbfgetint32(fin); /* sub-header size */ } if (GPI_DBG) { - warning("poi sublen = %1$d (0x%1$x)\n", len); + warning("poi sublen = %d (0x%x)\n", len, len); } (void) len; int pos = gbftell(fin); @@ -279,12 +279,12 @@ GarminGPIFormat::read_poi_list(const int sz) int pos = gbftell(fin); if (GPI_DBG) { PP; - warning("> reading poi list (-> %1$x / %1$d )\n", pos + sz); + warning("> reading poi list (-> %x / %d )\n", pos + sz, pos + sz); } PP; int i = gbfgetint32(fin); /* mostly 23 (0x17) */ if (GPI_DBG) { - warning("list sublen = %1$d (0x%1$x)\n", i); + warning("list sublen = %d (0x%x)\n", i, i); } (void) i; @@ -317,7 +317,7 @@ GarminGPIFormat::read_poi_group(const int sz, const int tag) int pos = gbftell(fin); if (GPI_DBG) { PP; - warning("> reading poi group (-> %1$x / %1$d)\n", pos + sz); + warning("> reading poi group (-> %x / %d)\n", pos + sz, pos + sz); } if (tag == 0x80009) { PP; From 0f58b6636e777197dc5f52e95ef77cfa8f0d094f Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 9 Sep 2023 07:12:34 -0600 Subject: [PATCH 009/132] drop extra semicolons --- duplicate.cc | 2 +- googletakeout.h | 2 +- mtk_logger.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/duplicate.cc b/duplicate.cc index 4739ae450..e79c1b4e9 100644 --- a/duplicate.cc +++ b/duplicate.cc @@ -118,7 +118,7 @@ void DuplicateFilter::process() for (auto it = values.cbegin(); it != values.cend(); ++it) { Waypoint* wpt = *it; if (purge_duplicates || (wpt != wptfirst)) { - wpt->wpt_flags.marked_for_deletion = 1;; + wpt->wpt_flags.marked_for_deletion = 1; } } } diff --git a/googletakeout.h b/googletakeout.h index ea549f6f5..51b9222f1 100644 --- a/googletakeout.h +++ b/googletakeout.h @@ -43,7 +43,7 @@ class GoogleTakeoutInputStream public: /* Special Member Functions */ GoogleTakeoutInputStream() = default; - GoogleTakeoutInputStream(const QString& source) : sources({source}) {}; + GoogleTakeoutInputStream(const QString& source) : sources({source}) {} /* Member Functions */ diff --git a/mtk_logger.cc b/mtk_logger.cc index d0a15a102..c67605a79 100644 --- a/mtk_logger.cc +++ b/mtk_logger.cc @@ -1027,7 +1027,7 @@ static int csv_line(gbfile* csvFile, int idx, unsigned long bmask, struct data_i QDateTime dt = QDateTime::fromSecsSinceEpoch(itm->timestamp, Qt::UTC); dt = dt.addMSecs(itm->timestamp_ms); - QString timestamp = dt.toUTC().toString("yyyy/MM/dd,hh:mm:ss.zzz");; + QString timestamp = dt.toUTC().toString("yyyy/MM/dd,hh:mm:ss.zzz"); gbfputs(timestamp, csvFile); gbfputc(',', csvFile); } From c77cce304cf14254aeb77218c3c1e306380ec4eb Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 9 Sep 2023 07:32:31 -0600 Subject: [PATCH 010/132] use noreturn attribute --- jeeps/gpsutil.h | 2 +- jeeps/jgpsutil.cc | 2 +- shape.cc | 2 +- shape.h | 2 +- unicsv.cc | 2 +- unicsv.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jeeps/gpsutil.h b/jeeps/gpsutil.h index 741d31a59..55ec8b0ba 100644 --- a/jeeps/gpsutil.h +++ b/jeeps/gpsutil.h @@ -22,7 +22,7 @@ void GPS_Warning(const char* s); [[gnu::format(printf, 1, 2)]] void GPS_Error(const char* fmt, ...); [[gnu::format(printf, 1, 2)]] void GPS_Serial_Error(const char* fmt, ...); - void GPS_Fatal(const char* s); + [[noreturn]] void GPS_Fatal(const char* s); void GPS_Enable_Error(); void GPS_Enable_Warning(); void GPS_Disable_Error(); diff --git a/jeeps/jgpsutil.cc b/jeeps/jgpsutil.cc index 0f522005f..a462201af 100644 --- a/jeeps/jgpsutil.cc +++ b/jeeps/jgpsutil.cc @@ -475,7 +475,7 @@ void GPS_Warning(const char* s) ** @@ ****************************************************************************/ -void GPS_Fatal(const char* s) +[[noreturn]] void GPS_Fatal(const char* s) { fprintf(stderr,"[FATAL] %s\n",s); diff --git a/shape.cc b/shape.cc index 94321902b..318c1a193 100644 --- a/shape.cc +++ b/shape.cc @@ -144,7 +144,7 @@ ShapeFormat::DBFCreateGpsbabel(const QString& pszFilename) } #endif -void ShapeFormat::dump_fields() const +[[noreturn]] void ShapeFormat::dump_fields() const { char name[12]; warning(MYNAME ": Database fields:\n"); diff --git a/shape.h b/shape.h index 3d1c0b9f1..04b59a0db 100644 --- a/shape.h +++ b/shape.h @@ -65,7 +65,7 @@ class ShapeFormat : public Format static SHPHandle SHPAPI_CALL SHPCreateGpsbabel(const QString& pszLayer, int nShapeType); static DBFHandle SHPAPI_CALL DBFOpenGpsbabel(const QString& pszFilename, const char* pszAccess); static DBFHandle SHPAPI_CALL DBFCreateExGpsbabel(const QString& pszFilename, const char* pszCodePage); - void dump_fields() const; + [[noreturn]] void dump_fields() const; void check_field_index(int fieldIdx) const; int get_field_index(const QString& fieldName) const; void write_wpt(const Waypoint* wpt) const; diff --git a/unicsv.cc b/unicsv.cc index 480616934..fd4ee9839 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -1078,7 +1078,7 @@ UnicsvFormat::read() /* =========================================================================== */ void -UnicsvFormat::unicsv_fatal_outside(const Waypoint* wpt) const +[[notreturn]] UnicsvFormat::unicsv_fatal_outside(const Waypoint* wpt) const { *fout << "#####\n"; fatal(MYNAME ": %s (%s) is outside of convertible area of grid \"%s\"!\n", diff --git a/unicsv.h b/unicsv.h index ce564508d..021e65a89 100644 --- a/unicsv.h +++ b/unicsv.h @@ -174,7 +174,7 @@ class UnicsvFormat : public Format static bool unicsv_compare_fields(const QString& s, const field_t* f); void unicsv_fondle_header(QString header); void unicsv_parse_one_line(const QString& ibuf); - void unicsv_fatal_outside(const Waypoint* wpt) const; + [[noreturn]] void unicsv_fatal_outside(const Waypoint* wpt) const; void unicsv_print_str(const QString& s) const; void unicsv_print_date_time(const QDateTime& idt) const; void unicsv_waypt_enum_cb(const Waypoint* wpt); From b3dc391236de5054b3809e65b7b1b2fbd9aaa0f9 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 9 Sep 2023 07:44:43 -0600 Subject: [PATCH 011/132] fix reserved-macro-identifier clang diagnostic --- googletakeout.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/googletakeout.h b/googletakeout.h index 51b9222f1..d1db57593 100644 --- a/googletakeout.h +++ b/googletakeout.h @@ -19,8 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef _GOOGLETAKEOUT_H -#define _GOOGLETAKEOUT_H +#ifndef GOOGLETAKEOUT_H_INCLUDED_ +#define GOOGLETAKEOUT_H_INCLUDED_ #include // for QJsonObject #include // for QJsonValue @@ -125,4 +125,4 @@ class GoogleTakeoutFormat : public Format QVector googletakeout_args; }; -#endif /* _GOOGLETAKEOUT_H */ +#endif /* GOOGLETAKEOUT_H_INCLUDED_ */ From 79432a8a6ceb1fa7c03e3f4f9d10e896c443154f Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sun, 10 Sep 2023 18:01:46 -0600 Subject: [PATCH 012/132] fix noreturn booboos. (#1176) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix warning: function declared ‘noreturn’ has a ‘return’ statement * geez, another booboo using noreturn. --- jeeps/jgpsutil.cc | 1 - unicsv.cc | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/jeeps/jgpsutil.cc b/jeeps/jgpsutil.cc index a462201af..68c5f926d 100644 --- a/jeeps/jgpsutil.cc +++ b/jeeps/jgpsutil.cc @@ -480,7 +480,6 @@ void GPS_Warning(const char* s) fprintf(stderr,"[FATAL] %s\n",s); exit(0); - return; } diff --git a/unicsv.cc b/unicsv.cc index fd4ee9839..372fd016d 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -1077,8 +1077,7 @@ UnicsvFormat::read() /* =========================================================================== */ -void -[[notreturn]] UnicsvFormat::unicsv_fatal_outside(const Waypoint* wpt) const +[[noreturn]] void UnicsvFormat::unicsv_fatal_outside(const Waypoint* wpt) const { *fout << "#####\n"; fatal(MYNAME ": %s (%s) is outside of convertible area of grid \"%s\"!\n", From 0a981dce1692e6796888c8a1c0eee4b8d65bd5db Mon Sep 17 00:00:00 2001 From: PacketFiend Date: Tue, 12 Sep 2023 07:28:55 -0400 Subject: [PATCH 013/132] Integrate OAT and SIU with Waypoints (#1060) * Integrate OAT and SIU with Waypoints * Type corrections, convert set_value() overload to nullptr* check * #1062 Fix core dump when merging tracks with disparate IGC extensions * Reduce `value` variable scope when writing SimpleArrays * Debug oopsie bugfix, fix core dump when merging IGC files with no extensions * Collapse redundant if statement * Fix brain fart * Eliminate igc_fsdata::has_value() * Fix subtle satellite count bug * Fix small sat count bug, and eliminate some ifdefs * Make some IGC exts override default WP members * Include IGC line-by-line debug info * Remove accidentally included file * delete obsolete macros --------- Co-authored-by: tsteven4 <13596209+tsteven4@users.noreply.github.com> --- defs.h | 4 +- igc.cc | 5 +- igc.h | 9 ++- kml.cc | 105 ++++++++++++++++++------------- kml.h | 6 ++ reference/realtime.kml | 22 +++++++ reference/track/92GV66G1.igc.kml | 5 ++ reference/track/92HV66G1.igc.kml | 5 ++ waypt.cc | 1 + 9 files changed, 114 insertions(+), 48 deletions(-) diff --git a/defs.h b/defs.h index 2a337c319..18fe9c0cf 100644 --- a/defs.h +++ b/defs.h @@ -261,13 +261,15 @@ class global_trait trait_cadence(0), trait_power(0), trait_depth(0), - trait_temperature(0) {} + trait_temperature(0), + trait_sat(0) {} unsigned int trait_geocaches:1; unsigned int trait_heartrate:1; unsigned int trait_cadence:1; unsigned int trait_power:1; unsigned int trait_depth:1; unsigned int trait_temperature:1; + unsigned int trait_sat:1; }; /* diff --git a/igc.cc b/igc.cc index 1910f2915..c26814354 100644 --- a/igc.cc +++ b/igc.cc @@ -260,6 +260,9 @@ void IgcFormat::read() strcpy(trk_desc, HDRMAGIC HDRDELIM); while (true) { + if (global_opts.debug_level >= 8) { + printf(MYNAME ": Processing IGC file line %i\n", current_line); + } igc_rec_type_t rec_type = get_record(&ibuf); current_line++; QString ibuf_q = QString::fromUtf8(ibuf); @@ -372,7 +375,7 @@ void IgcFormat::read() for (const auto& [name, ext, start, len, factor] : ext_types_list) { double ext_data = ibuf_q.mid(start,len).toInt() / factor; - fsdata->set_value(ext, ext_data); + fsdata->set_value(ext, ext_data, pres_wpt); if (global_opts.debug_level >= 6) { printf(" %s:%f", qPrintable(name), ext_data); } diff --git a/igc.h b/igc.h index 8646c1a10..d0672811e 100644 --- a/igc.h +++ b/igc.h @@ -298,7 +298,8 @@ struct igc_fsdata : public FormatSpecificData { std::optional acz; // Z Acceleration std::optional gfo; // G Force? - bool set_value(IgcFormat::igc_ext_type_t type, double value) + // Stores all data as igc_fsdata + bool set_value(IgcFormat::igc_ext_type_t type, double value, Waypoint *wp = nullptr) { bool success = true; switch (type) { @@ -312,6 +313,9 @@ struct igc_fsdata : public FormatSpecificData { vat = value; break; case IgcFormat::igc_ext_type_t::ext_rec_oat: + if (wp){ + wp->set_temperature(value); + } oat = value; break; case IgcFormat::igc_ext_type_t::ext_rec_trt: @@ -324,6 +328,9 @@ struct igc_fsdata : public FormatSpecificData { fxa = value; break; case IgcFormat::igc_ext_type_t::ext_rec_siu: + if (wp) { + wp->sat = value; + } siu = value; break; case IgcFormat::igc_ext_type_t::ext_rec_acz: diff --git a/kml.cc b/kml.cc index f05d86aa2..159cde986 100644 --- a/kml.cc +++ b/kml.cc @@ -69,8 +69,6 @@ #define ICON_DIR ICON_BASE "track-directional/track-%1.png" // format string where next arg is rotational degrees. #define MYNAME "kml" -// #define INCLUDE_IGC_TRT // Generally not very useful to graph on Google Earth -// #define INCLUDE_IGC_SIU // Satellites in use, not entirely useful to graph void KmlFormat::kml_init_color_sequencer(unsigned int steps_per_rev) { @@ -1496,6 +1494,10 @@ void KmlFormat::kml_mt_simple_array(const route_head* header, writer->writeTextElement(QStringLiteral("gx:value"), wpt->temperature_has_value()? QString::number(wpt->temperature_value(), 'f', 1) : QString()); break; + case wp_field::sat: + writer->writeTextElement(QStringLiteral("gx:value"), wpt->sat >= 0? + QString::number(wpt->sat) : QString()); + break; case wp_field::igc_enl: case wp_field::igc_tas: case wp_field::igc_vat: @@ -1561,6 +1563,7 @@ void KmlFormat::kml_mt_hdr(const route_head* header) bool has_heartrate = false; bool has_temperature = false; bool has_power = false; + bool has_sat = false; bool has_igc_exts = false; bool has_igc_enl = false; bool has_igc_tas = false; @@ -1570,12 +1573,8 @@ void KmlFormat::kml_mt_hdr(const route_head* header) bool has_igc_fxa = false; bool has_igc_gfo = false; bool has_igc_acz = false; -#ifdef INCLUDE_IGC_SIU bool has_igc_siu = false; // Not very useful to graph -#endif -#ifdef INCLUDE_IGC_TRT // Not very useful to graph - bool has_igc_trt = false; -#endif + bool has_igc_trt = false; // Not very useful to graph // This logic is kind of inside-out for GPSBabel. If a track doesn't // have enough interesting timestamps, just write it as a LineString. @@ -1635,6 +1634,10 @@ void KmlFormat::kml_mt_hdr(const route_head* header) if (tpt->power) { has_power = true; } + // # of satellites can legitimately be zero, so -1 means no data in this case + if (tpt->sat >= 0) { + has_sat = true; + } if (fs_igc) { has_igc_exts = true; if (fs_igc->enl.has_value()) { @@ -1661,47 +1664,29 @@ void KmlFormat::kml_mt_hdr(const route_head* header) if (fs_igc->acz.has_value()) { has_igc_acz = true; } -#ifdef INCLUDE_IGC_SIU - if (fs_igc->siu.has_value()) { - has_igc_siu = true; + if constexpr(kIncludeIGCSIU) { + if (fs_igc->siu.has_value()) { + has_igc_siu = true; + } } -#endif -#ifdef INCLUDE_IGC_TRT - if (fs_igc->trt.has_value()) { - has_igc_trt = true; + if constexpr(kIncludeIGCTRT) { + if (fs_igc->trt.has_value()) { + has_igc_trt = true; + } } -#endif } } // This gets unwieldly if we check each individual igc extension, // hence the has_igc_exts flag. if (has_cadence || has_depth || has_heartrate || has_temperature || - has_power || has_igc_exts) { + has_power || has_sat || has_igc_exts) { + bool include_kmt_sats = true; + bool include_kmt_temperature = true; writer->writeStartElement(QStringLiteral("ExtendedData")); writer->writeStartElement(QStringLiteral("SchemaData")); writer->writeAttribute(QStringLiteral("schemaUrl"), QStringLiteral("#schema")); - if (has_cadence) { - kml_mt_simple_array(header, kmt_cadence, wp_field::cadence); - } - - if (has_depth) { - kml_mt_simple_array(header, kmt_depth, wp_field::depth); - } - - if (has_heartrate) { - kml_mt_simple_array(header, kmt_heartrate, wp_field::heartrate); - } - - if (has_temperature) { - kml_mt_simple_array(header, kmt_temperature, wp_field::temperature); - } - - if (has_power) { - kml_mt_simple_array(header, kmt_power, wp_field::power); - } - // Perhaps not the /best/ way to do this, but this if ladder // should only be evaluated once. if (has_igc_exts) { @@ -1713,6 +1698,7 @@ void KmlFormat::kml_mt_hdr(const route_head* header) } if (has_igc_oat) { kml_mt_simple_array(header, kmt_igc_oat, wp_field::igc_oat); + include_kmt_temperature = false; } if (has_igc_vat) { kml_mt_simple_array(header, kmt_igc_vat, wp_field::igc_vat); @@ -1729,16 +1715,41 @@ void KmlFormat::kml_mt_hdr(const route_head* header) if (has_igc_acz) { kml_mt_simple_array(header, kmt_igc_acz, wp_field::igc_acz); } -#ifdef INCLUDE_IGC_SIU - if (has_igc_siu) { - kml_mt_simple_array(header, kmt_igc_siu, igc_siu); + if constexpr(kIncludeIGCSIU) { + if (has_igc_siu) { + kml_mt_simple_array(header, kmt_igc_siu, wp_field::igc_siu); + include_kmt_sats = false; + } } -#endif -#ifdef INCLUDE_IGC_TRT - if (has_igc_trt) { - kml_mt_simple_array(header, kmt_igc_trt, igc_trt); + if constexpr(kIncludeIGCTRT) { + if (has_igc_trt) { + kml_mt_simple_array(header, kmt_igc_trt, wp_field::igc_trt); + } } -#endif + } + + if (has_cadence) { + kml_mt_simple_array(header, kmt_cadence, wp_field::cadence); + } + + if (has_depth) { + kml_mt_simple_array(header, kmt_depth, wp_field::depth); + } + + if (has_heartrate) { + kml_mt_simple_array(header, kmt_heartrate, wp_field::heartrate); + } + + if (has_temperature && include_kmt_temperature) { + kml_mt_simple_array(header, kmt_temperature, wp_field::temperature); + } + + if (has_power) { + kml_mt_simple_array(header, kmt_power, wp_field::power); + } + + if (has_sat && include_kmt_sats) { + kml_mt_simple_array(header, kmt_sat, wp_field::sat); } writer->writeEndElement(); // Close SchemaData tag @@ -1924,7 +1935,8 @@ void KmlFormat::write() traits->trait_cadence || traits->trait_power || traits->trait_temperature || - traits->trait_depth) { + traits->trait_depth || + traits->trait_sat) { writer->writeStartElement(QStringLiteral("Schema")); writer->writeAttribute(QStringLiteral("id"), QStringLiteral("schema")); @@ -1943,6 +1955,9 @@ void KmlFormat::write() if (traits->trait_depth) { kml_mt_array_schema(kmt_depth, "Depth", "float"); } + if (traits->trait_sat) { + kml_mt_array_schema(kmt_sat, "Satellites", "int"); + } writer->writeEndElement(); // Close Schema tag } diff --git a/kml.h b/kml.h index f11e2ebbd..505e7aeac 100644 --- a/kml.h +++ b/kml.h @@ -74,6 +74,7 @@ class KmlFormat : public Format heartrate, temperature, power, + sat, igc_enl, // Engine Noise Level igc_tas, // True Airspeed igc_vat, // Compensated variometer (total energy) @@ -123,6 +124,7 @@ class KmlFormat : public Format static constexpr const char* kmt_temperature = "temperature"; static constexpr const char* kmt_depth = "depth"; static constexpr const char* kmt_power = "power"; + static constexpr const char* kmt_sat = "satellites"; // Constants pertaining to IGC files would be better defined in either igc.h or formspec.h static constexpr const char* kmt_igc_enl = "Engine Noise"; static constexpr const char* kmt_igc_vat = "Ttl Enrg Vario"; @@ -135,6 +137,10 @@ class KmlFormat : public Format static constexpr const char* kmt_igc_siu = "# Of Sats"; static constexpr const char* kmt_igc_acz = "Z Accel"; + // IGC option compile-time flags + static constexpr bool kIncludeIGCSIU = true; + static constexpr bool kIncludeIGCTRT = false; + /* Member Functions */ void kml_init_color_sequencer(unsigned int steps_per_rev); diff --git a/reference/realtime.kml b/reference/realtime.kml index 1eb65120f..11a914249 100644 --- a/reference/realtime.kml +++ b/reference/realtime.kml @@ -126,6 +126,9 @@ Depth + + Satellites + Wpt_8u4Dqkf @@ -280,6 +283,25 @@ 402.7 + + 6 + 8 + 6 + 3 + 12 + 11 + 3 + 4 + 10 + 4 + 10 + 9 + 8 + 9 + 2 + 3 + 5 + diff --git a/reference/track/92GV66G1.igc.kml b/reference/track/92GV66G1.igc.kml index 5e325be05..046376dfb 100644 --- a/reference/track/92GV66G1.igc.kml +++ b/reference/track/92GV66G1.igc.kml @@ -110,6 +110,11 @@ 6 + + + Temperature + + Tracks diff --git a/reference/track/92HV66G1.igc.kml b/reference/track/92HV66G1.igc.kml index 91600f937..e5957a366 100644 --- a/reference/track/92HV66G1.igc.kml +++ b/reference/track/92HV66G1.igc.kml @@ -110,6 +110,11 @@ 6 + + + Temperature + + Tracks diff --git a/waypt.cc b/waypt.cc index 30b255c73..e7f45e08c 100644 --- a/waypt.cc +++ b/waypt.cc @@ -74,6 +74,7 @@ void update_common_traits(const Waypoint* wpt) traits.trait_power |= wpt->power > 0; traits.trait_depth |= wpt->depth_has_value(); traits.trait_temperature |= wpt->temperature_has_value(); + traits.trait_sat |= wpt->sat >= 0; } void From 926f207cf035646adf1c4c6c3a8967b5aaf809d0 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 14 Sep 2023 06:54:38 -0600 Subject: [PATCH 014/132] fix SchemaArrayField/SchemaArrayData mismatch (#1177) * fix SchemaArrayField/SchemaArrayData mismatch related to IGC additions from #1060 and #1054. * retire global trait collection * use class member to store track traits instead of fs data. * fiddle with kml accumlate hash * compute number of wp_fields * correct bug concerning track specific traits. * simplify multi-track array decisions. * simplify kml multi-track schema decisions. --- defs.h | 25 -- kml.cc | 317 ++++++++---------- kml.h | 42 ++- reference/realtime.kml | 14 +- reference/track/92GV66G1.igc.kml | 50 ++- reference/track/92HV66G1.igc.kml | 50 ++- .../track/gpx_garmin_extensions-kml_track.kml | 6 +- reference/track/gtrnctr_power-kml.kml | 6 +- route.cc | 5 - waypt.cc | 27 -- 10 files changed, 240 insertions(+), 302 deletions(-) diff --git a/defs.h b/defs.h index 18fe9c0cf..1ab851799 100644 --- a/defs.h +++ b/defs.h @@ -248,30 +248,6 @@ class wp_flags unsigned int marked_for_deletion:1; /* True if schedulded for deletion. */ }; -// These are dicey as they're collected on read. Subsequent filters may change -// things, though it's unlikely to matter in practical terms. Don't use these -// if a false positive would be deleterious. -# -class global_trait -{ -public: - global_trait() : - trait_geocaches(0), - trait_heartrate(0), - trait_cadence(0), - trait_power(0), - trait_depth(0), - trait_temperature(0), - trait_sat(0) {} - unsigned int trait_geocaches:1; - unsigned int trait_heartrate:1; - unsigned int trait_cadence:1; - unsigned int trait_power:1; - unsigned int trait_depth:1; - unsigned int trait_temperature:1; - unsigned int trait_sat:1; -}; - /* * Bounding box information. */ @@ -509,7 +485,6 @@ class WaypointList : private QList using QList::size_type; }; -const global_trait* get_traits(); void waypt_init(); //void update_common_traits(const Waypoint* wpt); void waypt_add(Waypoint* wpt); diff --git a/kml.cc b/kml.cc index 159cde986..dbf3e28b2 100644 --- a/kml.cc +++ b/kml.cc @@ -35,6 +35,7 @@ #include // for QDate #include // for QDateTime #include // for QFile +#include // for QHash #include // for operator|, QIODevice, QIODevice::Text, QIODevice::WriteOnly #include // for QList #include // for QString, QStringLiteral, operator+, operator!= @@ -70,6 +71,25 @@ #define MYNAME "kml" +const QVector KmlFormat::mt_fields_def = { + { wp_field::igc_enl, "igc_enl", "Engine Noise", "double" }, + { wp_field::igc_tas, "igc_tas", "True Airspd", "double" }, + { wp_field::igc_oat, "igc_oat", "Otsd Air Temp", "double" }, + { wp_field::igc_vat, "igc_vat", "Ttl Enrg Vario", "double" }, + { wp_field::igc_gsp, "igc_gsp", "Ground Speed", "double" }, + { wp_field::igc_fxa, "igc_fxa", "Fix Accuracy", "double" }, + { wp_field::igc_gfo, "igc_gfo", "G Force?", "double" }, + { wp_field::igc_acz, "igc_acz", "Z Accel", "double" }, + { wp_field::igc_siu, "igc_siu", "# Of Sats", "double" }, + { wp_field::igc_trt, "igc_trt", "True Track", "double" }, + { wp_field::cadence, "cadence", "Cadence", "int" }, + { wp_field::depth, "depth", "Depth", "float" }, + { wp_field::heartrate, "heartrate", "Heart Rate", "int" }, + { wp_field::temperature, "temperature", "Temperature", "float" }, + { wp_field::power, "power", "Power", "float" }, + { wp_field::sat, "satellites", "Satellites", "int" }, +}; + void KmlFormat::kml_init_color_sequencer(unsigned int steps_per_rev) { if (rotate_colors) { @@ -101,7 +121,7 @@ void KmlFormat::kml_step_color() } else if ((color_seq >= (2*kml_color_limit)) && (color_seq < (3*kml_color_limit))) { kml_color_sequencer.color.bbggrr = kml_bgr_to_color(color_seq-2*kml_color_limit, kml_color_limit, 0); } else if ((color_seq >= (3*kml_color_limit)) && (color_seq < (4*kml_color_limit))) { - kml_color_sequencer.color.bbggrr = kml_bgr_to_color(kml_color_limit, 4*kml_color_limit-color_seq ,0); + kml_color_sequencer.color.bbggrr = kml_bgr_to_color(kml_color_limit, 4*kml_color_limit-color_seq,0); } else if ((color_seq >= (4*kml_color_limit)) && (color_seq < (5*kml_color_limit))) { kml_color_sequencer.color.bbggrr = kml_bgr_to_color(kml_color_limit, 0, color_seq-4*kml_color_limit); } else if ((color_seq >= (5*kml_color_limit)) && (color_seq < (6*kml_color_limit))) { @@ -417,6 +437,9 @@ void KmlFormat::wr_deinit() QFile::remove(posnfilename); QFile::rename(posnfilenametmp, posnfilename); } + + kml_track_traits.reset(); + kml_track_traits_hash.clear(); } void KmlFormat::wr_position_deinit() @@ -424,6 +447,9 @@ void KmlFormat::wr_position_deinit() // kml_wr_deinit(); posnfilename.clear(); posnfilenametmp.clear(); + + kml_track_traits.reset(); + kml_track_traits_hash.clear(); } @@ -1463,13 +1489,13 @@ void KmlFormat::kml_track_tlr(const route_head* header) */ void KmlFormat::kml_mt_simple_array(const route_head* header, - const char* name, + const QString& name, wp_field member) const { writer->writeStartElement(QStringLiteral("gx:SimpleArrayData")); writer->writeAttribute(QStringLiteral("name"), name); if (global_opts.debug_level >= 3) { - printf(MYNAME ": New KML SimpleArray: %s\n", name); + printf(MYNAME ": New KML SimpleArray: %s\n", qPrintable(name)); } foreach (const Waypoint* wpt, header->waypoint_list) { const auto* fs_igc = reinterpret_cast(wpt->fs.FsChainFind(kFsIGC)); @@ -1496,7 +1522,7 @@ void KmlFormat::kml_mt_simple_array(const route_head* header, break; case wp_field::sat: writer->writeTextElement(QStringLiteral("gx:value"), wpt->sat >= 0? - QString::number(wpt->sat) : QString()); + QString::number(wpt->sat) : QString()); break; case wp_field::igc_enl: case wp_field::igc_tas: @@ -1511,14 +1537,14 @@ void KmlFormat::kml_mt_simple_array(const route_head* header, if (fs_igc && fs_igc->get_value(member).has_value()) { double value = fs_igc->get_value(member).value(); if (global_opts.debug_level >= 6) { - printf(MYNAME ": Writing KML SimpleArray data: %s of %f\n", name, value); + printf(MYNAME ": Writing KML SimpleArray data: %s of %f\n", qPrintable(name), value); } writer->writeTextElement(QStringLiteral("gx:value"), QString::number(value)); - // No igc_fsdata present, but we still need to write out the SimpleArray. - // This can happen when merging tracks with different sets of IGC extensions. + // No igc_fsdata present, but we still need to write out the SimpleArray. + // This can happen when merging tracks with different sets of IGC extensions. } else { if (global_opts.debug_level >= 7) { - printf(MYNAME ": Writing empty KML SimpleArray data for %s\n", name); + printf(MYNAME ": Writing empty KML SimpleArray data for %s\n", qPrintable(name)); } writer->writeTextElement(QStringLiteral("gx:value"), QString()); } @@ -1556,200 +1582,141 @@ void KmlFormat::write_as_linestring(const route_head* header) } -void KmlFormat::kml_mt_hdr(const route_head* header) +void KmlFormat::kml_accumulate_track_traits(const route_head* rte) { - bool has_cadence = false; - bool has_depth = false; - bool has_heartrate = false; - bool has_temperature = false; - bool has_power = false; - bool has_sat = false; - bool has_igc_exts = false; - bool has_igc_enl = false; - bool has_igc_tas = false; - bool has_igc_oat = false; - bool has_igc_vat = false; - bool has_igc_gsp = false; - bool has_igc_fxa = false; - bool has_igc_gfo = false; - bool has_igc_acz = false; - bool has_igc_siu = false; // Not very useful to graph - bool has_igc_trt = false; // Not very useful to graph - - // This logic is kind of inside-out for GPSBabel. If a track doesn't - // have enough interesting timestamps, just write it as a LineString. - if (!track_has_time(header)) { - write_as_linestring(header); - return; - } - - writer->writeStartElement(QStringLiteral("Placemark")); - writer->writeOptionalTextElement(QStringLiteral("name"), header->rte_name); - writer->writeTextElement(QStringLiteral("styleUrl"), QStringLiteral("#multiTrack")); - writer->writeStartElement(QStringLiteral("gx:Track")); - kml_output_positioning(false); - - foreach (const Waypoint* tpt, header->waypoint_list) { - - if (tpt->GetCreationTime().isValid()) { - QString time_string = tpt->CreationTimeXML(); - writer->writeOptionalTextElement(QStringLiteral("when"), time_string); - } else { - writer->writeStartElement(QStringLiteral("when")); - writer->writeEndElement(); // Close when tag - } - } - - // TODO: How to handle clamped, floating, extruded, etc.? - foreach (const Waypoint* tpt, header->waypoint_list) { + track_trait_t track_traits; + foreach (const Waypoint* tpt, rte->waypoint_list) { const auto* fs_igc = reinterpret_cast(tpt->fs.FsChainFind(kFsIGC)); - if (kml_altitude_known(tpt)) { - writer->writeTextElement(QStringLiteral("gx:coord"), - QString::number(tpt->longitude, 'f', precision) + QString(" ") + - QString::number(tpt->latitude, 'f', precision) + QString(" ") + - QString::number(tpt->altitude, 'f', 2) - ); - } else { - writer->writeTextElement(QStringLiteral("gx:coord"), - QString::number(tpt->longitude, 'f', precision) + QString(" ") + - QString::number(tpt->latitude, 'f', precision) - ); - } // Capture interesting traits to see if we need to do an ExtendedData // section later. if (tpt->cadence) { - has_cadence = true; + track_traits[static_cast(wp_field::cadence)] = true; } if (tpt->depth_has_value()) { - has_depth = true; + track_traits[static_cast(wp_field::depth)] = true; } if (tpt->heartrate) { - has_heartrate = true; + track_traits[static_cast(wp_field::heartrate)] = true; } if (tpt->temperature_has_value()) { - has_temperature = true; + track_traits[static_cast(wp_field::temperature)] = true; } if (tpt->power) { - has_power = true; + track_traits[static_cast(wp_field::power)] = true; } // # of satellites can legitimately be zero, so -1 means no data in this case if (tpt->sat >= 0) { - has_sat = true; + track_traits[static_cast(wp_field::sat)] = true; } if (fs_igc) { - has_igc_exts = true; if (fs_igc->enl.has_value()) { - has_igc_enl = true; + track_traits[static_cast(wp_field::igc_enl)] = true; } if (fs_igc->tas.has_value()) { - has_igc_tas = true; + track_traits[static_cast(wp_field::igc_tas)] = true; } if (fs_igc->oat.has_value()) { - has_igc_oat = true; + track_traits[static_cast(wp_field::igc_oat)] = true; } if (fs_igc->vat.has_value()) { - has_igc_vat = true; + track_traits[static_cast(wp_field::igc_vat)] = true; } if (fs_igc->gsp.has_value()) { - has_igc_gsp = true; + track_traits[static_cast(wp_field::igc_gsp)] = true; } if (fs_igc->fxa.has_value()) { - has_igc_fxa = true; + track_traits[static_cast(wp_field::igc_fxa)] = true; } if (fs_igc->gfo.has_value()) { - has_igc_gfo = true; + track_traits[static_cast(wp_field::igc_gfo)] = true; } if (fs_igc->acz.has_value()) { - has_igc_acz = true; + track_traits[static_cast(wp_field::igc_acz)] = true; } if constexpr(kIncludeIGCSIU) { if (fs_igc->siu.has_value()) { - has_igc_siu = true; + track_traits[static_cast(wp_field::igc_siu)] = true; } } if constexpr(kIncludeIGCTRT) { if (fs_igc->trt.has_value()) { - has_igc_trt = true; + track_traits[static_cast(wp_field::igc_trt)] = true; } } } } - // This gets unwieldly if we check each individual igc extension, - // hence the has_igc_exts flag. - if (has_cadence || has_depth || has_heartrate || has_temperature || - has_power || has_sat || has_igc_exts) { - bool include_kmt_sats = true; - bool include_kmt_temperature = true; - writer->writeStartElement(QStringLiteral("ExtendedData")); - writer->writeStartElement(QStringLiteral("SchemaData")); - writer->writeAttribute(QStringLiteral("schemaUrl"), QStringLiteral("#schema")); + // For dual source fields give priority to igc. + if (track_traits[static_cast(wp_field::igc_oat)]) { + track_traits[static_cast(wp_field::temperature)] = false; + } + if (track_traits[static_cast(wp_field::igc_siu)]) { + track_traits[static_cast(wp_field::sat)] = false; + } - // Perhaps not the /best/ way to do this, but this if ladder - // should only be evaluated once. - if (has_igc_exts) { - if (has_igc_enl) { - kml_mt_simple_array(header, kmt_igc_enl, wp_field::igc_enl); - } - if (has_igc_tas) { - kml_mt_simple_array(header, kmt_igc_tas, wp_field::igc_tas); - } - if (has_igc_oat) { - kml_mt_simple_array(header, kmt_igc_oat, wp_field::igc_oat); - include_kmt_temperature = false; - } - if (has_igc_vat) { - kml_mt_simple_array(header, kmt_igc_vat, wp_field::igc_vat); - } - if (has_igc_gsp) { - kml_mt_simple_array(header, kmt_igc_gsp, wp_field::igc_gsp); - } - if (has_igc_fxa) { - kml_mt_simple_array(header, kmt_igc_fxa, wp_field::igc_fxa); - } - if (has_igc_gfo) { - kml_mt_simple_array(header, kmt_igc_gfo, wp_field::igc_gfo); - } - if (has_igc_acz) { - kml_mt_simple_array(header, kmt_igc_acz, wp_field::igc_acz); - } - if constexpr(kIncludeIGCSIU) { - if (has_igc_siu) { - kml_mt_simple_array(header, kmt_igc_siu, wp_field::igc_siu); - include_kmt_sats = false; - } - } - if constexpr(kIncludeIGCTRT) { - if (has_igc_trt) { - kml_mt_simple_array(header, kmt_igc_trt, wp_field::igc_trt); - } - } - } + // When doing real time positioning we may already have been here. + // If so, replace the previous value corresponding to the key. + // If not, insert a new key value pair. + kml_track_traits_hash.insert(rte, track_traits); + kml_track_traits |= track_traits; +} - if (has_cadence) { - kml_mt_simple_array(header, kmt_cadence, wp_field::cadence); - } +void KmlFormat::kml_mt_hdr(const route_head* header) +{ + // This logic is kind of inside-out for GPSBabel. If a track doesn't + // have enough interesting timestamps, just write it as a LineString. + if (!track_has_time(header)) { + write_as_linestring(header); + return; + } - if (has_depth) { - kml_mt_simple_array(header, kmt_depth, wp_field::depth); - } + writer->writeStartElement(QStringLiteral("Placemark")); + writer->writeOptionalTextElement(QStringLiteral("name"), header->rte_name); + writer->writeTextElement(QStringLiteral("styleUrl"), QStringLiteral("#multiTrack")); + writer->writeStartElement(QStringLiteral("gx:Track")); + kml_output_positioning(false); - if (has_heartrate) { - kml_mt_simple_array(header, kmt_heartrate, wp_field::heartrate); - } + foreach (const Waypoint* tpt, header->waypoint_list) { - if (has_temperature && include_kmt_temperature) { - kml_mt_simple_array(header, kmt_temperature, wp_field::temperature); + if (tpt->GetCreationTime().isValid()) { + QString time_string = tpt->CreationTimeXML(); + writer->writeOptionalTextElement(QStringLiteral("when"), time_string); + } else { + writer->writeStartElement(QStringLiteral("when")); + writer->writeEndElement(); // Close when tag } + } - if (has_power) { - kml_mt_simple_array(header, kmt_power, wp_field::power); + // TODO: How to handle clamped, floating, extruded, etc.? + foreach (const Waypoint* tpt, header->waypoint_list) { + + if (kml_altitude_known(tpt)) { + writer->writeTextElement(QStringLiteral("gx:coord"), + QString::number(tpt->longitude, 'f', precision) + QString(" ") + + QString::number(tpt->latitude, 'f', precision) + QString(" ") + + QString::number(tpt->altitude, 'f', 2) + ); + } else { + writer->writeTextElement(QStringLiteral("gx:coord"), + QString::number(tpt->longitude, 'f', precision) + QString(" ") + + QString::number(tpt->latitude, 'f', precision) + ); } + } + + + auto track_traits = kml_track_traits_hash.value(header); + if (track_traits.any()) { + writer->writeStartElement(QStringLiteral("ExtendedData")); + writer->writeStartElement(QStringLiteral("SchemaData")); + writer->writeAttribute(QStringLiteral("schemaUrl"), QStringLiteral("#schema")); - if (has_sat && include_kmt_sats) { - kml_mt_simple_array(header, kmt_sat, wp_field::sat); + for (const auto& flddef : mt_fields_def) { + if (track_traits[static_cast(flddef.id)]) { + kml_mt_simple_array(header, flddef.name, flddef.id); + } } writer->writeEndElement(); // Close SchemaData tag @@ -1757,7 +1724,6 @@ void KmlFormat::kml_mt_hdr(const route_head* header) } } - void KmlFormat::kml_mt_tlr(const route_head* header) const { if (track_has_time(header)) { @@ -1850,8 +1816,8 @@ void KmlFormat::kml_write_AbstractView() } -void KmlFormat::kml_mt_array_schema(const char* field_name, const char* display_name, - const char* type) const +void KmlFormat::kml_mt_array_schema(const QString& field_name, const QString& display_name, + const QString& type) const { writer->writeStartElement(QStringLiteral("gx:SimpleArrayField")); writer->writeAttribute(QStringLiteral("name"), field_name); @@ -1862,8 +1828,6 @@ void KmlFormat::kml_mt_array_schema(const char* field_name, const char* display_ void KmlFormat::write() { - const global_trait* traits = get_traits(); - // Parse options export_lines = (0 == strcmp("1", opt_export_lines)); export_points = (0 == strcmp("1", opt_export_points)); @@ -1927,38 +1891,35 @@ void KmlFormat::write() writer->writeEndElement(); // Close Style tag } - if (traits->trait_geocaches) { + bool has_geocaches = false; + auto kml_accumulate_wpt_traits_lambda = [&has_geocaches](const Waypoint* wpt)->void { + has_geocaches |= (wpt->gc_data->diff && wpt->gc_data->terr); + }; + waypt_disp_all(kml_accumulate_wpt_traits_lambda); + + if (has_geocaches) { kml_gc_make_balloonstyle(); } - if (traits->trait_heartrate || - traits->trait_cadence || - traits->trait_power || - traits->trait_temperature || - traits->trait_depth || - traits->trait_sat) { - writer->writeStartElement(QStringLiteral("Schema")); - writer->writeAttribute(QStringLiteral("id"), QStringLiteral("schema")); + if (export_track) { + kml_track_traits.reset(); + kml_track_traits_hash.clear(); + auto kml_accumulate_track_traits_lambda = [this](const route_head* rte)->void { + kml_accumulate_track_traits(rte); + }; + track_disp_all(kml_accumulate_track_traits_lambda, nullptr, nullptr); - if (traits->trait_heartrate) { - kml_mt_array_schema(kmt_heartrate, "Heart Rate", "int"); - } - if (traits->trait_cadence) { - kml_mt_array_schema(kmt_cadence, "Cadence", "int"); - } - if (traits->trait_power) { - kml_mt_array_schema(kmt_power, "Power", "float"); - } - if (traits->trait_temperature) { - kml_mt_array_schema(kmt_temperature, "Temperature", "float"); - } - if (traits->trait_depth) { - kml_mt_array_schema(kmt_depth, "Depth", "float"); - } - if (traits->trait_sat) { - kml_mt_array_schema(kmt_sat, "Satellites", "int"); + if (kml_track_traits.any()) { + writer->writeStartElement(QStringLiteral("Schema")); + writer->writeAttribute(QStringLiteral("id"), QStringLiteral("schema")); + + for (const auto& flddef : mt_fields_def) { + if (kml_track_traits[static_cast(flddef.id)]) { + kml_mt_array_schema(flddef.name, flddef.displayName, flddef.type); + } + } + writer->writeEndElement(); // Close Schema tag } - writer->writeEndElement(); // Close Schema tag } if (waypt_count()) { diff --git a/kml.h b/kml.h index 505e7aeac..d51f190dc 100644 --- a/kml.h +++ b/kml.h @@ -22,8 +22,10 @@ #ifndef KML_H_INCLUDED_ #define KML_H_INCLUDED_ +#include // for bitset #include // for tuple, make_tuple, tie +#include // for QHash #include // for QList #include // for QString, QStringLiteral, operator+, operator!= #include // for QVector @@ -69,7 +71,7 @@ class KmlFormat : public Format // Helper to write gx:SimpleList, iterating over a route queue and writing out. enum class wp_field { - cadence, + cadence = 0, depth, heartrate, temperature, @@ -86,6 +88,7 @@ class KmlFormat : public Format igc_siu, // Satellites In Use igc_acz // Z Acceleration }; + static constexpr int number_wp_fields = static_cast(wp_field::igc_acz) + 1; private: /* Types */ @@ -99,6 +102,15 @@ class KmlFormat : public Format kmlpt_other }; + struct mt_field_t { + wp_field id; + const QString name; + const QString displayName; + const QString type; + }; + + using track_trait_t = std::bitset; + /* Constants */ static constexpr const char* default_precision = "6"; static constexpr int kml_color_limit = 204; /* allowed range [0,255] */ @@ -118,25 +130,6 @@ class KmlFormat : public Format nullptr }; - // Multitrack ids to correlate Schema to SchemaData - static constexpr const char* kmt_heartrate = "heartrate"; - static constexpr const char* kmt_cadence = "cadence"; - static constexpr const char* kmt_temperature = "temperature"; - static constexpr const char* kmt_depth = "depth"; - static constexpr const char* kmt_power = "power"; - static constexpr const char* kmt_sat = "satellites"; - // Constants pertaining to IGC files would be better defined in either igc.h or formspec.h - static constexpr const char* kmt_igc_enl = "Engine Noise"; - static constexpr const char* kmt_igc_vat = "Ttl Enrg Vario"; - static constexpr const char* kmt_igc_tas = "True Airspd"; - static constexpr const char* kmt_igc_oat = "Otsd Air Temp"; - static constexpr const char* kmt_igc_trt = "True Track"; - static constexpr const char* kmt_igc_gsp = "Ground Speed"; - static constexpr const char* kmt_igc_fxa = "Fix Accuracy"; - static constexpr const char* kmt_igc_gfo = "G Force?"; - static constexpr const char* kmt_igc_siu = "# Of Sats"; - static constexpr const char* kmt_igc_acz = "Z Accel"; - // IGC option compile-time flags static constexpr bool kIncludeIGCSIU = true; static constexpr bool kIncludeIGCTRT = false; @@ -196,20 +189,25 @@ class KmlFormat : public Format void kml_track_hdr(const route_head* header) const; void kml_track_disp(const Waypoint* waypointp) const; void kml_track_tlr(const route_head* header); - void kml_mt_simple_array(const route_head* header, const char* name, wp_field member) const; + void kml_mt_simple_array(const route_head* header, const QString& name, wp_field member) const; static bool track_has_time(const route_head* header); void write_as_linestring(const route_head* header); + void kml_accumulate_track_traits(const route_head* rte); void kml_mt_hdr(const route_head* header); void kml_mt_tlr(const route_head* header) const; void kml_route_hdr(const route_head* header) const; void kml_route_disp(const Waypoint* waypointp) const; void kml_route_tlr(const route_head* header); void kml_write_AbstractView(); - void kml_mt_array_schema(const char* field_name, const char* display_name, const char* type) const; + void kml_mt_array_schema(const QString& field_name, const QString& display_name, const QString& type) const; static QString kml_get_posn_icon(int freshness); /* Data Members */ + static const QVector mt_fields_def; + track_trait_t kml_track_traits; + QHash kml_track_traits_hash; + // options char* opt_deficon{nullptr}; char* opt_export_lines{nullptr}; diff --git a/reference/realtime.kml b/reference/realtime.kml index 11a914249..4524ae74d 100644 --- a/reference/realtime.kml +++ b/reference/realtime.kml @@ -111,20 +111,20 @@ - - Heart Rate - Cadence - - Power + + Depth + + + Heart Rate Temperature - - Depth + + Power Satellites diff --git a/reference/track/92GV66G1.igc.kml b/reference/track/92GV66G1.igc.kml index 046376dfb..390afe661 100644 --- a/reference/track/92GV66G1.igc.kml +++ b/reference/track/92GV66G1.igc.kml @@ -111,8 +111,26 @@ - - Temperature + + Engine Noise + + + True Airspd + + + Otsd Air Temp + + + Ttl Enrg Vario + + + Ground Speed + + + Fix Accuracy + + + Z Accel @@ -1572,7 +1590,7 @@ -81.838083 28.408050 51.00 - + 31 1 4 @@ -2298,7 +2316,7 @@ 15 4 - + 0 0 0 @@ -3024,7 +3042,7 @@ 0 0 - + 26.1 26.1 26.1 @@ -3750,7 +3768,7 @@ 22.6 22.6 - + 1.1 0.7 0.3 @@ -4476,7 +4494,7 @@ 0 -0.1 - + 0.31 0.08 0.05 @@ -5202,7 +5220,7 @@ 0.02 0.01 - + 7 6 7 @@ -5928,7 +5946,7 @@ 7 7 - + 9 9 9 @@ -8113,7 +8131,7 @@ -81.838083 28.408050 28.00 - + 31 1 4 @@ -8839,7 +8857,7 @@ 15 4 - + 0 0 0 @@ -9565,7 +9583,7 @@ 0 0 - + 26.1 26.1 26.1 @@ -10291,7 +10309,7 @@ 22.6 22.6 - + 1.1 0.7 0.3 @@ -11017,7 +11035,7 @@ 0 -0.1 - + 0.31 0.08 0.05 @@ -11743,7 +11761,7 @@ 0.02 0.01 - + 7 6 7 @@ -12469,7 +12487,7 @@ 7 7 - + 9 9 9 diff --git a/reference/track/92HV66G1.igc.kml b/reference/track/92HV66G1.igc.kml index e5957a366..7975e47aa 100644 --- a/reference/track/92HV66G1.igc.kml +++ b/reference/track/92HV66G1.igc.kml @@ -111,8 +111,26 @@ - - Temperature + + Engine Noise + + + True Airspd + + + Otsd Air Temp + + + Ttl Enrg Vario + + + Ground Speed + + + Fix Accuracy + + + Z Accel @@ -5064,7 +5082,7 @@ -81.837917 28.408033 29.00 - + 4 4 4 @@ -7536,7 +7554,7 @@ 4 4 - + 0 0 0 @@ -10008,7 +10026,7 @@ 0 0 - + 28 28 28 @@ -12480,7 +12498,7 @@ 25.4 25.4 - + 0 0 0 @@ -14952,7 +14970,7 @@ 0 0.1 - + 0.19 0.05 0.03 @@ -17424,7 +17442,7 @@ 0.02 0.02 - + 8 8 8 @@ -19896,7 +19914,7 @@ 5 5 - + 9 9 9 @@ -27319,7 +27337,7 @@ -81.837917 28.408033 35.00 - + 4 4 4 @@ -29791,7 +29809,7 @@ 4 4 - + 0 0 0 @@ -32263,7 +32281,7 @@ 0 0 - + 28 28 28 @@ -34735,7 +34753,7 @@ 25.4 25.4 - + 0 0 0 @@ -37207,7 +37225,7 @@ 0 0.1 - + 0.19 0.05 0.03 @@ -39679,7 +39697,7 @@ 0.02 0.02 - + 8 8 8 @@ -42151,7 +42169,7 @@ 5 5 - + 9 9 9 diff --git a/reference/track/gpx_garmin_extensions-kml_track.kml b/reference/track/gpx_garmin_extensions-kml_track.kml index 81236455d..d4f43574f 100644 --- a/reference/track/gpx_garmin_extensions-kml_track.kml +++ b/reference/track/gpx_garmin_extensions-kml_track.kml @@ -111,12 +111,12 @@ - - Heart Rate - Cadence + + Heart Rate + Waypoints diff --git a/reference/track/gtrnctr_power-kml.kml b/reference/track/gtrnctr_power-kml.kml index 8c3b11c52..dea07b9d8 100644 --- a/reference/track/gtrnctr_power-kml.kml +++ b/reference/track/gtrnctr_power-kml.kml @@ -111,12 +111,12 @@ - - Heart Rate - Cadence + + Heart Rate + Power diff --git a/route.cc b/route.cc index a83e9dd88..f0a17cc6e 100644 --- a/route.cc +++ b/route.cc @@ -38,8 +38,6 @@ RouteList* global_route_list; RouteList* global_track_list; -extern void update_common_traits(const Waypoint* wpt); - void route_init() { @@ -446,9 +444,6 @@ RouteList::add_wpt(route_head* rte, Waypoint* wpt, bool synth, QStringView namep { ++waypt_ct; rte->waypoint_list.add_rte_waypt(waypt_ct, wpt, synth, namepart, number_digits); - if ((this == global_route_list) || (this == global_track_list)) { - update_common_traits(wpt); - } } void diff --git a/waypt.cc b/waypt.cc index e7f45e08c..8130add75 100644 --- a/waypt.cc +++ b/waypt.cc @@ -47,12 +47,6 @@ WaypointList* global_waypoint_list; Geocache Waypoint::empty_gc_data; -static global_trait traits; - -const global_trait* get_traits() -{ - return &traits; -} void waypt_init() @@ -60,23 +54,6 @@ waypt_init() global_waypoint_list = new WaypointList; } -void update_common_traits(const Waypoint* wpt) -{ - /* This is a bit tacky, but it allows a hint whether we've seen - * this data or not in the life cycle of this run. Of course, - * the caches could have been filtered out of existence and not - * all waypoints may have this and a few other pitfalls, but it's - * an easy and fast test here. - */ - traits.trait_geocaches |= (wpt->gc_data->diff && wpt->gc_data->terr); - traits.trait_heartrate |= wpt->heartrate > 0; - traits.trait_cadence |= wpt->cadence > 0; - traits.trait_power |= wpt->power > 0; - traits.trait_depth |= wpt->depth_has_value(); - traits.trait_temperature |= wpt->temperature_has_value(); - traits.trait_sat |= wpt->sat >= 0; -} - void waypt_add(Waypoint* wpt) { @@ -637,10 +614,6 @@ WaypointList::waypt_add(Waypoint* wpt) } } - if (this == global_waypoint_list) { - update_common_traits(wpt); - } - } void From 2ff93fa03edebdae634aa76d6b1877e7c2b3a08e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 14 Sep 2023 07:43:55 -0600 Subject: [PATCH 015/132] fix various "Redundancies in code" (#1178) * fix "Redundant elaborted type specifier" * fix "Redundant 'inline' specifier" * fix "redundant 'const' specifier on a constexpr variable" * remove "Redundant qualifier" * add /out/, /.vs/ to .gitignore, and sort. --- .gitignore | 62 +++++++++++++++++++++++--------------------- exif.h | 2 +- garmin.cc | 8 +++--- garmin_gpi.h | 10 +++---- garmin_txt.cc | 2 +- googletakeout.cc | 4 +-- igc.cc | 2 +- igc.h | 44 +++++++++++++++---------------- jeeps/gps.h | 8 +++--- jeeps/gpsapp.cc | 2 +- jeeps/gpscom.cc | 18 ++++++------- jeeps/gpscom.h | 16 ++++++------ jeeps/gpsprot.cc | 7 +++-- jeeps/gpsusbcommon.h | 2 +- mkshort.h | 2 +- mtk_logger.cc | 12 ++++----- skytraq.cc | 12 ++++----- v900.cc | 8 +++--- 18 files changed, 111 insertions(+), 110 deletions(-) diff --git a/.gitignore b/.gitignore index 8da97ca49..6d7d77f69 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,21 @@ +*.a +*.o +*.swp +.ninja_deps +.ninja_log +.qmake.cache +.qmake.stash +.qt +/*.gcda +/*.gcno +/*.gcov +/.vs/ +/.vscode/ +/GPSBabel +/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2 +/GPSBabel[0-9]*.[0-9]*.[0-9]*/ +/Makefile +/autogen/ /autom4te.cache/ /babelweb/ /bld/ @@ -8,46 +26,30 @@ /config.status /cscope.out /debug/ +/empty +/gbversion.h /gpsbabel /gpsbabel-debug /gpsbabel.exe /gpsbabel.fo +/gpsbabel.gch/ /gpsbabel.html /gpsbabel.pdf +/gpsbabel.rc /gpsbabel_autogen/ /gpsbabel_coverage.xml -/Makefile -.qmake.cache -.qmake.stash -/GPSBabel -/*.gcda -/*.gcno -/*.gcov -*.o -*.a -.ninja_deps -.ninja_log -.qt -build.ninja -rules.ninja -cmake_install.cmake -CMakeCache.txt -CMakeFiles/ -CTestTestfile.cmake -/GPSBabel[0-9]*.[0-9]*.[0-9]*/ -/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2 +/makedoc /makelinuxdist.sh +/mkcapabilities /objects/ +/out/ +/qrc_gpsbabel.cpp /release/ -*.swp /tmp/ -/mkcapabilities -/gpsbabel.gch/ -/gpsbabel.rc -/autogen/ -/makedoc -/empty -/gbversion.h -/qrc_gpsbabel.cpp -/.vscode/ +CMakeCache.txt +CMakeFiles/ +CTestTestfile.cmake Testing +build.ninja +cmake_install.cmake +rules.ninja diff --git a/exif.h b/exif.h index 3c0a9f85e..2be58deda 100644 --- a/exif.h +++ b/exif.h @@ -115,7 +115,7 @@ class ExifFormat : public Format // Return data value interpreted as EXIF_TYPE_LONG. // This is most useful when the type is EXIF_TYPE_LONG and the count is one, // which occurs for multiple specific tags where we need the value. - inline uint32_t toLong() const + uint32_t toLong() const { return data.at(0).value(); } diff --git a/garmin.cc b/garmin.cc index 159d3c02d..1382f9ead 100644 --- a/garmin.cc +++ b/garmin.cc @@ -484,7 +484,7 @@ waypt_read() } } -static int lap_read_nop_cb(int, struct GPS_SWay**) +static int lap_read_nop_cb(int, GPS_SWay**) { return 0; } @@ -864,7 +864,7 @@ waypoint_prepare() extern WaypointList* global_waypoint_list; int icon; - tx_waylist = (struct GPS_SWay**) xcalloc(n,sizeof(*tx_waylist)); + tx_waylist = (GPS_SWay**) xcalloc(n,sizeof(*tx_waylist)); for (i = 0; i < n; i++) { tx_waylist[i] = sane_GPS_Way_New(); @@ -1057,7 +1057,7 @@ route_write() { int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */ - tx_routelist = (struct GPS_SWay**) xcalloc(n,sizeof(GPS_PWay)); + tx_routelist = (GPS_SWay**) xcalloc(n,sizeof(GPS_PWay)); cur_tx_routelist_entry = tx_routelist; for (int i = 0; i < n; i++) { @@ -1104,7 +1104,7 @@ track_prepare() { int32 n = track_waypt_count() + track_count(); - tx_tracklist = (struct GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack)); + tx_tracklist = (GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack)); cur_tx_tracklist_entry = tx_tracklist; for (int i = 0; i < n; i++) { tx_tracklist[i] = GPS_Track_New(); diff --git a/garmin_gpi.h b/garmin_gpi.h index 5594f6ffc..cdc972eb3 100644 --- a/garmin_gpi.h +++ b/garmin_gpi.h @@ -293,11 +293,11 @@ class GarminGPIFormat : public Format static bool compare_wpt_cb(const Waypoint* a, const Waypoint* b); static char compare_strings(const QString& s1, const QString& s2); static writer_data_t* wdata_alloc(); - static void wdata_free(GarminGPIFormat::writer_data_t* data); - static void wdata_add_wpt(GarminGPIFormat::writer_data_t* data, Waypoint* wpt); - void wdata_check(GarminGPIFormat::writer_data_t* data) const; - int wdata_compute_size(GarminGPIFormat::writer_data_t* data) const; - void wdata_write(const GarminGPIFormat::writer_data_t* data) const; + static void wdata_free(writer_data_t* data); + static void wdata_add_wpt(writer_data_t* data, Waypoint* wpt); + void wdata_check(writer_data_t* data) const; + int wdata_compute_size(writer_data_t* data) const; + void wdata_write(const writer_data_t* data) const; void write_category(const char* unused, const unsigned char* image, int image_sz) const; void write_header() const; void enum_waypt_cb(const Waypoint* ref) const; diff --git a/garmin_txt.cc b/garmin_txt.cc index 5fd72a870..8720621a1 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -124,7 +124,7 @@ static constexpr double kGarminUnknownAlt = 1.0e25; static constexpr char kDefaultDateFormat[] = "dd/mm/yyyy"; static constexpr char kDefaultTimeFormat[] = "HH:mm:ss"; -static inline bool is_valid_alt(double alt) +static bool is_valid_alt(double alt) { return (alt != unknown_alt) && (alt < kGarminUnknownAlt); } diff --git a/googletakeout.cc b/googletakeout.cc index d4b82f882..af824ae23 100644 --- a/googletakeout.cc +++ b/googletakeout.cc @@ -48,11 +48,11 @@ static const QList takeout_month_names{ "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" }; -static inline void takeout_fatal(const QString& message) { +static void takeout_fatal(const QString& message) { fatal(FatalMsg() << MYNAME << ": " << message); } -static inline void takeout_warning(const QString& message) { +static void takeout_warning(const QString& message) { Warning() << MYNAME << ": " << message; } diff --git a/igc.cc b/igc.cc index c26814354..ba643762b 100644 --- a/igc.cc +++ b/igc.cc @@ -467,7 +467,7 @@ void IgcFormat::read() int len = end - begin + 1; QString name = extension_definition.mid(4,3); igc_ext_type_t ext = get_ext_type(ext_type); - if (ext != IgcFormat::igc_ext_type_t::ext_rec_unknown) { + if (ext != igc_ext_type_t::ext_rec_unknown) { int factor = get_ext_factor(ext); ext_types_list.append(std::make_tuple(name, ext, begin, len, factor)); supported_extensions.append(name); diff --git a/igc.h b/igc.h index d0672811e..17c6bdaa1 100644 --- a/igc.h +++ b/igc.h @@ -131,17 +131,17 @@ class IgcFormat : public Format rec_bad = 1, // Bad record }; - const QHash igc_extension_map{ - {"ENL", IgcFormat::igc_ext_type_t::ext_rec_enl}, - {"TAS", IgcFormat::igc_ext_type_t::ext_rec_tas}, - {"VAT", IgcFormat::igc_ext_type_t::ext_rec_vat}, - {"OAT", IgcFormat::igc_ext_type_t::ext_rec_oat}, - {"TRT", IgcFormat::igc_ext_type_t::ext_rec_trt}, - {"GSP", IgcFormat::igc_ext_type_t::ext_rec_gsp}, - {"FXA", IgcFormat::igc_ext_type_t::ext_rec_fxa}, - {"SIU", IgcFormat::igc_ext_type_t::ext_rec_siu}, - {"ACZ", IgcFormat::igc_ext_type_t::ext_rec_acz}, - {"GFO", IgcFormat::igc_ext_type_t::ext_rec_gfo}, + const QHash igc_extension_map{ + {"ENL", igc_ext_type_t::ext_rec_enl}, + {"TAS", igc_ext_type_t::ext_rec_tas}, + {"VAT", igc_ext_type_t::ext_rec_vat}, + {"OAT", igc_ext_type_t::ext_rec_oat}, + {"TRT", igc_ext_type_t::ext_rec_trt}, + {"GSP", igc_ext_type_t::ext_rec_gsp}, + {"FXA", igc_ext_type_t::ext_rec_fxa}, + {"SIU", igc_ext_type_t::ext_rec_siu}, + {"ACZ", igc_ext_type_t::ext_rec_acz}, + {"GFO", igc_ext_type_t::ext_rec_gfo}, }; // Will return zero if no match @@ -161,38 +161,38 @@ class IgcFormat : public Format * A factor can never be zero, so this looks good to me. * Be careful. */ - int get_ext_factor(IgcFormat::igc_ext_type_t type) const + int get_ext_factor(igc_ext_type_t type) const { int ret = 0; switch (type) { - case IgcFormat::igc_ext_type_t::ext_rec_enl: + case igc_ext_type_t::ext_rec_enl: ret = 1; break; - case IgcFormat::igc_ext_type_t::ext_rec_tas: + case igc_ext_type_t::ext_rec_tas: ret = 100; break; - case IgcFormat::igc_ext_type_t::ext_rec_vat: + case igc_ext_type_t::ext_rec_vat: ret = 10; break; - case IgcFormat::igc_ext_type_t::ext_rec_oat: + case igc_ext_type_t::ext_rec_oat: ret = 10; break; - case IgcFormat::igc_ext_type_t::ext_rec_trt: + case igc_ext_type_t::ext_rec_trt: ret = 1; break; - case IgcFormat::igc_ext_type_t::ext_rec_gsp: + case igc_ext_type_t::ext_rec_gsp: ret = 100; break; - case IgcFormat::igc_ext_type_t::ext_rec_fxa: + case igc_ext_type_t::ext_rec_fxa: ret = 1; break; - case IgcFormat::igc_ext_type_t::ext_rec_siu: + case igc_ext_type_t::ext_rec_siu: ret = 1; break; - case IgcFormat::igc_ext_type_t::ext_rec_acz: + case igc_ext_type_t::ext_rec_acz: ret = 10; break; - case IgcFormat::igc_ext_type_t::ext_rec_gfo: + case igc_ext_type_t::ext_rec_gfo: ret = 1; break; default: diff --git a/jeeps/gps.h b/jeeps/gps.h index 1efc420d9..951d8263a 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -247,7 +247,7 @@ typedef struct GPS_SCourse_Limits { } GPS_OCourse_Limits, *GPS_PCourse_Limits; -typedef int (*pcb_fn)(int, struct GPS_SWay**); +typedef int (*pcb_fn)(int, GPS_SWay**); #include "jeeps/gpsdevice.h" #include "jeeps/gpssend.h" @@ -270,9 +270,9 @@ extern char gps_save_string[GPS_ARB_LEN]; extern int gps_is_usb; extern int gps_baud_rate; -extern struct COMMANDDATA COMMAND_ID[2]; -extern struct LINKDATA LINK_ID[3]; -extern struct GPS_MODEL_PROTOCOL GPS_MP[]; +extern COMMANDDATA COMMAND_ID[2]; +extern LINKDATA LINK_ID[3]; +extern GPS_MODEL_PROTOCOL GPS_MP[]; extern const char* gps_marine_sym[]; extern const char* gps_land_sym[]; diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index 0eb115939..914b7e1c6 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -7571,7 +7571,7 @@ void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n) trkpt->distance_populated = 0; trkpt->heartrate = 0; trkpt->cadence = 0xff; - *trk = (struct GPS_STrack**) xrealloc(*trk, (*n+1) * sizeof(GPS_PTrack)); + *trk = (GPS_STrack**) xrealloc(*trk, (*n+1) * sizeof(GPS_PTrack)); memmove(&(*trk)[i+1], &(*trk)[i], (*n-i) * sizeof(GPS_PTrack)); (*trk)[i] = trkpt; i++; diff --git a/jeeps/gpscom.cc b/jeeps/gpscom.cc index f15c8f514..6408edf38 100644 --- a/jeeps/gpscom.cc +++ b/jeeps/gpscom.cc @@ -126,7 +126,7 @@ int32 GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way, pcb_fn cb) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(struct GPS_SWay**)) +int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_SWay**)) { int32 ret=0; @@ -1189,7 +1189,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 } /* Create & append course */ - crs = (struct GPS_SCourse**)xrealloc(crs, (n_crs+1) * sizeof(GPS_PCourse)); + crs = (GPS_SCourse**)xrealloc(crs, (n_crs+1) * sizeof(GPS_PCourse)); crs[n_crs] = GPS_Course_New(); if (!crs[n_crs]) { if (clp) xfree(clp); @@ -1203,7 +1203,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 crs[n_crs]->track_index = Unique_Track_Index(crs, n_crs); /* Create & append new lap */ - clp = (struct GPS_SCourse_Lap**) xrealloc(clp, (n_clp+1) * sizeof(GPS_PCourse_Lap)); + clp = (GPS_SCourse_Lap**) xrealloc(clp, (n_clp+1) * sizeof(GPS_PCourse_Lap)); clp[n_clp] = GPS_Course_Lap_New(); if (!clp[n_clp]) { if (clp) xfree(clp); @@ -1218,7 +1218,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 } /* Append new track points */ - ctk = (struct GPS_STrack**) xrealloc(ctk, (n_ctk+n_trk) * sizeof(GPS_PTrack)); + ctk = (GPS_STrack**) xrealloc(ctk, (n_ctk+n_trk) * sizeof(GPS_PTrack)); first_new_ctk = n_ctk; for (i=0; iishdr && (i>=n_trk || trk[i+1]->ishdr)) { @@ -1245,7 +1245,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 /* Convert waypoints to course points by searching closest track point & * append */ - cpt = (struct GPS_SCourse_Point**) xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point)); + cpt = (GPS_SCourse_Point**) xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point)); for (i=0; i replacements; /* Member Functions */ diff --git a/mtk_logger.cc b/mtk_logger.cc index c67605a79..1838a018d 100644 --- a/mtk_logger.cc +++ b/mtk_logger.cc @@ -202,7 +202,7 @@ struct data_item { short rcr; unsigned short timestamp_ms; double distance; - struct sat_info sat_data[32]; + sat_info sat_data[32]; }; struct mtk_loginfo { @@ -235,9 +235,9 @@ static char* OPT_erase_only; /* erase_only ? command option */ static char* OPT_log_enable; /* enable ? command option */ static char* csv_file; /* csv ? command option */ static char* OPT_block_size_kb; /* block_size_kb ? command option */ -static enum MTK_DEVICE_TYPE mtk_device = MTK_LOGGER; +static MTK_DEVICE_TYPE mtk_device = MTK_LOGGER; -static struct mtk_loginfo mtk_info; +static mtk_loginfo mtk_info; const char LIVE_CHAR[4] = {'-', '\\','|','/'}; @@ -796,7 +796,7 @@ static void mtk_read() static route_head* trk_head = nullptr; -static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm) +static int add_trackpoint(int idx, unsigned long bmask, data_item* itm) { auto* trk = new Waypoint; @@ -978,7 +978,7 @@ static void mtk_csv_deinit() } /* Output a single data line in MTK application compatible format - i.e ignore any locale settings... */ -static int csv_line(gbfile* csvFile, int idx, unsigned long bmask, struct data_item* itm) +static int csv_line(gbfile* csvFile, int idx, unsigned long bmask, data_item* itm) { const char* fix_str = ""; if (bmask & (1U< 5) { diff --git a/skytraq.cc b/skytraq.cc index fe4ebb63a..eca79199c 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -581,7 +581,7 @@ SkytraqBase::ECEF_to_LLA(double x, double y, long z, double* lat, double* lon, d } void -SkytraqBase::state_init(struct read_state* pst) +SkytraqBase::state_init(read_state* pst) { auto* track = new route_head; track->rte_name = "SkyTraq tracklog"; @@ -600,7 +600,7 @@ SkytraqBase::state_init(struct read_state* pst) } Waypoint* -SkytraqBase::make_trackpoint(struct read_state* st, double lat, double lon, double alt) const +SkytraqBase::make_trackpoint(read_state* st, double lat, double lon, double alt) const { auto* wpt = new Waypoint; @@ -623,7 +623,7 @@ SkytraqBase::make_trackpoint(struct read_state* st, double lat, double lon, doub #define ITEM_SPEED(item) (item->type_and_speed[1] | ((item->type_and_speed[0] & 0x0F) << 8)) int -SkytraqBase::process_data_item(struct read_state* pst, const item_frame* pitem, int len) const +SkytraqBase::process_data_item(read_state* pst, const item_frame* pitem, int len) const { int res = 0; double lat; @@ -766,7 +766,7 @@ SkytraqBase::process_data_item(struct read_state* pst, const item_frame* pitem, } int /* returns number of bytes processed (terminates on 0xFF i.e. empty or padding bytes) */ -SkytraqBase::process_data_sector(struct read_state* pst, const uint8_t* buf, int len) const +SkytraqBase::process_data_sector(read_state* pst, const uint8_t* buf, int len) const { int plen, ilen; @@ -924,7 +924,7 @@ SkytraqBase::skytraq_read_multiple_sectors(int first_sector, unsigned int sector void SkytraqBase::skytraq_read_tracks() const { - struct read_state st; + read_state st; uint32_t log_wr_ptr; uint16_t sectors_free, sectors_total, /*sectors_used_a, sectors_used_b,*/ sectors_used; int t, rc, got_sectors, total_sectors_read = 0; @@ -1240,7 +1240,7 @@ SkytraqfileFormat::rd_deinit() void SkytraqfileFormat::read() { - struct read_state st; + read_state st; int got_bytes; int opt_first_sector_val = xstrtoi(opt_first_sector, nullptr, 10); int opt_last_sector_val = xstrtoi(opt_last_sector, nullptr, 10); diff --git a/v900.cc b/v900.cc index e11129041..632195221 100644 --- a/v900.cc +++ b/v900.cc @@ -109,7 +109,7 @@ struct one_line_common_start { 1717**,T,090204,062634,31.765528N,035.207730E,772**,0***,0**,2D,SPS ,2.1**,1.9**,1.0**,********* */ struct one_line_advanced_mode { - struct one_line_common_start common; + one_line_common_start common; char fixmode[2]; /* "2D" or "3D" */ char comma10; /* ',' */ char valid[4]; /* "SPS " or "DGPS" */ @@ -130,7 +130,7 @@ struct one_line_advanced_mode { 1*****,T,090404,063401,31.765931N,035.206969E,821**,0***,0**,********* */ struct one_line_basic_mode { - struct one_line_common_start common; + one_line_common_start common; char vox[9]; /* voicetag recorded */ char cr; /* '\r' */ char lf; /* '\n' */ @@ -203,8 +203,8 @@ v900_read() { /* use line buffer large enough to hold either basic or advanced mode lines. */ union { - struct one_line_basic_mode bas; - struct one_line_advanced_mode adv; + one_line_basic_mode bas; + one_line_advanced_mode adv; char text[200]; /* used to read the header line, which is normal text */ } line; int lc = 0; From dfc770ac0a68a0827f89ddf8ef09c5766f16a53c Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 14 Sep 2023 18:09:56 -0600 Subject: [PATCH 016/132] tidy fixes (#1179) * tidy readability-convert-member-functions-to-static * tidy readability-make-member-function-const * kill trailing space --- duplicate.cc | 2 +- exif.cc | 4 ++-- filter_vecs.h | 2 +- gdb.h | 2 +- geo.cc | 2 +- geo.h | 2 +- googletakeout.h | 4 ++-- gpx.cc | 2 +- gtm.cc | 2 +- igc.cc | 6 +++--- igc.h | 10 +++++----- kml.cc | 2 +- kml.h | 2 +- position.cc | 12 ++++++------ util.cc | 4 ++-- vecs.h | 2 +- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/duplicate.cc b/duplicate.cc index e79c1b4e9..dccfad848 100644 --- a/duplicate.cc +++ b/duplicate.cc @@ -97,7 +97,7 @@ void DuplicateFilter::process() .arg(degrees2ddmm(waypointp->latitude), 11, 'f', 3) .arg(degrees2ddmm(waypointp->longitude), 11, 'f', 3); } - + if (snopt) { key.append(waypointp->shortname); } diff --git a/exif.cc b/exif.cc index 25bcd7b06..2e0ba8289 100644 --- a/exif.cc +++ b/exif.cc @@ -209,7 +209,7 @@ ExifFormat::exif_read_str(ExifTag* tag) // Panasonic DMC-TZ10 stores datum with trailing spaces. // Kodak stores zero count ASCII tags. QByteArray buf = (tag->count == 0) ? QByteArray("") : tag->data.at(0).toByteArray(); - // If the bytearray contains internal NULL(s), get rid of the first and + // If the bytearray contains internal NULL(s), get rid of the first and // anything after it. if (auto idx = buf.indexOf('\0'); idx >= 0) { buf = buf.left(idx); @@ -1574,7 +1574,7 @@ ExifFormat::write() exif_put_double(GPS_IFD, GPS_IFD_TAG_TIMESTAMP, 0, dt.time().hour()); exif_put_double(GPS_IFD, GPS_IFD_TAG_TIMESTAMP, 1, dt.time().minute()); exif_put_double(GPS_IFD, GPS_IFD_TAG_TIMESTAMP, 2, - static_cast(dt.time().second()) + + static_cast(dt.time().second()) + static_cast(dt.time().msec())/1000.0); exif_put_str(GPS_IFD, GPS_IFD_TAG_DATESTAMP, CSTR(dt.toString(u"yyyy:MM:dd"))); diff --git a/filter_vecs.h b/filter_vecs.h index 2abe2d366..beaaf0c3e 100644 --- a/filter_vecs.h +++ b/filter_vecs.h @@ -39,7 +39,7 @@ class FilterVecs class fltinfo_t { public: - bool isDynamic() { + bool isDynamic() const { return factory != nullptr; } explicit operator bool() const { diff --git a/gdb.h b/gdb.h index 1e30b7b6c..6697ca592 100644 --- a/gdb.h +++ b/gdb.h @@ -85,7 +85,7 @@ class GdbFormat : public Format * it’s in , a public header. */ QtPrivate::QHashCombine hash; - + seed = hash(seed, c.shortname.toUpper()); seed = hash(seed, c.lat); seed = hash(seed, c.lon); diff --git a/geo.cc b/geo.cc index 808a96121..9baaa5d57 100644 --- a/geo.cc +++ b/geo.cc @@ -33,7 +33,7 @@ #define MYNAME "geo" -void GeoFormat::GeoReadLoc(QXmlStreamReader& reader) const +void GeoFormat::GeoReadLoc(QXmlStreamReader& reader) { Waypoint* wpt = nullptr; QString current_tag; diff --git a/geo.h b/geo.h index 884b47cdd..ae1197702 100644 --- a/geo.h +++ b/geo.h @@ -60,7 +60,7 @@ class GeoFormat : public Format /* Member Functions */ - void GeoReadLoc(QXmlStreamReader& reader) const; + static void GeoReadLoc(QXmlStreamReader& reader); void geo_waypt_pr(const Waypoint*, QXmlStreamWriter& writer); static Geocache::container_t wpt_container(const QString&); diff --git a/googletakeout.h b/googletakeout.h index d1db57593..b3489d928 100644 --- a/googletakeout.h +++ b/googletakeout.h @@ -75,7 +75,7 @@ class GoogleTakeoutFormat : public Format ff_type get_type() const override { - return ff_type_file; + return ff_type_file; } QVector get_cap() const override @@ -86,7 +86,7 @@ class GoogleTakeoutFormat : public Format void rd_init(const QString& fname) override {} void read() override; - + private: /* Constants */ diff --git a/gpx.cc b/gpx.cc index 6d0a4c042..cf404ed60 100644 --- a/gpx.cc +++ b/gpx.cc @@ -981,7 +981,7 @@ GpxFormat::qualifiedName() const * file. So we map from the namespaceUris to the prefixes used in our * hash table. */ - static const QHash tag_ns_prefixes = { + static const QHash tag_ns_prefixes = { {"http://www.garmin.com/xmlschemas/GpxExtensions/v3", "gpxx"}, {"http://www.garmin.com/xmlschemas/TrackPointExtension/v1", "gpxtpx"}, {"http://www.groundspeak.com/cache/1/0", "groundspeak"}, diff --git a/gtm.cc b/gtm.cc index d2bf5fbfe..d4bdca5ef 100644 --- a/gtm.cc +++ b/gtm.cc @@ -31,7 +31,7 @@ #include // for QString #include // for QVector -#include "defs.h" +#include "defs.h" #include "gbfile.h" // for gbfseek, gbfputc, gbfputint32, gbfputflt #include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_WGS84_M #include "src/core/datetime.h" // for DateTime diff --git a/igc.cc b/igc.cc index ba643762b..11b2cfb6f 100644 --- a/igc.cc +++ b/igc.cc @@ -636,7 +636,7 @@ QByteArray IgcFormat::latlon2str(const Waypoint* wpt) return str; } -QByteArray IgcFormat::date2str(const gpsbabel::DateTime& dt) const +QByteArray IgcFormat::date2str(const gpsbabel::DateTime& dt) { QByteArray str = dt.toUTC().toString("ddMMyy").toUtf8(); if (str.size() != 6) { @@ -645,7 +645,7 @@ QByteArray IgcFormat::date2str(const gpsbabel::DateTime& dt) const return str; } -QByteArray IgcFormat::tod2str(const gpsbabel::DateTime& tod) const +QByteArray IgcFormat::tod2str(const gpsbabel::DateTime& tod) { QByteArray str = tod.toUTC().toString("hhmmss").toUtf8(); if (str.size() != 6) { @@ -826,7 +826,7 @@ void IgcFormat::wr_fix_record(const Waypoint* wpt, int pres_alt, int gnss_alt) * @return The number of seconds to add to the GNSS track in order to align * it with the pressure track. */ -int IgcFormat::correlate_tracks(const route_head* pres_track, const route_head* gnss_track) const +int IgcFormat::correlate_tracks(const route_head* pres_track, const route_head* gnss_track) { double alt_diff; double speed; diff --git a/igc.h b/igc.h index 17c6bdaa1..4054a9150 100644 --- a/igc.h +++ b/igc.h @@ -161,7 +161,7 @@ class IgcFormat : public Format * A factor can never be zero, so this looks good to me. * Be careful. */ - int get_ext_factor(igc_ext_type_t type) const + static int get_ext_factor(igc_ext_type_t type) { int ret = 0; switch (type) { @@ -242,9 +242,9 @@ class IgcFormat : public Format void detect_gnss_track(const route_head*); void detect_other_track(const route_head*, int& max_waypt_ct); void get_tracks(const route_head**, const route_head**); - QByteArray latlon2str(const Waypoint*); - QByteArray date2str(const gpsbabel::DateTime&) const; - QByteArray tod2str(const gpsbabel::DateTime&) const; + static QByteArray latlon2str(const Waypoint*); + static QByteArray date2str(const gpsbabel::DateTime&); + static QByteArray tod2str(const gpsbabel::DateTime&); void wr_header(); void wr_task_wpt_name(const Waypoint*, const char*); void wr_task_hdr(const route_head*, unsigned int task_num); @@ -252,7 +252,7 @@ class IgcFormat : public Format void wr_task_tlr(const route_head*); void wr_tasks(); void wr_fix_record(const Waypoint*, int, int); - int correlate_tracks(const route_head*, const route_head*) const; + static int correlate_tracks(const route_head*, const route_head*); void wr_track(); /* Data Members */ diff --git a/kml.cc b/kml.cc index dbf3e28b2..92245bf0a 100644 --- a/kml.cc +++ b/kml.cc @@ -1226,7 +1226,7 @@ QString KmlFormat::kml_gc_mkstar(int rating) } -QString KmlFormat::kml_geocache_get_logs(const Waypoint* wpt) const +QString KmlFormat::kml_geocache_get_logs(const Waypoint* wpt) { QString r; diff --git a/kml.h b/kml.h index d51f190dc..1262fe35c 100644 --- a/kml.h +++ b/kml.h @@ -179,7 +179,7 @@ class KmlFormat : public Format static QString kml_lookup_gc_icon(const Waypoint* waypointp); static const char* kml_lookup_gc_container(const Waypoint* waypointp); static QString kml_gc_mkstar(int rating); - QString kml_geocache_get_logs(const Waypoint* wpt) const; + static QString kml_geocache_get_logs(const Waypoint* wpt); void kml_write_data_element(const QString& name, const QString& value) const; void kml_write_data_element(const QString& name, int value) const; void kml_write_data_element(const QString& name, double value) const; diff --git a/position.cc b/position.cc index fe5d658ca..9060b916c 100644 --- a/position.cc +++ b/position.cc @@ -37,23 +37,23 @@ void PositionFilter::position_runqueue(const WaypointList& waypt_list, int qtype { if (!waypt_list.empty()) { QList qlist; - + for (auto* const waypointp : waypt_list) { qlist.append(WptRecord(waypointp)); } int nelems = qlist.size(); - + for (int i = 0 ; i < nelems ; ++i) { if (!qlist.at(i).deleted) { bool something_deleted = false; - + for (int j = i + 1 ; j < nelems ; ++j) { if (!qlist.at(j).deleted) { double dist = gc_distance(qlist.at(j).wpt->latitude, qlist.at(j).wpt->longitude, qlist.at(i).wpt->latitude, qlist.at(i).wpt->longitude); - + if (dist <= pos_dist) { if (check_time) { qint64 diff_time = std::abs(qlist.at(j).wpt->creation_time.msecsTo(qlist.at(i).wpt->creation_time)); @@ -61,7 +61,7 @@ void PositionFilter::position_runqueue(const WaypointList& waypt_list, int qtype continue; } } - + qlist[j].deleted = true; qlist.at(j).wpt->wpt_flags.marked_for_deletion = 1; something_deleted = true; @@ -75,7 +75,7 @@ void PositionFilter::position_runqueue(const WaypointList& waypt_list, int qtype } } } - + if (something_deleted && (purge_duplicates != nullptr)) { qlist.at(i).wpt->wpt_flags.marked_for_deletion = 1; } diff --git a/util.cc b/util.cc index 0e4d848f4..38b464f3e 100644 --- a/util.cc +++ b/util.cc @@ -351,7 +351,7 @@ make_datetime(QDate date, QTime time, bool is_localtime, bool force_utc, int utc result = date.startOfDay(timespec, offset); #endif } - + return result; } @@ -1066,7 +1066,7 @@ QString grapheme_truncate(const QString& input, unsigned int count) int xstrtoi(const char* str, char** str_end, int base) { - + long value = strtol(str, str_end, base); if (value > INT_MAX) { errno = ERANGE; diff --git a/vecs.h b/vecs.h index e2ccf4829..415f3b402 100644 --- a/vecs.h +++ b/vecs.h @@ -44,7 +44,7 @@ class Vecs class fmtinfo_t { public: - bool isDynamic() { + bool isDynamic() const { return factory != nullptr; } explicit operator bool() const { From bdcb6b1341148796ebc09b7f0d75c838695342d6 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 25 Sep 2023 07:48:19 -0600 Subject: [PATCH 017/132] Remove final remnants of 'exported' (#1146) * Remove final remnants of 'exported' * incorporate review comments in duplicate filter, and remove deleted exported keyword from unicsv doc. --------- Co-authored-by: Robert Lipe --- duplicate.cc | 47 ++------------------------ geocache.h | 1 - gpx.cc | 5 --- reference/duplicate_exported_1.csv | 5 --- reference/duplicate_exported_1~csv.csv | 3 -- reference/duplicate_exported_2.csv | 5 --- reference/duplicate_exported_2~csv.csv | 3 -- testo.d/duplicate.test | 5 --- unicsv.cc | 23 ------------- unicsv.h | 1 - xmldoc/formats/unicsv.xml | 1 - 11 files changed, 2 insertions(+), 97 deletions(-) delete mode 100644 reference/duplicate_exported_1.csv delete mode 100644 reference/duplicate_exported_1~csv.csv delete mode 100644 reference/duplicate_exported_2.csv delete mode 100644 reference/duplicate_exported_2~csv.csv diff --git a/duplicate.cc b/duplicate.cc index dccfad848..252c068e9 100644 --- a/duplicate.cc +++ b/duplicate.cc @@ -21,52 +21,16 @@ #include "duplicate.h" -#include // for stable_sort - -#include // for QDateTime #include // for QList, QList<>::iterator, QList<>::const_iterator #include // for QMultiHash +#include // for qAsConst #include "defs.h" -#include "geocache.h" // for Geocache -#include "src/core/datetime.h" // for DateTime #if FILTERS_ENABLED #define MYNAME "duplicate" -/* - -It looks odd that we have different comparisons for date and index. - If exported if a < b return 1 - if index if a < b return -1 - -The reason is that we want to sort in reverse order by date, but forward -order by index. So if we have four records: - - date index - June 24 0 - June 25 1 - June 25 2 - June 24 3 - -we want to sort them like this: - - date index - June 25 1 - June 25 2 - June 24 0 - June 24 3 - -Thus, the first point we come across is the latest point, but if we -have two points with the same export date/time, we will first see the -one with the smaller index (i.e. the first of those two points that we -came across while importing waypoints.) - -In the (common) case that we have no exported dates, the dates will all -be zero so the sort will end up being an expensive no-op. However, the -complexity of this filter is dominated by other concerns. -*/ void DuplicateFilter::init() { @@ -77,15 +41,8 @@ void DuplicateFilter::init() void DuplicateFilter::process() { - auto wptlist = *global_waypoint_list; - - auto compare_lambda = [](const Waypoint* wa, const Waypoint* wb)->bool { - return wa->gc_data->exported > wb->gc_data->exported; - }; - std::stable_sort(wptlist.begin(), wptlist.end(), compare_lambda); - QMultiHash wpthash; - for (Waypoint* waypointp : wptlist) { + for (Waypoint* waypointp : qAsConst(*global_waypoint_list)) { QString key; if (lcopt) { diff --git a/geocache.h b/geocache.h index 25c491319..e53cc7193 100644 --- a/geocache.h +++ b/geocache.h @@ -114,7 +114,6 @@ class Geocache status_t is_available:2; status_t is_memberonly:2; status_t has_customcoords:2; - gpsbabel::DateTime exported; gpsbabel::DateTime last_found; QString placer; /* Placer name */ int placer_id; /* Placer id */ diff --git a/gpx.cc b/gpx.cc index cf404ed60..9b8c8738f 100644 --- a/gpx.cc +++ b/gpx.cc @@ -1080,11 +1080,6 @@ GpxFormat::fprint_xml_chain(XmlTag* tag, const Waypoint* wpt) const if (tag->child) { fprint_xml_chain(tag->child, wpt); } - if (wpt && wpt->gc_data->exported.isValid() && - tag->tagname.compare(u"groundspeak:cache") == 0) { - writer->writeTextElement(QStringLiteral("time"), - wpt->gc_data->exported.toPrettyString()); - } writer->writeEndElement(); } if (!tag->parentcdata.isEmpty()) { diff --git a/reference/duplicate_exported_1.csv b/reference/duplicate_exported_1.csv deleted file mode 100644 index 4f413592a..000000000 --- a/reference/duplicate_exported_1.csv +++ /dev/null @@ -1,5 +0,0 @@ -No,Latitude,Longitude,Name,Exported -1,40.0,-105.1,"zero",2015/06/24 00:00:00 -1,40.0,-105.2,"one",2015/06/25 00:00:01 -1,40.0,-105.2,"two",2015/06/25 00:00:00 -1,40.0,-105.1,"three",2015/06/24 00:00:01 diff --git a/reference/duplicate_exported_1~csv.csv b/reference/duplicate_exported_1~csv.csv deleted file mode 100644 index bc70f1dfa..000000000 --- a/reference/duplicate_exported_1~csv.csv +++ /dev/null @@ -1,3 +0,0 @@ -No,Latitude,Longitude,Name,Exported -1,40.000000,-105.200000,"one","2015/06/25 00:00:01" -2,40.000000,-105.100000,"three","2015/06/24 00:00:01" diff --git a/reference/duplicate_exported_2.csv b/reference/duplicate_exported_2.csv deleted file mode 100644 index f3f657e9e..000000000 --- a/reference/duplicate_exported_2.csv +++ /dev/null @@ -1,5 +0,0 @@ -No,Latitude,Longitude,Name,Exported -1,40.0,-105.1,"zero",2015/06/24 00:00:02 -1,40.0,-105.2,"one",2015/06/25 00:00:01 -1,40.0,-105.2,"two",2015/06/25 00:00:02 -1,40.0,-105.1,"three",2015/06/24 00:00:01 diff --git a/reference/duplicate_exported_2~csv.csv b/reference/duplicate_exported_2~csv.csv deleted file mode 100644 index 9bd123f45..000000000 --- a/reference/duplicate_exported_2~csv.csv +++ /dev/null @@ -1,3 +0,0 @@ -No,Latitude,Longitude,Name,Exported -1,40.000000,-105.100000,"zero","2015/06/24 00:00:02" -2,40.000000,-105.200000,"two","2015/06/25 00:00:02" diff --git a/testo.d/duplicate.test b/testo.d/duplicate.test index ff8aaa5e4..c6dad28ab 100644 --- a/testo.d/duplicate.test +++ b/testo.d/duplicate.test @@ -7,8 +7,3 @@ gpsbabel -i geo -f ${REFERENCE}/geocaching.loc -o csv -F ${TMPDIR}/filterdupe.cs gpsbabel -i geo -f ${REFERENCE}/geocaching.loc -f ${REFERENCE}/geocaching.loc -x duplicate,shortname \ -o csv -F ${TMPDIR}/filterdupe.csv2 sort_and_compare ${TMPDIR}/filterdupe.csv1 ${TMPDIR}/filterdupe.csv2 - -gpsbabel -i unicsv,utc -f ${REFERENCE}/duplicate_exported_1.csv -x duplicate,location -o unicsv,utc -F ${TMPDIR}/duplicate_exported_1~csv.csv -compare ${REFERENCE}/duplicate_exported_1~csv.csv ${TMPDIR}/duplicate_exported_1~csv.csv -gpsbabel -i unicsv,utc -f ${REFERENCE}/duplicate_exported_2.csv -x duplicate,location -o unicsv,utc -F ${TMPDIR}/duplicate_exported_2~csv.csv -compare ${REFERENCE}/duplicate_exported_2~csv.csv ${TMPDIR}/duplicate_exported_2~csv.csv diff --git a/unicsv.cc b/unicsv.cc index 372fd016d..92ca85043 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -156,7 +156,6 @@ const UnicsvFormat::field_t UnicsvFormat::fields_def[] = { { "diff", fld_gc_diff, kStrAny }, { "arch", fld_gc_is_archived, kStrAny }, { "avail", fld_gc_is_available, kStrAny }, - { "exported", fld_gc_exported, kStrAny }, { "found", fld_gc_last_found, kStrAny }, { "placer_id", fld_gc_placer_id, kStrAny }, { "placer", fld_gc_placer, kStrAny }, @@ -869,7 +868,6 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) case fld_gc_diff: case fld_gc_is_archived: case fld_gc_is_available: - case fld_gc_exported: case fld_gc_last_found: case fld_gc_placer: case fld_gc_placer_id: @@ -907,14 +905,6 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) case fld_gc_is_available: gc_data->is_available = unicsv_parse_status(value); break; - case fld_gc_exported: { - QTime etime; - QDate edate; - etime = unicsv_parse_time(value, edate); - if (edate.isValid() || etime.isValid()) { - gc_data->exported = unicsv_adjust_time(edate, etime, true); - } - } break; case fld_gc_last_found: { QTime ftime; @@ -1251,9 +1241,6 @@ UnicsvFormat::unicsv_waypt_enum_cb(const Waypoint* wpt) if (gc_data->is_available != Geocache::status_t::gs_unknown) { unicsv_outp_flags[fld_gc_is_available] = true; } - if (gc_data->exported.isValid()) { - unicsv_outp_flags[fld_gc_exported] = true; - } if (gc_data->last_found.isValid()) { unicsv_outp_flags[fld_gc_last_found] = true; } @@ -1621,13 +1608,6 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) *fout << unicsv_fieldsep; } } - if (unicsv_outp_flags[fld_gc_exported]) { - if (gc_data) { - unicsv_print_date_time(gc_data->exported); - } else { - *fout << unicsv_fieldsep; - } - } if (unicsv_outp_flags[fld_gc_last_found]) { if (gc_data) { unicsv_print_date_time(gc_data->last_found); @@ -1900,9 +1880,6 @@ UnicsvFormat::write() if (unicsv_outp_flags[fld_gc_is_available]) { *fout << unicsv_fieldsep << "Available"; } - if (unicsv_outp_flags[fld_gc_exported]) { - *fout << unicsv_fieldsep << "Exported"; - } if (unicsv_outp_flags[fld_gc_last_found]) { *fout << unicsv_fieldsep << "Last Found"; } diff --git a/unicsv.h b/unicsv.h index 021e65a89..a8c86664e 100644 --- a/unicsv.h +++ b/unicsv.h @@ -133,7 +133,6 @@ class UnicsvFormat : public Format fld_gc_diff, fld_gc_is_archived, fld_gc_is_available, - fld_gc_exported, fld_gc_last_found, fld_gc_placer, fld_gc_placer_id, diff --git a/xmldoc/formats/unicsv.xml b/xmldoc/formats/unicsv.xml index bad010fdf..297a81a98 100644 --- a/xmldoc/formats/unicsv.xml +++ b/xmldoc/formats/unicsv.xml @@ -29,7 +29,6 @@ diff = Geocache difficulty ele = Elevation (in meters). For feet use "ele ft", "eleft", "ele feet", or "elefeet". e/w = 'e' for eastern hemisphere, 'w' for western - exported = Geocache export date found = Geocache last found date fix = 3d, 2d, etc. gcid = Geocache cache id. This accepts GC-ID ("575006") and GC-Code ("GC1234G"). From 4b3f5b6789510a10a5eeee489ebe86a8ffaeafe0 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:16:22 -0600 Subject: [PATCH 018/132] bump qt build from 6.5.2 to 6.5.3 (#1185) --- .github/workflows/macos.yml | 2 +- .github/workflows/windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 353a38760..31ad8eced 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -33,7 +33,7 @@ jobs: GENERATOR: 'Ninja' RELEASE: true os: macos-12 - - QT_VERSION: '6.5.2' + - QT_VERSION: '6.5.3' XCODE_VERSION: '14.2' GENERATOR: 'Ninja' RELEASE: false diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0a086dc5a..4a5a69411 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -60,7 +60,7 @@ jobs: GENERATOR: 'Visual Studio 17 2022' RELEASE: false os: windows-latest - - QT_VERSION: '6.5.2' + - QT_VERSION: '6.5.3' ARCH: 'amd64' HOST_ARCH: 'amd64' COMPILER: 'msvc2019_64' From 9572f31e6f29f35d456ccb836c79f3515ca8505f Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:26:23 -0600 Subject: [PATCH 019/132] archive docs in CI (#1187) * create document generation workflow * fix webdocdir bug * update checkout * update document for cmake variable renames. --- .github/workflows/gendocs.yml | 59 +++++++++++++++++++++++++++++++++++ CMakeLists.txt | 4 +-- INSTALL | 6 ++-- gbversion.cmake | 2 +- gbversion.h.in | 2 +- tools/build_and_test_cmake.sh | 6 +++- xmldoc/chapters/build.xml | 6 ++-- 7 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/gendocs.yml diff --git a/.github/workflows/gendocs.yml b/.github/workflows/gendocs.yml new file mode 100644 index 000000000..3e9ea55a3 --- /dev/null +++ b/.github/workflows/gendocs.yml @@ -0,0 +1,59 @@ +name: "gendocs" + +on: + push: + branches: [ master ] + schedule: + - cron: '27 4 * * 2' + workflow_dispatch: + inputs: + docversion: + required: false + type: string + default: 'development' + +jobs: + ubuntu: + name: ubuntu Build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - IMAGE: 'jammy' + CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6' + SCRIPT: './tools/build_and_test_cmake.sh' + RELEASE: true + container: + image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_${{ matrix.IMAGE }} + env: + LC_ALL: 'C.UTF-8' + JOB_CMAKE_PREFIX_PATH: ${{ matrix.CMAKE_PREFIX_PATH }} + JOB_SCRIPT: ${{ matrix.SCRIPT }} + JOB_DOCVERSION: ${{ inputs.docversion }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: build_and_test + run: | + # when using containers manually whitelist the checkout directory to allow git commands to work + git config --global --add safe.directory "${GITHUB_WORKSPACE}" + if [ -n "${JOB_CMAKE_PREFIX_PATH}" ]; then + CMAKE_PREFIX_PATH="${JOB_CMAKE_PREFIX_PATH}" + export CMAKE_PREFIX_PATH + fi + "${JOB_SCRIPT}" "${JOB_DOCVERSION:-development}" + + - name: 'Upload Artifacts' + if: matrix.RELEASE + uses: actions/upload-artifact@v3 + with: + name: Documents + path: | + gpsbabel.org/ + gpsbabel.pdf + gpsbabel.html + docbook.css + retention-days: 7 diff --git a/CMakeLists.txt b/CMakeLists.txt index 476883cca..eb8badaaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -477,9 +477,9 @@ endif() get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if((CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) AND NOT _isMultiConfig) - set(WEB "gpsbabel.org" CACHE PATH "Path where the documentation will be stored for www.gpsbabel.org.") + set(GPSBABEL_WEB "gpsbabel.org" CACHE PATH "Path where the documentation will be stored for www.gpsbabel.org.") add_custom_target(gpsbabel.org - ${CMAKE_SOURCE_DIR}/tools/make_gpsbabel_org.sh ${WEB} ${DOCVERSION} + ${CMAKE_SOURCE_DIR}/tools/make_gpsbabel_org.sh ${GPSBABEL_WEB} ${GPSBABEL_DOCVERSION} DEPENDS gpsbabel gpsbabel.pdf VERBATIM USES_TERMINAL) diff --git a/INSTALL b/INSTALL index d2de7f464..f6ea5c7cb 100644 --- a/INSTALL +++ b/INSTALL @@ -71,16 +71,16 @@ GPSBABEL_EXTRA_LINK_LIBRARIES:STRING GPSBABEL_EXTRA_LINK_OPTIONS:STRING Extra link options when building the target gpsbabel. -DOCVERSION:STRING=... +GPSBABEL_DOCVERSION:STRING=... string appended to documentation location for www.gpsbabel.org. The default value is the version string, e.g. "1.7.0". This is used by the gpsbabel.org target, you are unlikely to need it unless you are maintaining www.gpsbabel.org. -WEB:STRING=DIR +GPSBABEL_WEB:STRING=DIR Path where the documentation will be stored for www.gpsbabel.org. This is used by the gpsbabel.org target, you are unlikely to need it unless you are - maintaining www.gpsbabel.org. The default location is "../babelweb" + maintaining www.gpsbabel.org. The default location is "gpsbabel.org". Targets: diff --git a/gbversion.cmake b/gbversion.cmake index 6a7433649..1a06dbc44 100644 --- a/gbversion.cmake +++ b/gbversion.cmake @@ -35,4 +35,4 @@ endif() string(TIMESTAMP GB.COPYRIGHT_YEAR "%Y" UTC) # may be overridden on cmake command line -set(DOCVERSION ${GB.VERSION} CACHE STRING "String appended to documentation location for www.gpsbabel.org.") +set(GPSBABEL_DOCVERSION ${GB.VERSION} CACHE STRING "String appended to documentation location for www.gpsbabel.org.") diff --git a/gbversion.h.in b/gbversion.h.in index 5334e826c..cb3419d67 100644 --- a/gbversion.h.in +++ b/gbversion.h.in @@ -16,5 +16,5 @@ #define VERSION "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@" constexpr char kVersionSHA[] = "@GB.SHA@"; constexpr char kVersionDate[] = "@GB.DATE@"; -#define WEB_DOC_DIR "https://www.gpsbabel.org/htmldoc-@DOCVERSION@" +#define WEB_DOC_DIR "https://www.gpsbabel.org/htmldoc-@GPSBABEL_DOCVERSION@" #endif diff --git a/tools/build_and_test_cmake.sh b/tools/build_and_test_cmake.sh index 1cee99021..acc0118ed 100755 --- a/tools/build_and_test_cmake.sh +++ b/tools/build_and_test_cmake.sh @@ -15,7 +15,11 @@ git --no-pager log -n 1 # build and test keeping output within the pwd. export GBTEMP=$(pwd)/gbtemp mkdir -p "$GBTEMP" -cmake . -G Ninja -DCMAKE_BUILD_TYPE=Release +if [ -n "$1" ]; then + cmake . -G Ninja -DCMAKE_BUILD_TYPE=Release -DGPSABEL_DOCVERSION="$1" +else + cmake . -G Ninja -DCMAKE_BUILD_TYPE=Release +fi # As of 2018-10, all the virtualized travis build images are two cores per: # https://docs.travis-ci.com/user/reference/overview/ # We'll be slightly abusive on CPU knowing that I/O is virtualized. diff --git a/xmldoc/chapters/build.xml b/xmldoc/chapters/build.xml index e0839d800..83434456e 100644 --- a/xmldoc/chapters/build.xml +++ b/xmldoc/chapters/build.xml @@ -289,7 +289,7 @@ distributed. The Qt provided translations still need to be distributed. - DOCVERSION + GPSBABEL_DOCVERSION string appended to documentation location for www.gpsbabel.org. The default @@ -300,12 +300,12 @@ www.gpsbabel.org. - WEB + GPSBABEL_WEB Path where the documentation will be stored for www.gpsbabel.org. This is used by the gpsbabel.org target, you are unlikely to need it unless you are -maintaining www.gpsbabel.org. The default location is "../babelweb" +maintaining www.gpsbabel.org. The default location is "gpsbabel.org". From 007c0c1ac64daede1df9454335fb9129ef4e7e57 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:51:46 -0600 Subject: [PATCH 020/132] rc1 for release 1.9.0 (#1186) --- gbversion.cmake | 4 +- gui/aboutui.ui | 2 +- gui/coretool/core_strings.h | 287 +------- gui/coretool/gpsbabel_de.qm | Bin 30340 -> 19628 bytes gui/coretool/gpsbabel_de.ts | 1185 +++++++++++-------------------- gui/coretool/gpsbabel_es.qm | Bin 31488 -> 20236 bytes gui/coretool/gpsbabel_es.ts | 1188 +++++++++++-------------------- gui/coretool/gpsbabel_fr.qm | Bin 15304 -> 12747 bytes gui/coretool/gpsbabel_fr.ts | 1341 +++++++++-------------------------- gui/coretool/gpsbabel_hu.qm | Bin 13943 -> 11630 bytes gui/coretool/gpsbabel_hu.ts | 1341 +++++++++-------------------------- gui/coretool/gpsbabel_it.qm | Bin 15550 -> 12431 bytes gui/coretool/gpsbabel_it.ts | 1321 +++++++++------------------------- gui/coretool/gpsbabel_ru.qm | Bin 45490 -> 31942 bytes gui/coretool/gpsbabel_ru.ts | 1109 +++++++++++------------------ gui/gpsbabelfe_de.qm | Bin 56201 -> 55543 bytes gui/gpsbabelfe_de.ts | 222 +++--- gui/gpsbabelfe_es.qm | Bin 55368 -> 54720 bytes gui/gpsbabelfe_es.ts | 222 +++--- gui/gpsbabelfe_fr.qm | Bin 1957 -> 1967 bytes gui/gpsbabelfe_fr.ts | 226 +++--- gui/gpsbabelfe_hu.qm | Bin 1228 -> 1238 bytes gui/gpsbabelfe_hu.ts | 226 +++--- gui/gpsbabelfe_it.qm | Bin 55880 -> 55210 bytes gui/gpsbabelfe_it.ts | 222 +++--- gui/gpsbabelfe_ru.qm | Bin 69008 -> 68505 bytes gui/gpsbabelfe_ru.ts | 224 +++--- reference/help.txt | 2 +- reference/usage.txt | 2 +- 29 files changed, 3102 insertions(+), 6022 deletions(-) diff --git a/gbversion.cmake b/gbversion.cmake index 1a06dbc44..dfad1ac24 100644 --- a/gbversion.cmake +++ b/gbversion.cmake @@ -14,14 +14,14 @@ # By defining the version here we minimize the number of locations # containing the definition to gbversion.pri and gbversion.cmake. -set(GB.VERSION 1.8.0) # also change in gbversion.pri +set(GB.VERSION 1.9.0) string(REPLACE "." ";" VERSION_COMPONENTS ${GB.VERSION}) list(GET VERSION_COMPONENTS 0 GB.MAJOR) list(GET VERSION_COMPONENTS 1 GB.MINOR) list(GET VERSION_COMPONENTS 2 GB.MICRO) # Increase GB.BUILD for a new release (why? Where is this ever used?) # A: it's used by win32/gpsbabel.rc which includes gbversion.h -set(GB.BUILD 32 CACHE STRING "Fourth component of Windows VERSIONINFO resource FILEVERSION and PRODUCTVERSION parameters.") +set(GB.BUILD 33 CACHE STRING "Fourth component of Windows VERSIONINFO resource FILEVERSION and PRODUCTVERSION parameters.") set(GB.PACKAGE_RELEASE "" CACHE STRING "String to append to VERSION tuple.") # .e.g. "-beta20190413" set(GB.SHA $ENV{GITHUB_SHA}) if(DEFINED ENV{GITHUB_SHA}) diff --git a/gui/aboutui.ui b/gui/aboutui.ui index b96ed8495..d8a501d57 100644 --- a/gui/aboutui.ui +++ b/gui/aboutui.ui @@ -83,7 +83,7 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2023 Robert Lipe</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> diff --git a/gui/coretool/core_strings.h b/gui/coretool/core_strings.h index f71707686..b72f97206 100644 --- a/gui/coretool/core_strings.h +++ b/gui/coretool/core_strings.h @@ -1,12 +1,3 @@ -QT_TRANSLATE_NOOP("core","Brauniger IQ Series Barograph Download") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Cambridge/Winpilot glider software") QT_TRANSLATE_NOOP("core","Columbus/Visiontac V900 files (.csv)") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") @@ -15,6 +6,7 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","Comma separated values") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") @@ -23,6 +15,7 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","Data Logger iBlue747 csv") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") @@ -31,38 +24,17 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","Data Logger iBlue757 csv") -QT_TRANSLATE_NOOP("core","DeLorme GPL") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","DeLorme Street Atlas Plus") -QT_TRANSLATE_NOOP("core","Keep turns if simplify filter is used") -QT_TRANSLATE_NOOP("core","Only read turns; skip all other points") -QT_TRANSLATE_NOOP("core","Split into multiple routes at turns") -QT_TRANSLATE_NOOP("core","Read control points as waypoint/route/none") -QT_TRANSLATE_NOOP("core","Synthesize track times") -QT_TRANSLATE_NOOP("core","DeLorme Street Atlas Route") -QT_TRANSLATE_NOOP("core","Destinator Itineraries (.dat)") -QT_TRANSLATE_NOOP("core","Destinator Points of Interest (.dat)") -QT_TRANSLATE_NOOP("core","Destinator TrackLogs (.dat)") -QT_TRANSLATE_NOOP("core","EasyGPS binary format") QT_TRANSLATE_NOOP("core","Set waypoint name to source filename") QT_TRANSLATE_NOOP("core","Time-frame (in seconds)") QT_TRANSLATE_NOOP("core","Locate waypoint for tagging by this name") QT_TRANSLATE_NOOP("core","!OVERWRITE! the original file. Default=N") +QT_TRANSLATE_NOOP("core","Image Offset Time (+HH:MM or -HH:MM)") QT_TRANSLATE_NOOP("core","Embedded Exif-GPS data (.jpg)") -QT_TRANSLATE_NOOP("core","Time zone ID") -QT_TRANSLATE_NOOP("core","Energympro GPS training watch") -QT_TRANSLATE_NOOP("core","Enigma binary waypoint file (.ert)") QT_TRANSLATE_NOOP("core","Source for name field in .dbf") QT_TRANSLATE_NOOP("core","Source for URL field in .dbf") QT_TRANSLATE_NOOP("core","ESRI shapefile") -QT_TRANSLATE_NOOP("core","F90G Automobile DVR GPS log file") QT_TRANSLATE_NOOP("core","(integer sec or 'auto') Barograph to GPS time diff") QT_TRANSLATE_NOOP("core","FAI/IGC Flight Recorder Data Format") QT_TRANSLATE_NOOP("core","Read all points even if latitude or longitude is missing") @@ -75,25 +47,7 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","FlySight GPS File") -QT_TRANSLATE_NOOP("core","Default speed for waypoints (knots/hr)") -QT_TRANSLATE_NOOP("core","Split input into separate files") -QT_TRANSLATE_NOOP("core","Franson GPSGate Simulation") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Fugawi") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","Garmin 301 Custom position and heartrate") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") @@ -102,8 +56,8 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","Garmin G1000 datalog input filter file") -QT_TRANSLATE_NOOP("core","Garmin Logbook XML") QT_TRANSLATE_NOOP("core","Default category on output (1..16)") QT_TRANSLATE_NOOP("core","Bitmap of categories") QT_TRANSLATE_NOOP("core","Version of gdb file to generate (1..3)") @@ -127,6 +81,7 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","Garmin POI database") QT_TRANSLATE_NOOP("core","Enable alerts on speed or proximity distance") QT_TRANSLATE_NOOP("core","Use specified bitmap on output") @@ -153,6 +108,7 @@ QT_TRANSLATE_NOOP("core","Sync GPS time to computer time") QT_TRANSLATE_NOOP("core","Category number to use for written waypoints") QT_TRANSLATE_NOOP("core","Bitmap of categories") QT_TRANSLATE_NOOP("core","Speed in bits per second of serial port (baud=9600)") +QT_TRANSLATE_NOOP("core","override codec to use for device") QT_TRANSLATE_NOOP("core","Garmin serial/USB protocol") QT_TRANSLATE_NOOP("core","Write course rather than history, default yes") QT_TRANSLATE_NOOP("core","Sport: Biking (deflt), Running, MultiSport, Other") @@ -160,19 +116,8 @@ QT_TRANSLATE_NOOP("core","Garmin Training Center (.tcx/.crs/.hst/.xml)") QT_TRANSLATE_NOOP("core","Default icon name") QT_TRANSLATE_NOOP("core","Omit Placer name") QT_TRANSLATE_NOOP("core","Geocaching.com .loc") -QT_TRANSLATE_NOOP("core","Geogrid-Viewer ascii overlay file (.ovl)") -QT_TRANSLATE_NOOP("core","Geogrid-Viewer binary overlay file (.ovl)") -QT_TRANSLATE_NOOP("core","Geogrid-Viewer tracklogs (.log)") QT_TRANSLATE_NOOP("core","Compact Output. Default is off.") QT_TRANSLATE_NOOP("core","GeoJson") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","GEOnet Names Server (GNS)") QT_TRANSLATE_NOOP("core","Erase device data after download") QT_TRANSLATE_NOOP("core","Only erase device data, do not download anything") QT_TRANSLATE_NOOP("core","GlobalSat DG-100/BT-335 Download") @@ -185,7 +130,6 @@ QT_TRANSLATE_NOOP("core","Dump raw data to this file") QT_TRANSLATE_NOOP("core","Dump raw data to this file") QT_TRANSLATE_NOOP("core","Time zone ID") QT_TRANSLATE_NOOP("core","GlobalSat GH625XT GPS training watch") -QT_TRANSLATE_NOOP("core","Google Directions XML") QT_TRANSLATE_NOOP("core","Default icon name") QT_TRANSLATE_NOOP("core","Export linestrings for tracks and routes") QT_TRANSLATE_NOOP("core","Export placemarks for tracks and routes") @@ -202,7 +146,7 @@ QT_TRANSLATE_NOOP("core","Retain at most this number of position points (0 = un QT_TRANSLATE_NOOP("core","Rotate colors for tracks and routes (default automatic)") QT_TRANSLATE_NOOP("core","Precision of coordinates, number of decimals") QT_TRANSLATE_NOOP("core","Google Earth (Keyhole) Markup Language") -QT_TRANSLATE_NOOP("core","Google Navigator Tracklines (.trl)") +QT_TRANSLATE_NOOP("core","Google Takeout Location History") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") @@ -210,6 +154,7 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","GPS Tracking Key Pro text") QT_TRANSLATE_NOOP("core","GPS TrackMaker") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") @@ -219,6 +164,7 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","GPSBabel arc filter file") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") @@ -227,6 +173,7 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","GpsDrive Format") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") @@ -235,6 +182,7 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","GpsDrive Format for Tracks") QT_TRANSLATE_NOOP("core","Length of generated shortnames") QT_TRANSLATE_NOOP("core","No whitespace in generated shortnames") @@ -245,8 +193,6 @@ QT_TRANSLATE_NOOP("core","Add info (depth) as Humminbird extension") QT_TRANSLATE_NOOP("core","Add info (depth) as Garmin extension") QT_TRANSLATE_NOOP("core","Precision of elevations, number of decimals") QT_TRANSLATE_NOOP("core","GPX XML") -QT_TRANSLATE_NOOP("core","HikeTech") -QT_TRANSLATE_NOOP("core","Holux (gm-100) .wpo Format") QT_TRANSLATE_NOOP("core","MTK compatible CSV output file") QT_TRANSLATE_NOOP("core","Holux M-241 (MTK based) Binary File Format") QT_TRANSLATE_NOOP("core","Erase device data after download") @@ -263,44 +209,6 @@ QT_TRANSLATE_NOOP("core","Units for altitude (f)eet or (m)etres") QT_TRANSLATE_NOOP("core","HTML Output") QT_TRANSLATE_NOOP("core","Humminbird tracks (.ht)") QT_TRANSLATE_NOOP("core","Humminbird waypoints and routes (.hwr)") -QT_TRANSLATE_NOOP("core","Index of track to write (if more than one in source)") -QT_TRANSLATE_NOOP("core","IGN Rando track files") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","iGo Primo points of interest (.upoi)") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","iGO2008 points of interest (.upoi)") -QT_TRANSLATE_NOOP("core","Track identification number") -QT_TRANSLATE_NOOP("core","Track title") -QT_TRANSLATE_NOOP("core","Track description") -QT_TRANSLATE_NOOP("core","IGO8 .trk") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Kompass (DAV) Track (.tk)") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Kompass (DAV) Waypoints (.wp)") QT_TRANSLATE_NOOP("core","(USR input) Ignore event marker icons on read") QT_TRANSLATE_NOOP("core","(USR output) Treat waypoints as icons on write") QT_TRANSLATE_NOOP("core","(USR output) Merge into one segmented trail") @@ -310,66 +218,6 @@ QT_TRANSLATE_NOOP("core","(USR output) Output file title string") QT_TRANSLATE_NOOP("core","(USR output) Device serial number") QT_TRANSLATE_NOOP("core","(USR output) Output file content description") QT_TRANSLATE_NOOP("core","Lowrance USR") -QT_TRANSLATE_NOOP("core","Default icon name") -QT_TRANSLATE_NOOP("core","Max number of comments to write (maxcmts=200)") -QT_TRANSLATE_NOOP("core","Magellan SD files (as for eXplorist)") -QT_TRANSLATE_NOOP("core","Default icon name") -QT_TRANSLATE_NOOP("core","Max number of comments to write (maxcmts=200)") -QT_TRANSLATE_NOOP("core","Magellan SD files (as for Meridian)") -QT_TRANSLATE_NOOP("core","Default icon name") -QT_TRANSLATE_NOOP("core","Max number of comments to write (maxcmts=200)") -QT_TRANSLATE_NOOP("core","Numeric value of bitrate (baud=4800)") -QT_TRANSLATE_NOOP("core","Suppress use of handshaking in name of speed") -QT_TRANSLATE_NOOP("core","Delete all waypoints") -QT_TRANSLATE_NOOP("core","Magellan serial protocol") -QT_TRANSLATE_NOOP("core","MagicMaps IK3D project file (.ikt)") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Mainnav") -QT_TRANSLATE_NOOP("core","Include only via stations in route") -QT_TRANSLATE_NOOP("core","Map&Guide 'TourExchangeFormat' XML") -QT_TRANSLATE_NOOP("core","MapAsia track file (.tr7)") -QT_TRANSLATE_NOOP("core","Mapbar (China) navigation track for Sonim Xp3300") -QT_TRANSLATE_NOOP("core","Mapfactor Navigator") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Mapopolis.com Mapconverter CSV") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","MapTech Exchange Format") -QT_TRANSLATE_NOOP("core","Speed in bits per second of serial port (autodetect=0)") -QT_TRANSLATE_NOOP("core","Download logged fixes") -QT_TRANSLATE_NOOP("core","Erase device data after download") -QT_TRANSLATE_NOOP("core","Show device status") -QT_TRANSLATE_NOOP("core","Enable logging after download") -QT_TRANSLATE_NOOP("core","MediaTek Locus") -QT_TRANSLATE_NOOP("core","Write items 'locked' [default no]") -QT_TRANSLATE_NOOP("core","Write items 'visible' [default yes]") -QT_TRANSLATE_NOOP("core","Write files with internal version [n]") -QT_TRANSLATE_NOOP("core","Memory-Map Navigator overlay files (.mmo)") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Microsoft Streets and Trips 2002-2007") QT_TRANSLATE_NOOP("core","Baud rate used for download") QT_TRANSLATE_NOOP("core","Dump raw data to this file") QT_TRANSLATE_NOOP("core","Erase device data after download") @@ -389,19 +237,6 @@ QT_TRANSLATE_NOOP("core","MiniHomer, a skyTraq Venus 6 based logger (download tr QT_TRANSLATE_NOOP("core","Garmin Mobile XT ([ATRK]/STRK)") QT_TRANSLATE_NOOP("core","Track name processing option ([0]-nrm/1-ign)") QT_TRANSLATE_NOOP("core","Mobile Garmin XT Track files") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Motoactiv CSV") -QT_TRANSLATE_NOOP("core","Index of route to write (if more than one in source)") -QT_TRANSLATE_NOOP("core","New name for the route") -QT_TRANSLATE_NOOP("core","Radius of our big earth (default 6371000 meters)") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","Motorrad Routenplaner (Map&Guide) .bcr files") QT_TRANSLATE_NOOP("core","MTK compatible CSV output file") QT_TRANSLATE_NOOP("core","MTK Logger (iBlue 747,...) Binary File Format") QT_TRANSLATE_NOOP("core","Erase device data after download") @@ -410,45 +245,10 @@ QT_TRANSLATE_NOOP("core","Enable logging after download") QT_TRANSLATE_NOOP("core","MTK compatible CSV output file") QT_TRANSLATE_NOOP("core","Size of blocks in KB to request from device") QT_TRANSLATE_NOOP("core","MTK Logger (iBlue 747,Qstarz BT-1000,...) download") -QT_TRANSLATE_NOOP("core","MyNav TRC format") QT_TRANSLATE_NOOP("core","Datum (default=NAD27)") QT_TRANSLATE_NOOP("core","National Geographic Topo .tpg (waypoints)") QT_TRANSLATE_NOOP("core","National Geographic Topo 2.x .tpo") QT_TRANSLATE_NOOP("core","National Geographic Topo 3.x/4.x .tpo") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Navigon Waypoints") -QT_TRANSLATE_NOOP("core","Delete all track points") -QT_TRANSLATE_NOOP("core","Delete all routes") -QT_TRANSLATE_NOOP("core","Delete all waypoints") -QT_TRANSLATE_NOOP("core","Clear the datalog") -QT_TRANSLATE_NOOP("core","Read from datalogger buffer") -QT_TRANSLATE_NOOP("core","Command unit to power itself down") -QT_TRANSLATE_NOOP("core","NaviGPS GT-11/BGT-11 Download") -QT_TRANSLATE_NOOP("core","NaviGPS GT-31/BGT-31 datalogger (.sbp)") -QT_TRANSLATE_NOOP("core","NaviGPS GT-31/BGT-31 SiRF binary logfile (.sbn)") -QT_TRANSLATE_NOOP("core","Navitel binary track (.bin)") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Navitrak DNA marker format") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","NIMA/GNIS Geographic Names File") QT_TRANSLATE_NOOP("core","Max length of waypoint name to write") QT_TRANSLATE_NOOP("core","Read/write GPRMC sentences") QT_TRANSLATE_NOOP("core","Read/write GPGGA sentences") @@ -462,8 +262,6 @@ QT_TRANSLATE_NOOP("core","Speed in bits per second of serial port (baud=4800)") QT_TRANSLATE_NOOP("core","Write tracks for Gisteq Phototracker") QT_TRANSLATE_NOOP("core","Accept position fixes in gpgga marked invalid") QT_TRANSLATE_NOOP("core","NMEA 0183 sentences") -QT_TRANSLATE_NOOP("core","Compact binary representation") -QT_TRANSLATE_NOOP("core","Nokia Landmark Exchange") QT_TRANSLATE_NOOP("core","Write additional way tag key/value pairs") QT_TRANSLATE_NOOP("core","Write additional node tag key/value pairs") QT_TRANSLATE_NOOP("core","Use this value as custom created_by value") @@ -481,24 +279,6 @@ QT_TRANSLATE_NOOP("core","Unit used in proximity values") QT_TRANSLATE_NOOP("core","codec to use for reading and writing strings (default windows-1252)") QT_TRANSLATE_NOOP("core","OziExplorer") QT_TRANSLATE_NOOP("core","Qstarz BL-1000") -QT_TRANSLATE_NOOP("core","Default location") -QT_TRANSLATE_NOOP("core","Raymarine Waypoint File (.rwf)") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","Ricoh GPS Log File") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","See You flight analysis data") QT_TRANSLATE_NOOP("core","Erase device data after download") QT_TRANSLATE_NOOP("core","Set location finder target location as lat,lng") QT_TRANSLATE_NOOP("core","Configure logging parameter as tmin:tmax:dmin:dmax") @@ -522,7 +302,6 @@ QT_TRANSLATE_NOOP("core","GPS time at position video_time (hhmmss[.sss], default QT_TRANSLATE_NOOP("core","GPS date at position video_time (yyyymmdd, default is first timestamp of track)") QT_TRANSLATE_NOOP("core","Format for subtitles") QT_TRANSLATE_NOOP("core","SubRip subtitles for video mapping (.srt)") -QT_TRANSLATE_NOOP("core","Swiss Map 25/50/100 (.xol)") QT_TRANSLATE_NOOP("core","Max synthesized shortname length") QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") @@ -530,8 +309,8 @@ QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") QT_TRANSLATE_NOOP("core","Use shortname instead of description") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") +QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") QT_TRANSLATE_NOOP("core","Tab delimited fields useful for OpenOffice") -QT_TRANSLATE_NOOP("core","Teletype [ Get Jonathon Johnson to describe") QT_TRANSLATE_NOOP("core","Suppress separator lines between waypoints") QT_TRANSLATE_NOOP("core","Encrypt hints using ROT13") QT_TRANSLATE_NOOP("core","Include groundspeak logs if present") @@ -539,33 +318,6 @@ QT_TRANSLATE_NOOP("core","Degrees output as 'ddd', 'dmm'(default) or 'dms'") QT_TRANSLATE_NOOP("core","Units for altitude (f)eet or (m)etres") QT_TRANSLATE_NOOP("core","Write each waypoint in a separate file") QT_TRANSLATE_NOOP("core","Textual Output") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","TomTom Itineraries (.itn)") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","TomTom Places Itineraries (.itn)") -QT_TRANSLATE_NOOP("core","Max synthesized shortname length") -QT_TRANSLATE_NOOP("core","Allow whitespace synth. shortnames") -QT_TRANSLATE_NOOP("core","UPPERCASE synth. shortnames") -QT_TRANSLATE_NOOP("core","Make synth. shortnames unique") -QT_TRANSLATE_NOOP("core","Basename prepended to URL on output") -QT_TRANSLATE_NOOP("core","Use shortname instead of description") -QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") -QT_TRANSLATE_NOOP("core","TomTom POI file (.asc)") -QT_TRANSLATE_NOOP("core","TomTom POI file (.ov2)") -QT_TRANSLATE_NOOP("core","Index of track (if more than one in source)") -QT_TRANSLATE_NOOP("core","TrackLogs digital mapping (.trl)") QT_TRANSLATE_NOOP("core","GPS datum (def. WGS 84)") QT_TRANSLATE_NOOP("core","Write position using this grid.") QT_TRANSLATE_NOOP("core","Write timestamps with offset x to UTC time") @@ -574,14 +326,3 @@ QT_TRANSLATE_NOOP("core","Write filename(s) from input session(s)") QT_TRANSLATE_NOOP("core","Universal csv with field structure in first line") QT_TRANSLATE_NOOP("core","Encrypt hints using ROT13") QT_TRANSLATE_NOOP("core","Vcard Output (for iPod)") -QT_TRANSLATE_NOOP("core","Wintec TES file") -QT_TRANSLATE_NOOP("core","Wintec WBT-100/200 Binary File Format") -QT_TRANSLATE_NOOP("core","Erase device data after download") -QT_TRANSLATE_NOOP("core","Wintec WBT-100/200 GPS Download") -QT_TRANSLATE_NOOP("core","Wintec WBT-201/G-Rays 2 Binary File Format") -QT_TRANSLATE_NOOP("core","Appends the input to a backup file") -QT_TRANSLATE_NOOP("core","Only waypoints that are not the backup file") -QT_TRANSLATE_NOOP("core","XAiOX iTrackU Logger") -QT_TRANSLATE_NOOP("core","Appends the input to a backup file") -QT_TRANSLATE_NOOP("core","Only waypoints that are not the backup file") -QT_TRANSLATE_NOOP("core","XAiOX iTrackU Logger Binary File Format") diff --git a/gui/coretool/gpsbabel_de.qm b/gui/coretool/gpsbabel_de.qm index 35ffebf6cdc3365b7da6187edc55e70dc83df1d0..fea44efda62f975c7177d5562c08d496d0f05531 100644 GIT binary patch delta 1285 zcmWktdr%a09RK|GaeI5Ww=1BB3aC8fArCJ|4fIg(1W_|F6$Kvzo}=Z6h7U;bCdHJ| z24THHMw>)v7|qmik#xi`(FhVte2g0A+Xhn`#E-5`SUZ$pQ5LC9~JO0tUA-*JTypir9j*YQXh1`ygc$5aM9&ON1M?niZFY0Ye^o z*mmz}U`#WsImQuiEo+(nK9CZ`dL6^*d4)6cp+MA9&U~AI-YVy0{{+A>nVVTji$9&p-*|Ua~=^o%G zg)di}1pH!zL%H_>+gRa5)fHesqVRp-1HgBK@F3d-Oj;U%CuN6y1$bjXPSks4Zt`O^&JO^Sr#q(!&0rmi~txt$& zwOrNVEWchMaLmm$V?lv9Ipm{(F&!+|U!%|dK91$;&oJ(~eDOqZGa~+60DYe|( z1rJjHkj@no(8xv7_0wc|T%q)+sSpT#YOdHwnTyEMe@b6*n){E8HIT86DAps}r%^`HkA52R))hkIor@~+Z&>tj;vhQwCA{{cN-9LW$@?TS??7D%}p- zzIKX;UA8rO;^~94!FK*CEs`$U9wm_VLsC^WoidLJRRdS~k+ofFklhU=Sk&<2uYlxS zHM58aB~+>Ne72C~L)GlL^#1l5HT$<_a^S4$o?A`l&Zw2oHjvd(YW+74sN6Tz_P-vI zz^m%>o%yscQJw#flax3EwD<o5yPvtuuj9ZtXxy zF*$HYJG^5e;P25IzpJ9_)}eK_(tJ?9_M+el5WII8Fgers*VG~!$u^DCv--6dc|HdP zBijEq(=!Jh)AtSTFs=p_^Tz&QnKNR-HgQH>#Lvt)8?})$GGcw1elxDy$Z_;A<63+) zr#FmwVz`o8dHvb=mAY@LSI?Mu#2A`(kLe*(x7Dth#*Fsq{Wzm%W~5-;%F5x4q?~l7 hmoKO=3KyPW#?ibFC8PYKX@XIlbr>}``Y z{o2oHkJ*`bzu!Cl-1lkAwXa*ETfX91cKTPJJ$7bQ?c;~6d$R zi6-kUrH@n)E$gwIx8w&z*2gWCcfN=FS6VLki-Sa)4qJMo-J6KIbW8vD97H+umT?U? zNPU(=J3mcy*^L(2xt^%C%c49B!Me{_7H$CJmP3{+AG@2#)oZz-Ge)$n(sJXm$H4Gi z%bj1!A?kVGa&p8)q>NhL?^r|R&Ce;!T}^c1s+__XL3iYi99va4(ePAGbo^E@bljH{ ziQs+rl{q*6nhBrI`OJGNG*@!&`obonsataHuG~Yk_IS?SyIS!5jhuHrc@t56B)4$u z6j4KAZsh@Jp0_Ty>c|qJ1GnYYfAR*RzW>N|HV26)mOGXMhSR5VKUM=lF8NaK$DX~G zsOg1h?&)Xqh}^Zge|P~8EI*!i@aF4?dhg7;?o$gyT3+7m!AFRyFUz~{@XJK!wdQ^0 zw(k?wd^_(OwXeXmU(NgRbI-$KRe3+%_7KrnP2MX9`iW+@<-Hbr3EwZvd*{X#M8zkp zmNM{J|CH6yfajNwSyweSz{SxUtj*tr33tv}FWwpRTFiTS?BH0 zX!@}A==nAx`_0xnS)d}1^&aorL<3J-@BJ(U*jQpc_16_dZMoJbzWxcKx;E=mY~rEU ztS{{QOQOIX))#L(4uy6f7j)+rJ|7^8&io|b-u!!_OP%?pk6uGmJD7j|?I(yl zMfn^41*SW&Cx6@F>xq`$l|S@vONsg$@+bC|BSIA9d8j6{qq~Oy|NC zZ{|NV2zt2Vwbvo&n!fzkrN2dt{C)m=RiN9uy`V&aVosx=(cMi^s{2MkOG_I})K{=| zCWa{fZNb$J5U%}V!2>l%iBzrN#P6RY+OntM(%O94&bFQZU+lZ{dbBgG3ixUU+!oURdge!Yh99JOuke;VoCK zj}q;>rSR74_u|I#!bd*?69x(jzg_zR9w@Z!``oQW!A{%c)T?0h&$denULji9W;^<; zbws5OTeLAuv@2q}df^!Ef75oG^;)9+AGh7nhWF09Y>VAsoV(Wca0lr7zF_;-=xRK- z%l7T3z6T56VteMwCZeTW>B}YK7@`%oVNJjq6Q^ zili_YedyYv{*POs;g5=j-4SHX8%2A+(1NUJEjskIDWZyB7F~I)f~f3N(XrxtiI%vE zK6MN(n~W5lv>ivVf1>EEgWHM9A1}_^cK@r${~s3Ho`xy+pDCVP0zz%~7f-frAS!vL z_+S-&-%(V2IPegFgfGcXBGDEx#CXxL&c+e)R9IL2SQj zzxl59Fw~Rwk2U22KCZFf|32<3yU_mdPjn>P=j~7a;uQ4y2m3P*E+B;Voo|0>452Z4 zqy5!yfnokX*?)WT5hTyUCHXP9dhK&1^*2NQODrX=yQ_(2c9cvUUk&{_OQsGkAaq_R zxpew|5VV&ZZ3g3-6(x6^MhsiNS91JaFmmRWJlciphc7RAB784Vd!*!vA3!kMRLSY0 zmk~ncTFL1eB*C5=OMc#s7;LV0v}R_T&2aZpVS2K2CJe zl@4Y9r}5lT$I&;VClI68Ij-*M2E)%gZhhm!$ik}~w~yn2Ex&Qx^Tk(yTTeT_`kgPs zw6%`Y|M{;l{ZAclf7}h%eAV$^TcP2l&y{waI0ocCRNC`2o~xKI?e*sY$DS>{&{>Bh z{9UQ@k>^n|UM$_I0O5CSE}eTGuq3}0QjmNk(=;h0;XQ~~7p}T#23K^7 zh~JIaysdU!p@0><)H_2VCFn7v@Qfm^8_qCU`& z1r-&1n4(03bg|&V-&9;PVpm(MV&PTGq{cp7js#VoqDzApOD;uM6+`NibXg_TS$pA#=$322LEGIimq7uVezJ50^@C0rf6UDn``YsAC1uS6Ek+u;dK;WkVYCM~qDN zJ!i3ZL1h>Z|JcAzy!v4R1E0siA%gEI!!D0=St@0)8P_6VW$`0ruUj^)pnZ5sPsX2t z=Q#pB;%Yc4?|J=-SC06@l3#PnVO0ypJWIb``k~CHV=paTF%3by^gc*RhzA9PLn8EM zSuk8{rad6f(V^hI9UonQuAz33mfe-dP}Ub{Kr*| zP~DGzOf#uC1vv^@%K8<*5>_PH@0WDeHOr_SiDzTKtE`IMS5+2!X1Q%iRoYWw9cd)R z-s~+eSZCfGyRE8`Z!0cO-4=V+zAV}+Jj8b6Jm!F8d$Ldpt{8ab5D=ZN5yP`0iF_j7vNe(Nk(xDWJSW(SLz)lH6N)UpTz-A-&PG5U2ke5# zK^IKYCrtMWSa^l;0&JdSR8;JcjfH_RmoyCv=?fed0Xe*Qa9LGOl;Jaor+vt38I-1z zlsGQ35i!10ptq+MNL+T=o4@XB@{i=8;h4Ozcwe@Lpz0af>25m zK4x%nK|Pb1iRJ;s0B0)43GPa&w|u8A2MsL<=y46mh+3B#i1j5<=AvmTr zZC2VpJhb@mikmPCfsBGje6T1Nj#eNH*QdF-xK4<=9o1_PBuB|qf~~rMJF}gu;dg(U zV$A~zikRwY-KQ#Z&`CDjsw!zv&o3jaP%))wbDMU=pQY%wKOs{pH$)*y=7#w#mE|k5 z_zRFhiQ@FY8*^RUxT?;A>N+6o#?_PKn7wxdX5c0v0WaxH+2W>eIVHI~q^n&&plLqn zHXl>S>e>Hj@?E=SH(4D{^T9IVL74A}Jl?lZ?lNoY7cmNd+ zAvzC{n?*{tQYXq`2esfz8+;hT9TLLWEW=PHNp$%x%^#VUntg%R&W?^2DX(oVq{V(# zTd}xx^;?!`GaSxw%CMR!PZA_cfRc%P$m=A*iot;qXW_HR}lSR$y7(gi|1 zw%cs-dE4N?=miq2Gs|vSy=FsBGz0-6xQSDUt7JTr;qUAc*CgD(DPBS3${_ggFQ%`&(1wdC!vn*_4CLUaIQUdtk+QnfG?-4yub#o6N12yUVnos9 zesoTcs(`d+)hh+iyrD6ZgV2FHRm%g11ljl#!HuZ{8t^C@{+cdpd+D zP*H{#kiq8t{A>_cxcc)v5<~>IB8R!j=TfSRsF{x9qbgX`|1E6prXY z1guvw)Ii9udIjjB8Ie>&iWrI~GlaX)DQZF_?iN_YWcx; zS|B7F0JwhVz7|O!9)sO%R=oB8Q6||91pAU9mXR#QtB!dsOEH^F^{ha##SP6r%#B`z z@+ZSDipaCXjMoo(USY`ud?#AxVPRRWfGVDY&6B2FJuLeazaM$z>K8=|I?9Gd=7u<6;;@WJer{UN`mt43yzgsl(_H=M=aY>c_In_WEo z8@o@ci7rdhH=vE|mqNN0*4&yuGdTL=_T(vt@3FVciv#?DSFb+{|L3j*6v<3I$1uGBOEG~6-o20r?foub2S;;txD>u6V;zZ2?m zV5H|kwvt@WHl_tmHMltql#WzA6y<+oR=BjqdBp2JcqFxIi>r0+8eRnk+!sg*J-B`= zTjJz2_=x)h4yZO5iBnsO|Hj{f@ovt<6bW6Pi}od>eg$Z2AjZ;cL&18)-E(HvE0_j(7@a7gCIQnvvs(4 zV|M9{38M~+VYV#I!l5Bb&o;(>hTv(TPRcgxh5-}0J|KG}vEB%V0FiK8GmK^CSc}v) z?bc1m%#>;y8oNR8a$+CBUFIOUVh^-cZ%Ln;%z~F%t*jgw9Co%3j10OY(bi)(rn=)Z z(@tK#eW~?LOG_`PnZ3I?67t?@0>n#c#Ch` z4u1fp?hH!&%^Ww!fj!ytFz>&7XMv#sTc#J7_B1KFO)0uNqZmuacP8dyOeJjFVj83Bcs;n%&DnrPtWm#&by}VLif2K3-O`ETOEpuTRS2gX)~)XI1oM zJeP_22y^&k?2X<^6zqiO7?2n|GItB9{v#WA&HGZ3S;K_Gia%kzc-Ps69YdD5Jt>}1 zksdra_v4}y?~G{}P~xeP)`2HASS}dp@~qT9;*_MX;hRq~{hLK1BO@v!I zBKsqloxE@Xtj`0fql?YRJ`y;$4futevfgE`xMP#4Yhgqs#N5ckduUFOup5}BJH za|_6YpYIwI_azpeiTRGFMaEaNL5RLYO^E$FJ znh^7>K&EwIDM}aKIZVv0fQbfKM+q4iz?}rtNm^~KkR!4B;sXXbEMWyNVgD+Xvg^~& z7-~CLE4bQF8(4c!~DIOvc9Sp4cnR$^@tYlDS&OePGIZNltC*3svC z(;BE1w>gdE6flJ~LJRR|R6@77C_lCS^1B7RRHMCylX^RW*SrsTraLKsp z)@FDG$}2%()l7LWqA8GyfP@$F@G5Ku_T=-Apvb}n$f+d5I!Lh{6=ku%skGJAx)ep4 z(jt=Auli;X$U)h^U|`^6!51essyU_mQHB}f<66d?YpSAV`dlHdGc+;|v%UDbncZv~ z?xXk$KbzXttaM?x4aX1VaCV_dh7ytm?wn%@wIR*Ri4N5{ifY4kBzu%U7rWI7c3_0f zaaau@B!%D6k>OO3hwjA(Htn@+o<<;=it)^{3kore88D?R;F}?dr<7)J=H@)n{~(QH zWz|icsf1kTiiAQqL=ba3rzPeVk1-?9szD#`c0{Gnys`7j%cpwK$YWy-J{;tUez=R) zqXSxxly8qGzghU_MT(?2EqBeSV8bnM*ZTJL9qq_+)cSeN-x7PL_x2qP0(#g{yc=gn zr7AOr23NV1Ybsp}K_Hl+UV&YdIO7Sc*m5skzxhcEhAST90`b>BeuAUI^XW}f^@J9{ ze_5wDYB;;Zw`K7d!xnoG4I!c{_MMg1-KsEu8w59yJSj6&#_5lZ4km_Dtgo{mCxdwG z8!MMa6XbXm-u1`HX-B%U$knHrl6Ocfk+~Vi#?v484`Kf#N#+8mpB*!n;?ku>;n)=GN>^bU{(%>Rj=w6+t2uHmI)Q*DNa#A zl#?cP@>*;X3aep%7A9VldNA#ji|d&We`cR*_F*9)I9Cy0+*^$7=__}0-!!Bx!*1WB z`cyQj=*L1K&JMA0U);8Jp2ve=KGgFPSU zu%6RGFoxY&-tMx&50K$9NR#5fI)nca)ljGXN}2!*ig9T1*Sj9fjq?93(TsJT6P!lz z&Nfd0hz;|!JA(cw4dVU^ Krpd8bEdLG66`KVB diff --git a/gui/coretool/gpsbabel_de.ts b/gui/coretool/gpsbabel_de.ts index 0904b7b38..3252e9f6f 100644 --- a/gui/coretool/gpsbabel_de.ts +++ b/gui/coretool/gpsbabel_de.ts @@ -4,7 +4,7 @@ core - + (integer sec or 'auto') Barograph to GPS time diff Zeitdifferent zwischen Barograph und GPS (ganzz. Sekunden oder 'auto') @@ -25,51 +25,29 @@ Icon allgemein für "offen" - + After output job done sleep n second(s) Im Anschluß n Sekunde(n) pausieren - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + Allow whitespace synth. shortnames Leerzeichen in Kurznamen erlauben - + Altitudes are absolute and not clamped to ground Absolute Höhenangaben (nicht bodenverbunden) @@ -78,55 +56,33 @@ Beschreibung um Symbolbeschreibung erweitern - + Append realtime positioning data to the output file instead of truncating Echtzeit-Positionierungsdaten an Ausgabendatei anhängen und nicht kürzen - + Base URL for link tag in output Basis-URL für Verknüpfungseintrag in Ausgabe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Basename prepended to URL on output Basis-Adresse für erzeugte URLs - - + + Bitmap of categories Mehrfachkategorie, als Dezimal- oder Hexadezimalwert @@ -135,7 +91,7 @@ Kategoriename (Cache) - + Category number to use for written waypoints Kategorienummer (1..16) beim Schreiben von Wegpunkten verwenden @@ -144,23 +100,22 @@ Farbe für Linien oder Kartenangaben - - + Command unit to power itself down Gerät im Anschluß abschalten - + Complete date-free tracks with given date (YYYYMMDD). Tracks ohne Datumsangaben mit diesem Datum vervollständigen (YYYYMMDD) - + Create unique waypoint names (default = yes) Eindeutige Wegpunktnamen erzeugen (Vorgabe: JA) - + Create waypoints from geocache log entries Wegpunkte aus Geocache Log-Einträgen erzeugen @@ -173,7 +128,7 @@ Datenbankname (Dateiname) - + Datum (default=NAD27) GPS-Datum (Vorgabe: NAD27) @@ -182,79 +137,70 @@ Anzahl an Tagen, nach denen Punkte als alt betrachtet werden - + Decimal seconds to pause between groups of strings Pause (in Sekunden) zwischen Zeilengruppen - + Default category on output Standardkategorie beim Schreiben - + Default category on output (1..16) Standardkategorie der Ausgabe (1..16) - - - - - - + + + Default icon name Standard Symbol - Default location - Vorgabestandort + Vorgabestandort - + Default proximity Vorgabe-Annäherungsabstand - + Default speed Standardgeschwindigkeit - Default speed for waypoints (knots/hr) - Vorgabegeschwindigkeit für Wegpunkte (Knoten/h) + Vorgabegeschwindigkeit für Wegpunkte (Knoten/h) - - + + Degrees output as 'ddd', 'dmm'(default) or 'dms' Schreibe Gradangaben in 'ddd', 'dmm' (Vorgabe) oder 'dms' (Gitter) - Delete all routes - Alle Routen löschen + Alle Routen löschen - Delete all track points - Alle Trackpunkte löschen + Alle Trackpunkte löschen - - Delete all waypoints - Alle Wegpunkte löschen + Alle Wegpunkte löschen - + Display labels on track and routepoints (default = 1) Beschriftung bei Track- und Routenpunkten anzeigen (Vorgabe: 1) - + Distance unit [m=metric, s=statute] Entfernungsangaben [m=Metrisch, s=Statute] @@ -267,29 +213,29 @@ Keine URLs zur Beschreibung hinzufügen - + Don't show gpi bitmap on device Kein Bitmap (Icon) auf dem GPS anzeigen - + Draw extrusion line from trackpoint to ground Verbindungslinie vom Trackpunkt zum Erdboden zeichnen - + Drop route points that do not have an equivalent waypoint (hidden points) Versteckte Wegpunkte löschen (automatisch berechnete Routenpunkte) - + Enable alerts on speed or proximity distance Alarm für Annäherung oder Geschwindigkeit aktivieren - - - + + + Encrypt hints using ROT13 Verschlüsselung mit ROT13 @@ -298,24 +244,22 @@ Verschlüsselung mit ROT13 - - - - - - - - + + + + + + Erase device data after download Nachdem Download Daten auf dem Gerät löschen - + Export linestrings for tracks and routes Linendaten (linestrings) für Tracks und Routen exportieren (Vorgabe: JA) - + Export placemarks for tracks and routes Markierungen für Tracks und Routen exportieren @@ -338,39 +282,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + GPS datum (def. WGS 84) GPS-Datum (Vorgabe: WGS 84) @@ -383,25 +305,24 @@ Ereignis-Symbole beim Lesen ignorieren - + Include extended data for trackpoints (default = 1) Erweiterte Daten in Trackpoints mit einbeziehen (Vorgabe = 1) - - + + Include groundspeak logs if present Groundspeak Logs beifügen (sofern vorhandan) - + Include major turn points (with description) from calculated route Hauptrichtungsänderungen (Ansage vorhanden) mit einbeziehen - Include only via stations in route - Nur Stationspunkte ('via stations') der Route übernehmen + Nur Stationspunkte ('via stations') der Route übernehmen Include short name in bookmarks @@ -416,30 +337,27 @@ Routen-Index (falls mehrere im Eingabeformat) - Index of route to write (if more than one in source) - Zu Schreibender Routen-Index (falls mehrere im Eingabeformat) + Zu Schreibender Routen-Index (falls mehrere im Eingabeformat) Index of route/track to write (if more than one in source) Routen- oder Track-Index (falls mehrere im Eingabeformat) - Index of track (if more than one in source) - Track-Index (falls mehrere im Eingabeformat) + Track-Index (falls mehrere im Eingabeformat) - Index of track to write (if more than one in source) - Track-Index (falls mehrere im Eingabeformat) + Track-Index (falls mehrere im Eingabeformat) Index of URL field in .dbf Index der URL innerhalb der .dbf - + Indicate direction of travel in track icons (default = 0) Bewegungsrichtung in Tracksymbolen mit Richtungspfeilen anzeigen (Vorgabe: 0) @@ -452,95 +370,50 @@ Icon "Komplex (Infrastruktur) offen" - Keep turns if simplify filter is used - Abbiegungen bei Verwendung des Simplify(Vereinfachen)-Filters beibehalten + Abbiegungen bei Verwendung des Simplify(Vereinfachen)-Filters beibehalten - - + + Length of generated shortnames Maximale Länge der generierten Kurznamen - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Max synthesized shortname length Length of generated shortnames (default 16) Maximale Länge der zu generierenden Kurznamen (Vorgabe: 16) - + Line color, specified in hex AABBGGRR Linienfarbe (hexadezimaler Wert AABBGGRR) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Make synth. shortnames unique Eindeutige Kurznamen erzeugen @@ -549,17 +422,17 @@ TRK-Datei in MapSend-Version # (3,4) erzeugen - + Video position for which exact GPS time is known (hhmmss[.sss], default is 00:00:00,000) - + GPS time at position video_time (hhmmss[.sss], default is first timestamp of track) - + GPS date at position video_time (yyyymmdd, default is first timestamp of track) @@ -580,68 +453,27 @@ Markierungstyp für nicht gefundene Punkte - + Max length of waypoint name to write Max. Länge der zu schreibenden Wegpunktnamen - - - Max number of comments to write (maxcmts=200) - Maximale Anzahl an Kommentaren für die Ausgabe + Maximale Anzahl an Kommentaren für die Ausgabe Max shortname length when used with -s Maximale Länge der generierten Kurznamen - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Max synthesized shortname length - Maximale Länge der generierten Kurznamen - Merge output with existing file Ausgabe in existierende Datei einfügen - - - - + + + + MTK compatible CSV output file Ausgabe-CSV-Datei kompatibel zum MTK-Datalogger @@ -650,16 +482,15 @@ Name der 'unassigned'-Kategorie - New name for the route - Name der neuen Route + Name der neuen Route No separator lines between waypoints Keine Trennlinien zwischen den Wegpunkten - + No whitespace in generated shortnames Leerzeichen in Kurznamen unterdrücken @@ -672,32 +503,30 @@ Sichtbar und unverschlüsselter Symbolname - Numeric value of bitrate (baud=4800) - Baudrate (Vorgabe: 4800) + Baudrate (Vorgabe: 4800) - + Omit Placer name Placername auslassen - Only read turns; skip all other points - Nur Abbiegungen lesen und alle sonstigen Punkte überspringen + Nur Abbiegungen lesen und alle sonstigen Punkte überspringen - + Path to HTML style sheet Pfad zum HTML-Stylesheet - + Precision of coordinates Präzision der Koordinaten (Anzahl Nachkommastellen) - + Proximity distance Standardmäßiger Annäherungsabstand @@ -706,57 +535,55 @@ Kreisradius - Radius of our big earth (default 6371000 meters) - Erdradius in Meter (Vorgabe: 6371000 Meter) + Erdradius in Meter (Vorgabe: 6371000 Meter) - Read control points as waypoint/route/none - Lese Kontrollpunkte als Wegpunkt/Route/nichts + Lese Kontrollpunkte als Wegpunkt/Route/nichts Read/Write date format (i.e. DDMMYYYY) Datumsformat für Ein-/Ausgabe (z.B. DDMMYYYY) - + Read/Write date format (i.e. yyyy/mm/dd) Datumsformat (z.B. DD.MM.YYYY) - + Read/write GPGGA sentences Schreibe/Lese GPGGA Sequenzen - + Read/write GPGSA sentences Schreibe/Lese GPGSA Sequenzen - + Read/write GPRMC sentences Schreibe/Lese GPRMC Sequenzen - + Read/write GPVTG sentences Schreibe/Lese GPVTG Sequenzen - + Read/Write time format (i.e. HH:mm:ss xx) Zeitformat (z.B. HH:mm:ss xx) - + Retain at most this number of position points (0 = unlimited) Höchstens diese Anzahl an Positionspunkten behalten (0 = keine Begrenzung) - - + + Return current position as a waypoint Aktuelle Position als Wegpunkt übertragen @@ -769,72 +596,63 @@ Kurzname ergibt sich aus MAC-Adresse - + Speed in bits per second of serial port (baud=4800) Übertragungsrate des seriellen Ports in Bits/Sekunde (Vorgabe: baud=4800) - Split input into separate files - Gelesene Daten in einzelne Dateien aufteilen + Gelesene Daten in einzelne Dateien aufteilen - Split into multiple routes at turns - Route an Abbiegungen teilen + Route an Abbiegungen teilen Garmin Training Center Garmin Training Center - + Write course rather than history, default yes Kurs statt Verlauf schreiben (Vorgabe: ja) - + Sport: Biking (deflt), Running, MultiSport, Other Sport: Radfahren, Laufen, Mehrere Sportarten, Andere - Geogrid-Viewer ascii overlay file (.ovl) - Geogrid-Viewer ASCII Overlay-Datei (.ovl) + Geogrid-Viewer ASCII Overlay-Datei (.ovl) - Geogrid-Viewer tracklogs (.log) - Geogrid-Viewer Tracklogs (.log) + Geogrid-Viewer Tracklogs (.log) The minimum speed (km/h) traveling from waypoint to waypoint. Set >0 to remove duplicate waypoints Minimalgeschwindigkeit (km/h) bei Bewegung von einem Wegpunkt zum nächsten. Größer Null wählen, um doppelte Wegpunkte zu entfernen. - iGO2008 points of interest (.upoi) - iGO2008 points of interest (.upoi) + iGO2008 points of interest (.upoi) - IGO8 .trk - IGO8 .trk + IGO8 .trk - Track identification number - Track-Identifikationsnummer + Track-Identifikationsnummer - Track title - Tracktitel + Tracktitel - Track description - Trackbeschreibung + Trackbeschreibung Starting seed of the internal number generator @@ -853,96 +671,100 @@ Unsichtbarer unverschlüsselter Symbolname - + Set location finder target location as lat,lng - + Configure logging parameter as tmin:tmax:dmin:dmax - - - + + + Seconds that GPS time tracks UTC (0: best guess) - - - + + Image Offset Time (+HH:MM or -HH:MM) + + + + + override codec to use for device + + + + + Google Takeout Location History + + + + + + GPS week rollover period we're in (-1: best guess) - + codec to use for reading and writing strings (default windows-1252) - + Qstarz BL-1000 - + SkyTraq Venus based loggers (download) - + First sector to be read from the file - + Last sector to be read from the file (-1: read till empty sector) - + SkyTraq Venus based loggers Binary File Format - + Format for subtitles - + SubRip subtitles for video mapping (.srt) - Swiss Map 25/50/100 (.xol) - Swiss Map 25/50/100 (.xol) + Swiss Map 25/50/100 (.xol) - + Tab delimited fields useful for OpenOffice - - Teletype [ Get Jonathon Johnson to describe - - - - - TomTom Places Itineraries (.itn) - - - - + Write name(s) of format(s) from input session(s) Name(n) der Format(e) der Eingabesitzung(en) ausgeben - + Write filename(s) from input session(s) Dateiname(n) der Eingabesitzung(en) ausgeben @@ -950,11 +772,6 @@ Version of VidaOne file to read or write (1 or 2) Version der zu schreibenden/lesenden VidaOne-Datei (1 oder 2) - - - Wintec TES file - - String to separate concatenated address fields (default=", ") Trennzeichen für zusammengefügte Adressfelder (Vorgabe: ", ") @@ -968,14 +785,13 @@ Unterdrücke zurückgezogene (?) Geocaches - + Suppress separator lines between waypoints Keine Trennlinien zwischen den Wegpunkten - Suppress use of handshaking in name of speed - Kein 'Handshaking' (im Namen der Geschwindigkeit) + Kein 'Handshaking' (im Namen der Geschwindigkeit) Suppress whitespace in generated shortnames @@ -986,22 +802,21 @@ Symbol für Punkte - + Sync GPS time to computer time Synchronisiere PC-Uhr mit dem GPS (PC -> GPS) - Synthesize track times - Erzeuge Tracknamen + Erzeuge Tracknamen - + Target GPX version for output Schreibe in GPX-Version (1.0 oder 1.1) - + Temperature unit [c=Celsius, f=Fahrenheit] Temperatureinheit [c=Celsius, F=Fahrenheit] @@ -1018,13 +833,13 @@ .an1 Dateityp - - + + Units for altitude (f)eet or (m)etres Höhenangaben in Fuß oder Meter ('f' oder 'm') - + Units used for names with @speed ('s'tatute or 'm'etric) Einheit für Geschwindigkeit in Wegpunkten [...@30] ( 's'tatute oder 'm'etrisch) @@ -1035,38 +850,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + UPPERCASE synth. shortnames Erzeuge Kurznamen in Großbuchstaben @@ -1081,48 +874,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Use shortname instead of description Kurznamen anstelle der Beschreibung verwenden - + Use specified bitmap on output Gewähltes Bitmap (.BMP) für die Ausgabe verwenden - + Version of gdb file to generate (1..3) Schreibe GDB-Version 1, 2 oder 3 @@ -1131,12 +901,12 @@ Schreibe MapSource Datei in Version ... (3,4 oder 5) - + Waypoint background color Wegpunkt Hintergrundfarbe - + Waypoint foreground color Wegpunkt Vordergrundfarbe @@ -1149,54 +919,65 @@ Kartenbreite in Pixel - + Width of lines, in pixels Linienhöhe in Pixel - + Write additional node tag key/value pairs Zusätzliche Wegpunkt (node) Informationspaare (tags) schreiben - + Write additional way tag key/value pairs Zusätzliche Routen (way) Informationspaare (tags) schreiben - + Write all tracks into one file Alle Tracks in eine Datei schreiben - + Write description to address field Beschreibung in das Adressfeld schreiben - + Write each waypoint in a separate file Jeden Wegpunkt in eine separate Datei schreiben - + Write notes to address field Kommentar (Notizen) in das Adressfeld schreiben - + Write position to address field Koordinaten in das Adressfeld schreiben - - + + Write position using this grid. Koordinaten unter Benutzung dieses Gitters (Grids) erzeugen. - - + + + + + + + + + + + + + Write timestamps with offset x to UTC time Zeitstempel mit Versatz x zur UTC schreiben @@ -1205,7 +986,7 @@ Tracks ohne Titel erzeugen (kompatibel zu "Carto Exploreur") - + Write tracks for Gisteq Phototracker Tracks für "Gisteq Phototracker" schreiben @@ -1222,14 +1003,12 @@ Alan Map500 Wegpunkte und Routen (.wpr) - Brauniger IQ Series Barograph Download - Brauniger IQ Series Barograph Download + Brauniger IQ Series Barograph Download - Cambridge/Winpilot glider software - Cambridge/Winpilot glider Software + Cambridge/Winpilot glider Software CarteSurTable data file @@ -1244,12 +1023,12 @@ CoastalExplorer XML - + Columbus/Visiontac V900 files (.csv) Columbus/Visiontac V900 Datei (.csv) - + Comma separated values Kommaseparierte Werte @@ -1266,7 +1045,7 @@ cotoGPS für Palm/OS - + Data Logger iBlue747 csv Data Logger iBlue747 (.csv) @@ -1279,9 +1058,8 @@ DeLorme .an1 (drawing) Datei - DeLorme GPL - DeLorme GPL + DeLorme GPL DeLorme PN-20/PN-30/PN-40 USB protocol @@ -1296,14 +1074,12 @@ Unabhängig von PN-Version lange Wegpunkte verwenden - DeLorme Street Atlas Plus - DeLorme PN-20/PN-30/PN-40 USB protocol + DeLorme PN-20/PN-30/PN-40 USB protocol - DeLorme Street Atlas Route - DeLorme Street Atlas Route + DeLorme Street Atlas Route DeLorme XMap HH Native .WPT @@ -1318,136 +1094,113 @@ DeLorme XMat HH Street Atlas USA .WPT (PPC) - Destinator Itineraries (.dat) - Destinator Reiserouten (.dat) + Destinator Reiserouten (.dat) - Destinator Points of Interest (.dat) - Destinator Points of Interest (.dat) + Destinator Points of Interest (.dat) - Destinator TrackLogs (.dat) - Destinator TrackLogs (.dat) + Destinator TrackLogs (.dat) - EasyGPS binary format - EasyGPS Binärformat + EasyGPS Binärformat - + Embedded Exif-GPS data (.jpg) Eingebettete EXIF-GPS-Daten (.jpg) - + Set waypoint name to source filename Wegpunktnamen nach Eingabedatei benennen - + Data Logger iBlue757 csv Data Logger iBlue747 (.csv) {757 ?} - + Time-frame (in seconds) Zeit-Frame (in Sekunden) - + Locate waypoint for tagging by this name Wegpunkt für Tagging mit diesem Namen auffinden - + !OVERWRITE! the original file. Default=N Originaldatei !ÜBERSCHREIBEN!. Standard=N - - Energympro GPS training watch - - - - Enigma binary waypoint file (.ert) - Enigma binäre Wegpunkt-Datei (.ert) + Enigma binäre Wegpunkt-Datei (.ert) - + Source for name field in .dbf - + Source for URL field in .dbf - + ESRI shapefile - - F90G Automobile DVR GPS log file - - - - + FAI/IGC Flight Recorder Data Format FAI/IGC Flight Recorder Datenformat - + Read all points even if latitude or longitude is missing - + Flexible and Interoperable Data Transfer (FIT) Activity file - - FlySight GPS File - - - - Franson GPSGate Simulation - Franson GPSGate Simulation + Franson GPSGate Simulation - Fugawi - Fugawi + Fugawi G7ToWin data files (.g7t) G7ToWin Datendatei (.g7t) - + Garmin 301 Custom position and heartrate Garmin 301 Custom Position und Herzfrequenz - + Garmin G1000 datalog input filter file - Garmin Logbook XML - Garmin Logbook XML + Garmin Logbook XML - + Garmin MapSource - gdb Garmin MapSource - gdb @@ -1456,7 +1209,7 @@ Garmin MapSource - mps - + Garmin MapSource - txt (tab delimited) Garmin MapSource - txt (Tabulator getrennt) @@ -1465,47 +1218,47 @@ Garmin PCX5 - + Garmin POI database Garmin POI-Datenbank - + codec to use for writing strings - + language code to use for reading dual language files - + Garmin Points of Interest (.gpi) Garmin Points of Interest (.gpi) - + Erase existing courses when writing new ones - + Speed in bits per second of serial port (baud=9600) Übertragungsrate des seriellen Ports in Bits/Sekunde (Vorgabe: baud=4800) {9600)?} - + Garmin serial/USB protocol Garmin Serielles/USB-Protokoll - + Garmin Training Center (.tcx/.crs/.hst/.xml) - + Geocaching.com .loc Geocaching.com .loc @@ -1514,29 +1267,28 @@ GeocachingDB für Palm/OS - GEOnet Names Server (GNS) - GEOnet Names Server (GNS) + GEOnet Names Server (GNS) GeoNiche .pdb GeoNiche .pdb - + GlobalSat DG-100/BT-335 Download GlobalSat DG-100/BT-335 Download - - - - + + + + Only erase device data, do not download anything Nur Gerätedaten löschen, aber nichts herunter laden - + Google Earth (Keyhole) Markup Language Google Earth (Keyhole) Markup Language (.kml) @@ -1545,9 +1297,8 @@ Google Maps XML - Google Navigator Tracklines (.trl) - Google Navigator Tracklines (.trl) + Google Navigator Tracklines (.trl) GoPal GPS track log (.trk) @@ -1566,22 +1317,22 @@ GpilotS - + GPS TrackMaker GPS TrackMaker - + GPSBabel arc filter file GPSBabel arc Filterdatei - + GpsDrive Format GpsDrive Format - + GpsDrive Format for Tracks GpsDrive Format für Tracks @@ -1598,44 +1349,41 @@ gpsutil - + GPX XML GPX XML - + Add info (depth) as Humminbird extension Information (Tiefe) als Humminbird-Erweiterung hinzufügen - + Add info (depth) as Garmin extension Information (Tiefe) als Garminerweiterung hinzufügen - HikeTech - HikeTech + HikeTech - Holux (gm-100) .wpo Format - Holux (gm-100) .wpo Format + Holux (gm-100) .wpo Format - + Holux M-241 (MTK based) Binary File Format Holux M-241 (MTK basiert) Binärdatei - + Holux M-241 (MTK based) download Holux M-241 (MTK basiert) Download - - - + + Enable logging after download Logging nach dem Download aktivieren @@ -1648,24 +1396,23 @@ HSA Endeavour Navigator Export - + HTML Output HTML Ausgabe - + Humminbird tracks (.ht) Humminbird Tracks (.ht) - + Humminbird waypoints and routes (.hwr) Humminbird Wegpunkte und Routen (.hwr) - IGN Rando track files - IGN Rando Trackdatei + IGN Rando Trackdatei Kartex 5 Track File @@ -1676,26 +1423,24 @@ Kartex 5 Wegpunktdatei - Kompass (DAV) Track (.tk) - Kompass (DAV) Track (.tk) + Kompass (DAV) Track (.tk) - Kompass (DAV) Waypoints (.wp) - Kompass (DAV) Wegpunkte (.wp) + Kompass (DAV) Wegpunkte (.wp) KuDaTa PsiTrex text KuDaTa PsiTrex Text - + Lowrance USR Lowrance USR - + (USR output) Write version (USR Ausgabe) Write version @@ -1712,68 +1457,56 @@ Magellan NAV Companion für Palm/OS - Magellan SD files (as for eXplorist) - Magellan SD files (für eXplorist) + Magellan SD files (für eXplorist) - Magellan SD files (as for Meridian) - Magellan SD files (für Meridian) + Magellan SD files (für Meridian) - Magellan serial protocol - Magellan serielles Protokoll + Magellan serielles Protokoll - MagicMaps IK3D project file (.ikt) - MagicMaps IK3D Projektdatei (.ikt) + MagicMaps IK3D Projektdatei (.ikt) - Map&Guide 'TourExchangeFormat' XML - Map&Guide 'TourExchangeFormat' XML + Map&Guide 'TourExchangeFormat' XML Map&Guide to Palm/OS exported files (.pdb) Map&Guide nach Palm/OS exportierte Datei (.pdb) - MapAsia track file (.tr7) - MapAsia Trackdatei (.tr7) + MapAsia Trackdatei (.tr7) - Mapopolis.com Mapconverter CSV - Mapopolis.com Mapconverter CSV + Mapopolis.com Mapconverter CSV - MapTech Exchange Format - MapTech Exchange Format + MapTech Exchange Format - Memory-Map Navigator overlay files (.mmo) - Memory-Map Navigator Overlay-Datei (.mmo) + Memory-Map Navigator Overlay-Datei (.mmo) - Write items 'locked' [default no] - Element 'locked' schreiben [Standard nein] + Element 'locked' schreiben [Standard nein] - Write items 'visible' [default yes] - Element 'visible' schreiben [Standard ja] + Element 'visible' schreiben [Standard ja] - Write files with internal version [n] - Dateien mit interner Version schreiben [n] + Dateien mit interner Version schreiben [n] Microsoft AutoRoute 2002 (pin/route reader) @@ -1784,41 +1517,39 @@ Microsoft Streets and Trips (pin/route reader) - Microsoft Streets and Trips 2002-2007 - Microsoft Streets and Trips 2002-2007 + Microsoft Streets and Trips 2002-2007 - Motorrad Routenplaner (Map&Guide) .bcr files - Motorrad Routenplaner (Map&Guide) (.bcr) + Motorrad Routenplaner (Map&Guide) (.bcr) MS PocketStreets 2002 Pushpin MS PocketStreets 2002 Pushpin - + MTK Logger (iBlue 747,...) Binary File Format MTK Logger (iBlue 747,...) Binärdatei - + MTK Logger (iBlue 747,Qstarz BT-1000,...) download MTK Logger (iBlue 747,Qstarz BT-1000,...) Download - + National Geographic Topo .tpg (waypoints) National Geographic Topo .tpg (Wegpunkte) - + National Geographic Topo 2.x .tpo National Geographic Topo 2.x .tpo - + National Geographic Topo 3.x/4.x .tpo National Geographic Topo 3.x/4.x .tpo @@ -1831,34 +1562,28 @@ Navigon Mobile Navigator .rte-Datei - Navigon Waypoints - Navigon Wegpunkte + Navigon Wegpunkte - NaviGPS GT-11/BGT-11 Download - NaviGPS GT-11/BGT-11 Download + NaviGPS GT-11/BGT-11 Download - Clear the datalog - Datalog löschen + Datalog löschen - Read from datalogger buffer - Datalogger-Puffer auslesen + Datalogger-Puffer auslesen - NaviGPS GT-31/BGT-31 datalogger (.sbp) - NaviGPS GT-31/BGT-31 Datalogger (.sbp) + NaviGPS GT-31/BGT-31 Datalogger (.sbp) - NaviGPS GT-31/BGT-31 SiRF binary logfile (.sbn) - NaviGPS GT-31/BGT-31 SiRF binäre Logdatei (.sbn) + NaviGPS GT-31/BGT-31 SiRF binäre Logdatei (.sbn) Naviguide binary route file (.twl) @@ -1869,330 +1594,260 @@ 'wp' - Wegpunktdatei erstellen, 'rte' - Routendatei erstellen - - + Time zone ID - + Attempt to recovery data from corrupt file - + Don't create waypoints for non-user points - - Geogrid-Viewer binary overlay file (.ovl) - - - - + Compact Output. Default is off. - + GeoJson - + GlobalSat DG-200 Download - + list tracks - + get track - - - - + + + + Dump raw data to this file - + GlobalSat GH625XT GPS training watch - - Google Directions XML - - - - + Write KML track (default = 0) - + Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical, 'a'viation) - + Rotate colors for tracks and routes (default automatic) - + Precision of coordinates, number of decimals - + GPS Tracking Key Pro text - + Precision of elevations, number of decimals - - + + Size of blocks in KB to request from device - - iGo Primo points of interest (.upoi) - - - - + (USR input) Ignore event marker icons on read - + (USR output) Treat waypoints as icons on write - + (USR output) Merge into one segmented trail - + (USR input) Break segments into separate trails - + (USR output) Output file title string - + (USR output) Device serial number - + (USR output) Output file content description - - Mainnav - - - - - Mapbar (China) navigation track for Sonim Xp3300 - - - - - Mapfactor Navigator - - - - - Speed in bits per second of serial port (autodetect=0) - - - - - Download logged fixes - - - - - Show device status - - - - - MediaTek Locus - - - - - + + First sector to be read from the device - - + + Baud rate used to init device (0=autodetect) - - + + Last sector to be read from the device (-1: smart read everything) - - + + Disable output (useful with erase) - - + + Number of sectors to read at once (0=use single sector mode) - + POI for Home Symbol as lat:lng[:alt] - + POI for Car Symbol as lat:lng[:alt] - + POI for Boat Symbol as lat:lng[:alt] - + POI for Heart Symbol as lat:lng[:alt] - + POI for Bar Symbol as lat:lng[:alt] - + MiniHomer, a skyTraq Venus 6 based logger (download tracks, waypoints and get/set POI) - + Garmin Mobile XT ([ATRK]/STRK) - + Track name processing option ([0]-nrm/1-ign) - + Mobile Garmin XT Track files - - - Motoactiv CSV - - - - - MyNav TRC format - - 'n' - Keep the existing wp name, 'y' - rename waypoints 'n' - Existierende Wegpunktnamen behalten, 'y' - Wegpunkte umbenennen - Navitel binary track (.bin) - Navitel binäre Trackdatei (.bin) + Navitel binäre Trackdatei (.bin) - Navitrak DNA marker format - Navitrak DNA marker format + Navitrak DNA marker format NetStumbler Summary File (text) NetStumbler Summary File (text) - NIMA/GNIS Geographic Names File - NIMA/GNIS Geographic Names File + NIMA/GNIS Geographic Names File - + Accept position fixes in gpgga marked invalid - + NMEA 0183 sentences NMEA 0183 Sätze - - Compact binary representation - - - - Nokia Landmark Exchange - Nokia Landmark Exchange + Nokia Landmark Exchange - + OpenStreetMap data files OpenStreetMap Datendatei (.osm) - + Use this value as custom created_by value Diesen Wert als eigenen Wert für created_by verwenden - + OziExplorer OziExplorer - + Unit used in altitude values Einheit für Höhenwerte - + Unit used in proximity values Einheit für Entfernungswerte @@ -2225,19 +1880,16 @@ Quovadis - Raymarine Waypoint File (.rwf) - Raymarine Wegpunktdatei (.rwf) + Raymarine Wegpunktdatei (.rwf) - Ricoh GPS Log File - Ricoh GPS Logdatei + Ricoh GPS Logdatei - See You flight analysis data - You flight Analysedaten anzeigen + You flight Analysedaten anzeigen Skymap / KMD150 ascii files @@ -2252,8 +1904,8 @@ Baudrate für die Geräteinitialisierung, 0=automatische Erkennung - - + + Baud rate used for download Baudrate für das Herunterladen @@ -2278,45 +1930,41 @@ Tabulator-getrennte Felder (nützlich für OpenOffice, Ploticus etc.) - + Textual Output Textausgabe - TomTom Itineraries (.itn) - TomTom Reiserouten (.itn) + TomTom Reiserouten (.itn) - TomTom POI file (.asc) - TomTom POI-Datei (.asc) + TomTom POI-Datei (.asc) - TomTom POI file (.ov2) - TomTom POI-Datei (.ov2) + TomTom POI-Datei (.ov2) TopoMapPro Places File TopoMapPro Places-Datei - TrackLogs digital mapping (.trl) - TrackLogs digital mapping (.trl) + TrackLogs digital mapping (.trl) U.S. Census Bureau Tiger Mapping Service U.S. Census Bureau Tiger Mapping Service - + Universal csv with field structure in first line Universelle CSV-Datei mit Feldstruktur in der ersten Zeile - + Vcard Output (for iPod) VCard-Ausgabe (für iPod) @@ -2337,41 +1985,32 @@ WiFiFoFum 2.0 für PocketPC XML - Wintec WBT-100/200 Binary File Format - Wintec WBT-100/200 Binärdatei + Wintec WBT-100/200 Binärdatei - Wintec WBT-100/200 GPS Download - Wintec WBT-100/200 GPS Download + Wintec WBT-100/200 GPS Download - Wintec WBT-201/G-Rays 2 Binary File Format - Wintec WBT-201/G-Rays 2 Binärdatei + Wintec WBT-201/G-Rays 2 Binärdatei - XAiOX iTrackU Logger - XAiOX iTrackU Logger + XAiOX iTrackU Logger - - Appends the input to a backup file - Eingabe an Sicherungsdatei anhängen + Eingabe an Sicherungsdatei anhängen - - Only waypoints that are not the backup file - Nur Wegpunkte, die keine Sicherungsdatei sind + Nur Wegpunkte, die keine Sicherungsdatei sind - XAiOX iTrackU Logger Binary File Format - XAiOX iTrackU Logger Binärdatei + XAiOX iTrackU Logger Binärdatei Yahoo Geocode API data diff --git a/gui/coretool/gpsbabel_es.qm b/gui/coretool/gpsbabel_es.qm index 692bbbd39b6c4e28cb941c1baeb37a6b1400f10e..8cdd630a4e72e56a7a15964bdc27234ec5e91417 100644 GIT binary patch delta 1294 zcmW+$X-pJn7=FIFc88sv;Sf;33y?z!B8Y;51!O^KtKxwITJcz;wSlN8P{q}1wFnK$ zxUq&-OKTX9H7)vKP^#=(meA^FhGqot*hD0mUY8vTrO9BXF~-X^}OL zt9ibX2-~9&xx~-pXg=iuU*%6Y6L<4f*R}z}1Nm2-<$$*% zP&iO<5*Rc{_&)zWp!y1pdv5|h6NIw?U4U1S(3P7;3Oa?S6~h2Go5(x_a^RsjG9;LQ zZi`t-$G!!2N>sZl4$M)<$X0+(CdeM%w<6 z6hsG0pQ(Xl`EsdY2@eeIkWNga^MEO2DJ}4InZm=P0QtNrX@w3XdYT$u-XcdmOs&7} zfdjS)rnb`8KzB{In#uApmrOlPYbm27^X^TQS^Nrf^^Unf_;BMIwQbfw0$y-XDG{?z%#cdSnpRy4<4d6p%S2Ufsos%zJyaA-<$yYbfxnTiv zr@hxfOm52eejoygU%PpU-vW_-ZX=2aC~1S+1}81lesXhK4wD0cZl60zdHe&5d^v%# zjJ3>*8V@MtmclpAt+K3tRtQ9tSjzi)02XiAmHZ76cx-W&9;C9Jw$#0u?^A@d>A=)` zO6F7tF*UuTWS_cEfd47E3l~t94yEh}Suf95szS-qv|{Dx3z>*SD6TtefFY}ua}U~x zP>FJHCS^G;KmSAidB!=U@cj)OaoaSlCDksP#|mav~)XN$Eaql_%^jUxm(+PeipS`)()qX zk^>Fe(aI^5eU9cjy_Y^1k=ph1bbeTsHc)tz?zyy*8hzaOM~ang#Z8m delta 10910 zcmb_i33MCvng1l8vMrf7K5#BiY{y3u-?_zF=l*o_$!8WXcz^cA zK23ucJwtTiZ^-wimuPhxU7=JH4V|LnS4N4JtfTwyo=bG;GxX}5(?na((C>C<5bbYt z6h2r&RDPx7f})>*Zj+<**7u02Pde6Ib&%+yYaHuhZEJ~E^f=W4mp^hF(Vl;HT-Ra}UA(~YiIa~I9msOr zdasjc)jN*I`v!>A#g4x=FTwZkoVgiQMD1V5uaNL5p5gEy5nXDu;#t2Cq7?7)LfGFoo{`bXwmIiPg*8kp7qk6 zj}Tq<`>bD{It_*oWW81TI9woS=e`gmiUpTt7u5ZYX!uli;lm$=W?#=7KPjWw+$~^brKv z_V;ss^Dr#8az)M`!Xrevx8}TiDHv_|dG4xbx{20(JooV69Ykwy$UXMk7l>*a&wXmaOL(B#wdYGGi1e#nd-uJD^viJ_$a$4W8g?E3 z({iE4@2J9a z8(mL5`D3E7OI<&>JO+YwZr4i+7_=XEy?oDgu)rT&Z+TA7pUrnY4O1R?Eq`wj2sNM0-`lu~$TN|D zungBbC-V;n?}P6v@-+^goqx%ncvmCZyx4r!SsGh*F8^!R?f+4b>Fpy5f1{wi0CIQV zU$CtUhRAubU`G!WZ|Ex6^UYU)Qym5S4*`FwG7HA8bRir41xGK!`O>uo$N%-Ch=i>L zH-2R$4E2?Qn`$$Nj$B@F*I#j8(ZYiJf373h-YNL*Z=Zl(j~D#lo+*UTzOI6ocOo?U zzh3a#_nF~f!T&t|Ad=^I?ramTZup_Q@F`}3SnNJt2gVB~++RM270kBfnct0xX;NiqcHS5&#p;mI{3P0-<*#ltB-m1om-3Ko9o#>g!8-a_3Zz}V=(*| zJ<8DM@Z2q)sESh>Bj?`vOQnB^Ht#1S3M6s`)`1a zfalzQ{Tilk^}O{-ACjcU^WPhwp|7T}_3TL?_lCk1Pvg1LGllB{nQ-N@!cFZ9Q3)&LWG;p-pdQ!tZEOnU1 z5;D|m*5znO^((s6y-ONUbX75=&9bifbvZmHd9|aVfF_URkomL9f|!@K;Q1g8gAQxM zJez1Qeupfr1JFJKetuYruM3F`oE^paqm~p(f_LQ>IXJAVBYvf6FVt59T14^()Dg&H zXrqy%vaaO7Oqo7SR~(3DGLIB|^Wtji0qtPi%1N&T!7T_*ESa3(F=tCak#)<$BXUFz zX#VLk_fS@>l)SjV$GV@Nl&F(-QcvQ!e6P}@=|M&6+}Sfzh}QF-9I&E60TtH09iJR0 zZ1?0ojmt2BOAHCM*5{CjC$%3Z_ZJ&a>If;L@)}Bep@O z$BK%a<;|7>IIP%R$MEgL_gfS)Zz^6q=K`-XDn|nmDWLh}h^mFmK=E0}nE71s(md!E zw!A5yC@nLuYVvH7s1898h0`^tUY}68#-?I~6=g&k)pY5oJQdc|P{fex#zR`fXd2V& z&7zV=ltu(9JCOf4)Fo)8SxLjjw2i7;+QPsI9&@}(K#3@l90*7{Ynf)vu2j0__O5dC z#hRk!0gFC!V$C6Uf?in)y@-x%l*~EqVt2wT>DsRU;|JTj*7ch#Hb3uv#~MD7tJVXk82TY-N;z^-`Sj!xijK!Jpc9;u&>&L4Ef zRsdBQd7@S*##04yby#)@K{gHY3M3hTl&nWeQg-Na$k0MSlz~ne(K?_8qX8?iW;(I} z1fzgZ8GxxK)XeUPMg8(ob>_X^IM7c(FwQ&)|J4dn*#1B_#_#4OZ z5cQ_OXi=xE2i1@SZx3tQxHQz;Gks6R6VBKelvDvXV^(&scWtpbSJ;*UU%1w?rA3|P z8mQurZLEMH*E3eUf%f2Afx$$@;at*a0)9#=SJ$basHr0jdsO9U42sEyPgNxiItFBf zjqtWM5lG9c^)uq$Hss&q&Xv%g!o4DuyQ0sLEL=f3;v~RV{q$&Mu>%FR6A$vE0jMIu zKQh$d;+_Nwk%m54n^Bv+$>_)`b5oM4a%HEc`4Pl@@`UQQK*UPD0Dy$qM)Y)D&0|$> z$1b2Q&>aWeLHvV@5;2(DrH(6uif?RY5Ux2dbGx7dSH4M0Fh7E&fm)~;fAu)i2tS2! zhm;^ZuS*L=C#5=nu%RWlxw&3yJQ~(a$C8q1t$K;`;+k1p&}~JpMEzE{aO@|^m2`LZ zN&RwYL=$E<9c{%mMZn`ug#Q{#0yfong1@V~bH^G91{t5ere?rtUQ%0xe(Nphz>&$Z z$M>@{Wzc>*p=2q=nnT&~z`f~6(-v02PJo1kpuf7HN-KET4~$)7Z^kpIIN zxZZrK?p*8$YQJs?#`rgZSYW?%^fEN~tvC?Bg`E{#lhBi^_~yvwDCaBORWqpY6)|lH zb$PxqKsB{VTC!bH!cruvhm4qn2r$%OIG~PNNE!jWs)iIb6ig1O9sH`aOqOUnm@`{0 z?E=TVXrcF5Kp`+~JS7Ipw`;+$YyiEy?R)A)Cn43%ZH$bkIdt2JnkC!+9&Lu9WPC52 zNqcXyO9dKDUsL~lMrF_ zP>K*$y|P~k1dvAqUaKZSRZIxnHuowqlrL2drK!6A|4AqXwVT~9MksC@leVe0#A=*X zE@dbj&~(*EZ%CWXhZZl4F|eeWC;@{PCX_WWc*+4OtZNa?rv+vPO@Eq#Hu{CF$en^M zeGr!IEEsX@@~(?l12pf_zcY|A%p7cmBWVAy}ixLA{J+b)gHOAG>LTzY-r_{` z)%E7tD#^TOMYh?uEpG*9I?wc?%NCYPFa2d8#g$)*%X(r-sj@z9Wo|UN-t$b*7>|14 zi?DSR0wRf~TXbhzkRf{#L9hsvwXhaYjYgjqlyKzJLTJhuL$(a;F~8Mt2k@;IwP_L@ zL_US+FZjjO*z3X>BHKh|vu6g*&kus^Ag-{}f(QqLHc+eRPZDx9^vaV`C>k7A^eQfT z5H6_j(3*thpgiddMvM)uXj#kyjn~F{to;asS*ldSaqT%!_zGvg*i=lRFB0~irPWJF zQs1kfyiP%&a7rte+PHEz7Yu5#G-TKY;+za@CVL6P@WhZW))m4)+*t6$z>vgABgKu; z3h{(lRwsm6(yRJ(jrTK>*e)0n8Z98P8b%#}C0ZNsv3h3wUXqr<0ylYAB*uNNEZoY) z7a2fA1|mjA5ixafE2XBN=p=_(JzKasTHXr)(RF!5vbG(eFc6Dp7?@5Z99qj^pUw@T zd1TRreJnuwl+*{r=tX8VSsi9KB}dJQzV6=krp~_Z0m*9Tu_04^@oA|8^TTb=H##r9 zI6mKt`kA_|vzvL|Gz~!CPMDng;uf&loIJ9%p@rPH^JLpO*wE6_wAuPHe^^--yE4t5 zcC_&#hvS-iM4p^^ND~>sd6GU)+tp}xx!PvP#YY@ED!kMYONiK%B4V2mv8@G@ZGVS7 zPGh!-JpZNObJ11W));ato(SpS=VR`htu+-6-|OwId>Nxr`fO6#ryP|+*Z^2f2d}2Bm74k8<})#Vp2vLQtR4u(&>=)*LDI@#LZq@j zZ5(B&2S~y4*hR$NM#k5>LumUrg2ftxmx)2lTMSB!?TGRH5ZxYQ_!Pqf7X{vOu*HY* zIBy`uqHP1Mz_4cxoe4pz`=UX#8a`=44n#42jlvc1LPRmOb@Qh6mQu&2L98?w9NE;# z88F#HFSpLKoIG>!UBcm_|BjeHSY5g_!LMcq4|uu)K(adJizH)Q4O@#!4W`wt#iHv7 z63ZGk&1Y-MW0zSjlAseSEr!dNEe$!9Q}zF_FB+CvQrL?ve%~NRBy86uY+tR_c;byi zK*^cDyw%}cdBhs5g((HPa8M^vS-8A&DLt51slE@&v2a6aMJff@SI(KOCi*x>bw($dM3j5C{nCxr%<5@Wd zmR3DWa4PCoecBjrIeF`68FHrNg9t5#AZ{0vgR1#P3&sIh=w)OUU*dnZTO+WVghv>= zfDZ{?3kDQL+NVXO(SYh7LrjO{z?6Z>lXaXfSi9SaHM|$3#C}w)Lqryd5!YTnGAn*j z7k{Y%3_-_~U{f)G$u<&yMTZv`nq(+pnPEeWXes)=kN+i}s~QL|77yYPEPEqr7*QqO zP)JBY3lgRWE($s}1pon2uxGU6s-46Yp1kcYmqU!FP1V947E;_7Vl+2P=anQY^YVdc zIIJrel`(~Lnqk5iF~;O^HRR|0jD_$xZM~LBQ2^sQ@42yh24B&q@g&79;YvjDO5}7? zJiA3UO+t#q(s22;S z1)%UgK&&h5Dky4Q`g@wvfvFHs)KHIM#bdpviKy6IPq%D%z!7V;hO=P&lgGgHw=rT* z$Ac5wGj$3tAJl^Qf7&}2HIm-I@La}4TYU2Sz8&CWZB}B?iK`Wp=iP=c1#n8^_%3I zW-_@TvO{pDpSU>SN+J*DTVy26yP=3Ws*1OX@!4u-=vBj%Z@?KG8L2@Zi6PPx<8Oj+ zz91Y?BPd)m7ESBo6N5l3UZ9Jd;S3tIXz>EQ2Tc4{l-uKTB9cKZ@<1a5=U{VL*UM|_9C tFJ3s!xXfvgGdUMks+~KK18eO52W81}Ena>j(W2;zQt<1aU=F9l@xRPopx^)i diff --git a/gui/coretool/gpsbabel_es.ts b/gui/coretool/gpsbabel_es.ts index 0c3dd7f20..1601bdb07 100644 --- a/gui/coretool/gpsbabel_es.ts +++ b/gui/coretool/gpsbabel_es.ts @@ -10,267 +10,112 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Max synthesized shortname length Longitud máxima del nombre corto - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + Allow whitespace synth. shortnames Permitir espacios en nombres cortos - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + UPPERCASE synth. shortnames MAYÚSCULAS en nombres cortos - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Make synth. shortnames unique Hacer los nombres cortos únicos - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Basename prepended to URL on output Prefijo añadido a la URL en la salida - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Use shortname instead of description Usar nombre corto en lugar de descripción - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + GPS datum (def. WGS 84) GPS datum (def. WGS 84) @@ -283,14 +128,12 @@ Puntos de interés y rutas Alan Map500 (.wpr) - Brauniger IQ Series Barograph Download - Descarga de Brauniger IQ Series Barograph + Descarga de Brauniger IQ Series Barograph - Cambridge/Winpilot glider software - Cambridge/Winpilot glider software + Cambridge/Winpilot glider software CarteSurTable data file @@ -313,12 +156,12 @@ CoastalExplorer XML - + Columbus/Visiontac V900 files (.csv) Ficheros Columbus/Visiontac V900 (.csv) - + Comma separated values Fichero separado por comas (CSV) @@ -327,12 +170,9 @@ Ficheros CompeGPS (.wpt/.trk/.rte) - - - - - - + + + Default icon name Nombre de la imagen por defecto @@ -344,45 +184,6 @@ Give points (waypoints/route points) a default radius (proximity) Dar a los puntos (puntos de interes, puntos de ruta) un radio de proximidad por defecto - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Max synthesized shortname length - Length of generated shortnames (default 16) - Longitud de los nombres cortos generados (16 por defecto) - CoPilot Flight Planner for Palm/OS CoPilot Flight Planner para Palm/OS @@ -396,7 +197,7 @@ Nombre de la categoría "no asignado" - + Data Logger iBlue747 csv Data Logger iBlue747 csv @@ -445,9 +246,8 @@ Radio para círculos - DeLorme GPL - DeLorme GPL + DeLorme GPL DeLorme PN-20/PN-30/PN-40 USB protocol @@ -462,44 +262,33 @@ Usar notas largas en los puntos de interés independientemente de la versión PN - DeLorme Street Atlas Plus - DeLorme Street Atlas Plus + DeLorme Street Atlas Plus - DeLorme Street Atlas Route - DeLorme Street Atlas Route + DeLorme Street Atlas Route - Keep turns if simplify filter is used - Preservar los giros si el filtro simplificar es usado + Preservar los giros si el filtro simplificar es usado - + Data Logger iBlue757 csv Data Logger iBlue747 csv {757 ?} - Only read turns; skip all other points - Leer sólo giros, saltar el resto de puntos - - - - Split into multiple routes at turns - + Leer sólo giros, saltar el resto de puntos - Read control points as waypoint/route/none - Leer los puntos de control como puntos de interés/ruta/ninguno + Leer los puntos de control como puntos de interés/ruta/ninguno - Synthesize track times - Calcular los tiempos del trazado + Calcular los tiempos del trazado DeLorme XMap HH Native .WPT @@ -514,55 +303,50 @@ DeLorme XMat HH Street Atlas USA .WPT (PPC) - Destinator Itineraries (.dat) - Itinerarios Destinator (.dat) + Itinerarios Destinator (.dat) - Destinator Points of Interest (.dat) - Puntos de interés Destinator (.dat) + Puntos de interés Destinator (.dat) - Destinator TrackLogs (.dat) - Trazadis Destinator (.dat) + Trazadis Destinator (.dat) - EasyGPS binary format - Formato binario EasyGPS + Formato binario EasyGPS - + Embedded Exif-GPS data (.jpg) Metadatos Exif-GPS (.jpg) - + Set waypoint name to source filename No estoy seguro Poner el nombre del punto de interés al fichero fuente - + Time-frame (in seconds) Secuencia (en segundos) - + Locate waypoint for tagging by this name Localizar el punto de interés para etiquetar con este nombre - + !OVERWRITE! the original file. Default=N ¡Seguro! que quieres sobreescribir el fichero original. Por defecto=N - Enigma binary waypoint file (.ert) - Fichero binario de puntos de interés (.ert) + Fichero binario de puntos de interés (.ert) Index of name field in .dbf @@ -573,77 +357,72 @@ Indice del campo URL en .dbf - + FAI/IGC Flight Recorder Data Format Formato de datos FAI/IGC Flight Recorder - + (integer sec or 'auto') Barograph to GPS time diff (entero seg o 'auto') Barograph a GPS tiempo diff - Franson GPSGate Simulation - Simulación Franson GPSGate + Simulación Franson GPSGate - Default speed for waypoints (knots/hr) - Velocidad por defecto para puntos de interés (nudos) + Velocidad por defecto para puntos de interés (nudos) - Split input into separate files - Dividir en ficheros separados + Dividir en ficheros separados - Fugawi - Fugawi + Fugawi G7ToWin data files (.g7t) Ficheros de datos G7ToWin - + Garmin 301 Custom position and heartrate Localización y frecuencia de latido Garmin 301 personalizado - Garmin Logbook XML - Garmin Logbook XML + Garmin Logbook XML - + Garmin MapSource - gdb Garmin MapSource - gdb - + Default category on output (1..16) Categoría por defecto en la salida (1..16) - - + + Bitmap of categories Bitmap de categorías - + Version of gdb file to generate (1..3) Versión del fichero gdb a generar (1..3) - + Drop route points that do not have an equivalent waypoint (hidden points) Eliminar puntos de ruta que no tienen un punto de interés equivalente (puntos ocultos) - + Include major turn points (with description) from calculated route Incluir giros importantes (con descripción) de la ruta calculada @@ -652,8 +431,8 @@ Garmin MapSource - mps - - + + Length of generated shortnames Longitud de los nombres cortos generados @@ -674,44 +453,55 @@ Usar valores de proximidad en el resultado (por defecto se ignoran) - + Garmin MapSource - txt (tab delimited) Garmin MapSource - txt (delimitado por tabuladores) - + Read/Write date format (i.e. yyyy/mm/dd) Leer/Escribir el formato de la fecha (por ejemplo aaaa/mm/dd) - + Distance unit [m=metric, s=statute] Unidades de distancia [m=métricas, s=statute] - - + + Write position using this grid. Escribir la posición usando esta cuadrícula. - + Precision of coordinates Precisión de las coordenadas - + Temperature unit [c=Celsius, f=Fahrenheit] Unidad de temperatura [c=Celsius, f=Fahrenheit] - + Read/Write time format (i.e. HH:mm:ss xx) Leer/Escribir el formato de la hora (por ejemplo HH:mm:ss xx) - - + + + + + + + + + + + + + Write timestamps with offset x to UTC time Escribir marcas de tiempo con un retraso de x a UTC @@ -724,164 +514,153 @@ Escribir trazados compatibles con Carto Exploreur - + Garmin POI database Base de datos Garmin POI (Puntos de Interés) - + Garmin Points of Interest (.gpi) Puntos de interés Garmin (.gpi) - + Enable alerts on speed or proximity distance Habilitar alertas sobre la velocidad o la proximidad - - Energympro GPS training watch - - - - + Source for name field in .dbf - + Source for URL field in .dbf - + ESRI shapefile - - F90G Automobile DVR GPS log file - - - - + Read all points even if latitude or longitude is missing - + Flexible and Interoperable Data Transfer (FIT) Activity file - - FlySight GPS File - - - - + Garmin G1000 datalog input filter file - + Use specified bitmap on output Usar bitmap especificado en el resultado - + Default category on output Categoría por defecto en la salida - + Don't show gpi bitmap on device No mostrar gpi bitmap en el dispositivo - + Write description to address field Escribir la descripción al campo dirección - + Write notes to address field Escribir las notas al campo dirección - + Write position to address field Escribir la posición al campo dirección - + Default proximity Proximidad por defecto - + After output job done sleep n second(s) Después de recibir la señal de trabajo realizado, dormir n segundo(s) - + Default speed Velocidad por defecto - + Create unique waypoint names (default = yes) Crear nombres únicos para los puntos de interés (defecto=si) - + Units used for names with @speed ('s'tatute or 'm'etric) Unidades usadas para nombres con @velocidad ('s'tatute p 'm'etricas) - + codec to use for writing strings - + language code to use for reading dual language files - + Erase existing courses when writing new ones - + Speed in bits per second of serial port (baud=9600) Velocidad en bits por segunod del puerto serie (4800 baudios) {9600)?} - + + override codec to use for device + + + + Garmin serial/USB protocol Protocolo serial/USB Garmin - - + + Return current position as a waypoint Devolver la posición actual como un punto de interés - - + Command unit to power itself down Mandar apagarse a la unidad de GPS - + Sync GPS time to computer time Sincronizar la hora con el ordenador - + Category number to use for written waypoints Número de la categoría donde escribir los puntos de interés @@ -890,22 +669,22 @@ Centro de Entrenamiento Garmin - + Write course rather than history, default yes Escribir la dirección en lugar de la historia, por defecto si - + Sport: Biking (deflt), Running, MultiSport, Other Deporte: Ciclismo(deflt), Correr, MultiDeporte, Otros - + Geocaching.com .loc Geocaching.com .loc - + Omit Placer name Omitir el nombre del lugar @@ -914,19 +693,16 @@ GeocachingDB para Palm/OS - Geogrid-Viewer ascii overlay file (.ovl) - Fichero de Transparencia ascii Geogrid-Viewer (.ovl) + Fichero de Transparencia ascii Geogrid-Viewer (.ovl) - Geogrid-Viewer tracklogs (.log) - Trazados Geogrid-Viewer (.log) + Trazados Geogrid-Viewer (.log) - GEOnet Names Server (GNS) - Servidor de Topónimos GEOnet (GNS) + Servidor de Topónimos GEOnet (GNS) GeoNiche .pdb @@ -941,72 +717,70 @@ Nombre de la categoría (Caché) - + GlobalSat DG-100/BT-335 Download Bajar GlobalSat DG-100/BT-335 - - - - - - - - + + + + + + Erase device data after download Borrar dispostivio después de la descarga - - - - + + + + Only erase device data, do not download anything Sólo borrar los datos del dispositivo, no descargar nada - + Google Earth (Keyhole) Markup Language Google Earth (Keyhole) Markup Language KML - + Export linestrings for tracks and routes Exportar cadenas de texto de los trazados y rutas - + Export placemarks for tracks and routes Exportar hitos de los trazados y rutas - + Width of lines, in pixels Achura de las líneas (en píxeles) - + Line color, specified in hex AABBGGRR Color de la línea, en hex AABBGGRR - + Altitudes are absolute and not clamped to ground Las altitudes son absolutas y no están pegadas al terreno - + Draw extrusion line from trackpoint to ground Extruir línea desde el trazado hasta el suelo - + Include extended data for trackpoints (default = 1) Incluir datos extendidos para los puntos de trazado (defecto=1) - + Indicate direction of travel in track icons (default = 0) Indicar la dirección del viaje con iconos (defecto=0) @@ -1015,12 +789,12 @@ Unidades usadas al escribir los comentarios ('s'tatute p 'm'etricas) - + Display labels on track and routepoints (default = 1) Mostrar etiquetas en los puntos de los trazados y las rutas (defecto= 1) - + Retain at most this number of position points (0 = unlimited) Retener como máximo este número de puntos de posición (0 = ilimitados) @@ -1029,16 +803,15 @@ Google Maps XML - Google Navigator Tracklines (.trl) - Google Navigator Tracklines (.trl) + Google Navigator Tracklines (.trl) GoPal GPS track log (.trk) Trazado GoPal GPS (.trk) - + Complete date-free tracks with given date (YYYYMMDD). Completar trazados con una fecha determinada (AAAAMMDD). @@ -1059,22 +832,22 @@ GpilotS - + GPS TrackMaker GPS TrackMaker - + GPSBabel arc filter file Fichero de filtro arc GPSBabel - + GpsDrive Format Formato GpsDrive - + GpsDrive Format for Tracks Formato GpsDrive para trazados @@ -1091,72 +864,69 @@ gpsutil - + GPX XML GPX XML - + No whitespace in generated shortnames No permitir espacios en nombres cortos generados - + Create waypoints from geocache log entries Crear puntos de interés desde las entradas de los trazados geocache - + Base URL for link tag in output URL base para enlazar etiquetas en el resultado - + Target GPX version for output Versión GPX del resultado - + Add info (depth) as Humminbird extension Añadir info (profundidad) como extensión Humminbird - + Add info (depth) as Garmin extension Añadir info (profundidad) como extensión Garmin - HikeTech - HikeTech + HikeTech - Holux (gm-100) .wpo Format - Formato Holux (gm-100) .wpo + Formato Holux (gm-100) .wpo - + Holux M-241 (MTK based) Binary File Format Formato de fichero binario Holux M-241 (MTK based) - - - - + + + + MTK compatible CSV output file Fichero de salida CSV MTK compatible - + Holux M-241 (MTK based) download Descarga de Holux M-241 (basado en MTK) - - - + + Enable logging after download Habilitar registro después de la descarga @@ -1169,84 +939,77 @@ Fihero de exportación HSA Endeavour Navigator - + HTML Output Salida a HTML - + Path to HTML style sheet Ruta a la hoja de estilo HTML - - - + + + Encrypt hints using ROT13 Emcriptar trucos usando ROT13 - - + + Include groundspeak logs if present Incluir registros 'groundspeak' si están presentes - - + + Degrees output as 'ddd', 'dmm'(default) or 'dms' Salida en grados como 'ddd', 'dmm'(defecto) o 'dms' - - + + Units for altitude (f)eet or (m)etres Unidades de altitud pies (f) o metros (m) - + Humminbird tracks (.ht) Trazados Humminbird (.ht) - + Humminbird waypoints and routes (.hwr) Puntos de interés y rutas Humminbird (.hwr) - IGN Rando track files - Trazados IGN Rando + Trazados IGN Rando - Index of track to write (if more than one in source) - Indice del trazado a escribir (si la fuente tiene más de uno) + Indice del trazado a escribir (si la fuente tiene más de uno) - iGO2008 points of interest (.upoi) - Puntos de interés iGO2008 (.upoi) + Puntos de interés iGO2008 (.upoi) - IGO8 .trk - IGO8 .trk + IGO8 .trk - Track identification number - Identificador del tratado + Identificador del tratado - Track title - Título del trazado + Título del trazado - Track description - Descripción del trazado + Descripción del trazado Generate # points @@ -1269,21 +1032,19 @@ Fichero de puntos de interés Kartex 5 - Kompass (DAV) Track (.tk) - Trazado Kompass (DAV) (.tk) + Trazado Kompass (DAV) (.tk) - Kompass (DAV) Waypoints (.wp) - Puntos de interés Kompass (DAV) (.wp) + Puntos de interés Kompass (DAV) (.wp) KuDaTa PsiTrex text Texto KuDaTa PsiTrex - + Lowrance USR Lowrance USR @@ -1304,7 +1065,7 @@ (entrada USR) Dividir los segmentos en trazados separados - + (USR output) Write version (salida USR) Escribir versión @@ -1325,97 +1086,77 @@ Magellan NAV Companion para Palm/OS - Magellan SD files (as for eXplorist) - Ficheros Magellan SD (como los del eXplorist) + Ficheros Magellan SD (como los del eXplorist) - - - Max number of comments to write (maxcmts=200) - Máximo número de comentarios a escribir (maxcmts=200) + Máximo número de comentarios a escribir (maxcmts=200) - Magellan SD files (as for Meridian) - Ficheros Magellan SD (como los del Meridian) + Ficheros Magellan SD (como los del Meridian) - Magellan serial protocol - Protocolo serie Magellan + Protocolo serie Magellan - Numeric value of bitrate (baud=4800) - Valor numérico de la conexión (baudios=4800) + Valor numérico de la conexión (baudios=4800) - Suppress use of handshaking in name of speed no sé - Suprimir el uso del agitador en nombre de la velocidad + Suprimir el uso del agitador en nombre de la velocidad - - Delete all waypoints - Borrrar todos los puntos de interés + Borrrar todos los puntos de interés - MagicMaps IK3D project file (.ikt) - Fichero de proyecto MagicMaps IK3D (.ikt) + Fichero de proyecto MagicMaps IK3D (.ikt) - Map&Guide 'TourExchangeFormat' XML - Map&Guide 'TourExchangeFormat' XML + Map&Guide 'TourExchangeFormat' XML - Include only via stations in route - Incluir sólo a través de las estaciones en la ruta + Incluir sólo a través de las estaciones en la ruta Map&Guide to Palm/OS exported files (.pdb) Fichero de exportación Map&Guide a Palm/OS (.pdb) - MapAsia track file (.tr7) - Trazado MapAsia (.tr7) + Trazado MapAsia (.tr7) - Mapopolis.com Mapconverter CSV - Mapopolis.com Mapconverter CSV + Mapopolis.com Mapconverter CSV - MapTech Exchange Format - Formato de intercambio MapTech + Formato de intercambio MapTech - Memory-Map Navigator overlay files (.mmo) - Capa de cobertura Memory-Map Navigator + Capa de cobertura Memory-Map Navigator - Write items 'locked' [default no] - Escribir elementos bloqueados [por defecto no] + Escribir elementos bloqueados [por defecto no] - Write items 'visible' [default yes] - Escribir elementos 'visibles' [por defecto si] + Escribir elementos 'visibles' [por defecto si] - Write files with internal version [n] - Escribir ficheros con la versión del sistema [n] + Escribir ficheros con la versión del sistema [n] Microsoft AutoRoute 2002 (pin/route reader) @@ -1426,62 +1167,57 @@ Microsoft Streets and Trips (lector de puntos y rutas) - Microsoft Streets and Trips 2002-2007 - Microsoft Streets and Trips 2002-2007 + Microsoft Streets and Trips 2002-2007 - Motorrad Routenplaner (Map&Guide) .bcr files - Ficheros Motorrad Routenplaner (Map&Guide) .bcr + Ficheros Motorrad Routenplaner (Map&Guide) .bcr - Index of route to write (if more than one in source) - Indice de la ruta a escribir (si la fuente tiene más de uno) + Indice de la ruta a escribir (si la fuente tiene más de uno) - New name for the route - Nuevo nombre de la ruta + Nuevo nombre de la ruta - Radius of our big earth (default 6371000 meters) - Radio del planeta tierra (por defecto 6371000 metros) + Radio del planeta tierra (por defecto 6371000 metros) MS PocketStreets 2002 Pushpin MS PocketStreets 2002 Pushpin - + MTK Logger (iBlue 747,...) Binary File Format Formato de fichero binario MTK Logger (iBlue 747,...) - + MTK Logger (iBlue 747,Qstarz BT-1000,...) download Descarga de MTK Logger (iBlue 747,...) - + National Geographic Topo .tpg (waypoints) National Geographic Topo .tpg (Puntos de interés) - + Datum (default=NAD27) esta opción es buena para América del Norte sólo Datum (default=NAD27, esta opción es buena para América del Norte sólo) - + National Geographic Topo 2.x .tpo National Geographic Topo 2.x .tpo - + National Geographic Topo 3.x/4.x .tpo National Geographic Topo 3.x/4.x .tpo @@ -1498,44 +1234,36 @@ Ficheros del Navigon Mobile Navigator .rte - Navigon Waypoints - Puntos de interés Navigon + Puntos de interés Navigon - NaviGPS GT-11/BGT-11 Download - Descarga de NaviGPS GT-11/BGT-11 + Descarga de NaviGPS GT-11/BGT-11 - Delete all track points - Borrrar todos los puntos del trazado + Borrrar todos los puntos del trazado - Delete all routes - Borrrar todas las rutas + Borrrar todas las rutas - Clear the datalog - Limpiar la memoria + Limpiar la memoria - Read from datalogger buffer - Leer de la memoria + Leer de la memoria - NaviGPS GT-31/BGT-31 datalogger (.sbp) - Memoria del NaviGPS GT-31/BGT-31 + Memoria del NaviGPS GT-31/BGT-31 - NaviGPS GT-31/BGT-31 SiRF binary logfile (.sbn) - Fichero de almacenamiento binario del NaviGPS GT-31/BGT-31 SiRF + Fichero de almacenamiento binario del NaviGPS GT-31/BGT-31 SiRF Naviguide binary route file (.twl) @@ -1550,14 +1278,12 @@ 'n' - Conserva el nombre del punto de interés existente, 'y' - cambia el nombre de los puntos de interés - Navitel binary track (.bin) - Trazado binario Navitel (.bin) + Trazado binario Navitel (.bin) - Navitrak DNA marker format - Fomato del marcador Navitrak DNA + Fomato del marcador Navitrak DNA NetStumbler Summary File (text) @@ -1585,117 +1311,125 @@ El nombre corto es la MAC address - NIMA/GNIS Geographic Names File - Fichero de topónimos NIMA/GNIS + Fichero de topónimos NIMA/GNIS - + NMEA 0183 sentences Frases NMEA 018 - + Max length of waypoint name to write Longitud máxima del nombre del punto de interés - + + Image Offset Time (+HH:MM or -HH:MM) + + + + + Google Takeout Location History + + + + Read/write GPRMC sentences Leer/escribir GPRMC frases - + Read/write GPGGA sentences Leer/escribir GPGGA frases - + Read/write GPVTG sentences Leer/escribir GPVTG frases - + Read/write GPGSA sentences Leer/escribir GPGSA frases - + Decimal seconds to pause between groups of strings Demora en décimas de segundo entre textos - + Append realtime positioning data to the output file instead of truncating Añadrir el la hora del poscionamiento al fichero de salida en lugar de truncarla - + Speed in bits per second of serial port (baud=4800) Velocidad en bits por segunod del puerto serie (4800 baudios) - + Write tracks for Gisteq Phototracker Escribir trazados para el Gisteq Phototracker - Nokia Landmark Exchange - Nokia Landmark Exchange + Nokia Landmark Exchange - + OpenStreetMap data files Ficheros de datos de OpenStreetMap (gratuitos) - + Write additional way tag key/value pairs Escribir pares adiciones de clave/valor para la etiqueta de sentido - + Write additional node tag key/value pairs Escribir pares adiciones de clave/valor para la etiqueta de nodo - + Use this value as custom created_by value Usar este valor como valor personalizado - + OziExplorer OziExplorer - + Write all tracks into one file Escribir todos los trazados a un fichero único - + Waypoint foreground color Color del primer plano del punto de interés - + Waypoint background color Color del fondo del punto de interés - + Proximity distance Distancia de proximidad - + Unit used in altitude values Unidades usadas en los valores de altitud - + Unit used in proximity values Unidades usadas en los valores de proximidad @@ -1744,24 +1478,20 @@ Quovadis - Raymarine Waypoint File (.rwf) - Fichero de puntos de interés Raymarine (.rwf) + Fichero de puntos de interés Raymarine (.rwf) - Default location - Localización por defecto + Localización por defecto - Ricoh GPS Log File - Fichero de memoria de Ricoh GPS + Fichero de memoria de Ricoh GPS - See You flight analysis data - Revisar los datos del análisis de tu vuelo + Revisar los datos del análisis de tu vuelo Skymap / KMD150 ascii files @@ -1776,8 +1506,8 @@ Baudios usados para inicializar el dispositivo, autodetectar=0 - - + + Baud rate used for download Baudios usados para la descarga @@ -1802,57 +1532,51 @@ Ficheros Suunto Trek Manager (STM) WaypointPlus - Swiss Map 25/50/100 (.xol) - Swiss Map 25/50/100 (.xol) + Swiss Map 25/50/100 (.xol) Tab delimited fields useful for OpenOffice, Ploticus etc. Campos delimitados por tabuladores, útila para OpenOffice, Ploticus etc. - + Textual Output Salida literal - + Suppress separator lines between waypoints Suprimir saltos de línea entre los puntos de interés - + Write each waypoint in a separate file escribir cada punto de interés en un fichero separado - TomTom Itineraries (.itn) - TomTom Itineraries (.itn) + TomTom Itineraries (.itn) - TomTom POI file (.asc) - TomTom POI file (.asc) + TomTom POI file (.asc) - TomTom POI file (.ov2) - TomTom POI file (.ov2) + TomTom POI file (.ov2) TopoMapPro Places File Fichero de TopoMapPro Places - TrackLogs digital mapping (.trl) - Mapa digital TrackLogs (.trl) + Mapa digital TrackLogs (.trl) - Index of track (if more than one in source) - Indice del trazado (si la fuente tiene más de uno) + Indice del trazado (si la fuente tiene más de uno) U.S. Census Bureau Tiger Mapping Service @@ -1863,359 +1587,283 @@ Suprimir etiquetas en los puntos creados - - + Time zone ID - + Attempt to recovery data from corrupt file - + Don't create waypoints for non-user points - + Garmin Training Center (.tcx/.crs/.hst/.xml) - - Geogrid-Viewer binary overlay file (.ovl) - - - - + Compact Output. Default is off. - + GeoJson - + GlobalSat DG-200 Download - + list tracks - + get track - - - - + + + + Dump raw data to this file - + GlobalSat GH625XT GPS training watch - - Google Directions XML - - - - + Write KML track (default = 0) - + Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical, 'a'viation) - + Rotate colors for tracks and routes (default automatic) - + Precision of coordinates, number of decimals - + GPS Tracking Key Pro text - + Precision of elevations, number of decimals - - + + Size of blocks in KB to request from device - - iGo Primo points of interest (.upoi) - - - - + (USR input) Ignore event marker icons on read - + (USR output) Treat waypoints as icons on write - + (USR output) Merge into one segmented trail - + (USR input) Break segments into separate trails - + (USR output) Output file title string - + (USR output) Device serial number - + (USR output) Output file content description - - Mainnav - - - - - Mapbar (China) navigation track for Sonim Xp3300 - - - - - Mapfactor Navigator - - - - - Speed in bits per second of serial port (autodetect=0) - - - - - Download logged fixes - - - - - Show device status - - - - - MediaTek Locus - - - - - + + First sector to be read from the device - - + + Baud rate used to init device (0=autodetect) - - + + Last sector to be read from the device (-1: smart read everything) - - + + Disable output (useful with erase) - - + + Number of sectors to read at once (0=use single sector mode) - + POI for Home Symbol as lat:lng[:alt] - + POI for Car Symbol as lat:lng[:alt] - + POI for Boat Symbol as lat:lng[:alt] - + POI for Heart Symbol as lat:lng[:alt] - + POI for Bar Symbol as lat:lng[:alt] - + MiniHomer, a skyTraq Venus 6 based logger (download tracks, waypoints and get/set POI) - + Garmin Mobile XT ([ATRK]/STRK) - + Track name processing option ([0]-nrm/1-ign) - + Mobile Garmin XT Track files - - Motoactiv CSV - - - - - MyNav TRC format - - - - + Accept position fixes in gpgga marked invalid - - Compact binary representation - - - - + codec to use for reading and writing strings (default windows-1252) - + Qstarz BL-1000 - + Set location finder target location as lat,lng - + Configure logging parameter as tmin:tmax:dmin:dmax - - - + + + Seconds that GPS time tracks UTC (0: best guess) - - - + + + GPS week rollover period we're in (-1: best guess) - + SkyTraq Venus based loggers (download) - + First sector to be read from the file - + Last sector to be read from the file (-1: read till empty sector) - + SkyTraq Venus based loggers Binary File Format - + Format for subtitles - + SubRip subtitles for video mapping (.srt) - + Tab delimited fields useful for OpenOffice - - - Teletype [ Get Jonathon Johnson to describe - - - - - TomTom Places Itineraries (.itn) - - Generate file with lat/lon for centering map Crear fichero con lat/lon para centrar el mapa @@ -2261,22 +1909,22 @@ La descripción ya es la marca - + Universal csv with field structure in first line Formato csv universal con la estructura de campos en la primera línea - + Write name(s) of format(s) from input session(s) Escribir los de los formatos de entrada en cada sesión - + Write filename(s) from input session(s) Escribir el nombre de los ficheros de entrada en cada sesión - + Vcard Output (for iPod) Salida Vcard (para iPod) @@ -2305,17 +1953,17 @@ Nombre del icono de infraestructura cerrada - + Video position for which exact GPS time is known (hhmmss[.sss], default is 00:00:00,000) - + GPS time at position video_time (hhmmss[.sss], default is first timestamp of track) - + GPS date at position video_time (yyyymmdd, default is first timestamp of track) @@ -2332,46 +1980,32 @@ Nombre del icono abierto ad-hoc - - Wintec TES file - - - - Wintec WBT-100/200 Binary File Format - Formato de fichero binario Wintec WBT-100/200 + Formato de fichero binario Wintec WBT-100/200 - Wintec WBT-100/200 GPS Download - Descarga de Wintec WBT-100/200 GPS + Descarga de Wintec WBT-100/200 GPS - Wintec WBT-201/G-Rays 2 Binary File Format - Formato de fichero binario Wintec WBT-201/G-Rays 2 + Formato de fichero binario Wintec WBT-201/G-Rays 2 - XAiOX iTrackU Logger - Registors del XAiOX iTrackU + Registors del XAiOX iTrackU - - Appends the input to a backup file - Añadir la entrada a una copia de seguridad + Añadir la entrada a una copia de seguridad - - Only waypoints that are not the backup file - Sólo los puntos que no están en la copia de seguridad + Sólo los puntos que no están en la copia de seguridad - XAiOX iTrackU Logger Binary File Format - Formato de fichero binario XAiOX iTrackU Logger + Formato de fichero binario XAiOX iTrackU Logger Yahoo Geocode API data diff --git a/gui/coretool/gpsbabel_fr.qm b/gui/coretool/gpsbabel_fr.qm index b75fdd622fcf3fcdaf9d80c7ba50405be4e5e0dd..7f9d4c4efc2d3dde0f722ed114d10118b7a1f396 100644 GIT binary patch delta 748 zcmW+!TS!z<6kRiOA9H8!-0NHOl{z}9zVy~8vr)9=)#GVV}SY&Qe!3oLy}7Faiw!!bum5~aQUOknWBI97*&G;W!##Ot6*R?~ZMlSNbQWds7t znU?$>K#pTxWi0}N%nW)j0n#mIDKh~$U}Sz*`2t)coB!z=5D?1V5S@r1o-GX(06v=? zc~=iOrm^F@f@b#Hxw}AkHM`+91o-xGV(<=N3g_g$a=>AgJDODi=q+8`={09y&nB0e z<^pJ@xd-c&fVYV^Ws^h49X=!^oP>k;*eePdUE$yC%n&|@ADSb<&@FzrMPfli3j?cxEFw`Ok@(0Ncf=Gxh+uLA#rqNn0|A`h2(lz;HMK;$L;})S^PUhBXFHF zaLO#;++av;HPXyPLuqg{MRw9K@wogn(b=j`$K1G|Qcjjss2u za(90NElIEZtKc&&n>i1N@UsPIJoHM1)U14z2W=l5^8{tsYu%Ra)1p?|{1m0h|GBaj akYVEjqg1w96T>MTVI2w^q1g11cKttKHPA)? delta 2808 zcmaJ?3vgUz6+XMkzF$p~P1+`D{*Y|CDWTaWG_8$wrVv!HwAi$P)Q;qK_il5|eJuBp z2es~Cizp~+uNkd&gb2vM&yIeysT6pX63t{L8V)7n&QM8=5-(+Z%`~g0!pm1){_u`mESWbZrN{ zwY!3-L-!<3B#D+KJ;K%vM0Fh=@kN|p^|D0ssAVDUYE@oGiwo=1ti%PMa3;y~A`im%qU5Uul8 zKBS%?s(mY zE+<<5yzk)J5K$oOoBcL`uSodLJ^u}&>ic~cIFQz-e8t}ke4c1i-1koHSs?WIqv;Qb zI*EHIpYNFMaf7k9BF!Zwj3xE0&QOii6Eek_6-GTP@bpVnI zY#FuzJRkVs2d@w{-V-?cYdE}qJTN<2iU)_5nQS4G=Zyg*q)kTJsA0gtJh{l;oJ!oI{)E0YYqGP>p0?*dy^!p*$ z*%B$ zbKf-X)x-{_HxMm97(4f?3L@VZV;94)9~+4`+*J*tJ{AAuIQ*>nb9}JsUMf=kj`-lk z58>j!;(PAEM*6Y1c*jwq%!T;l$FD#l=i~2uEek`b_}{kxSmxu2&2lAC&zi*8t6UNT zi6^!KK=N2(`pY*WbMGdeJ@ZXS?_}aV?UzKg$0W$%AwZ$KDNQ1&WRirpPK=D1lU`3G z(MmUAIfo?;Tc&+E)>O5uPs|IJY%*EP3Z|r~_H^t?k7_64t@iD~)b2EHXfR{po&i$@ z5*(Am&YF&=LG3|!B|rXcC2K}O6mu-E>1<4xC}@&u8Z14cYNpXSthd{@#4me#?5T!i z#DsMVP+`ZeN;WlD^@*}*icFAYrfZfd8Ufg?%xb#m;lX{B-wL?5412n+sn-M^fwJ5} z8AshBE2b`FN0^IYsjW@_g`hdroUB=Nw+wzJk{AowiMr*I;RG(@so>99X2fTloH@({ zP~^^X7^}{@j1hBacS0@0yyj*#D_c2{X{tQIMkRq6rjrDNN$Ml&3QzGf^fBDkLB5;G zlBZE5kcYj0-j{*7i-S=fV;M+za*%t>6kw9^<~ws(P#}2Wr(?%p_RwI0Jt3)RA}G4I|ZP|VNii_1ui&nhV1Y& zCBg*kyUJnoI(FxR9B>PaiYcvdluEnS&RyZ!I_ss1hpr$wW{BLEw7bj=YK90l?+`Cn zQ?C;S2gi$@>zV^r%a+_^7MxW#IDUo$bT#L;3AC6VTtWuR!fM;WWv+`t&Q(`0Ge)F> zQ|cO6)#rL`0^-wo$r1cI}8O#-WtBhoU zuFOs$Cs_ukNwaiNwV#QCZVt0_ZoUKdbZ=ar$z+&<{-Yc1OMAuWA}UKoSRngk-SPzI zg9ob9yIctN!@lIFxvbrU^VGQ&CQ>KPl-eC1^Zu-s=~=szGn3U+Q`h8qE|_4HJ7}lV z4?9&&oq29`wZC`^^*N=(E%Kh@N_dTvD~@IkBVOyAKVJD+8g@MDPEJwrPJa2hg%maQ zqts1wpMu4oC@4cL2wYUW`j<50BD(Pa^_R`K09<#x-B@tL1LSqVC9x1XpK*dXAc0C% zvPgtwN?J;A07Su8N-D_n#b>afV7fB0XIp=aFV<8;V{suB8c&7eccH!or!sjmG@vOF zRyxJ!d1r_B9~J1ZQ%2I!Zxsr core - + (integer sec or 'auto') Barograph to GPS time diff (entier sec ou 'auto') Barograph de différence temporelle GPS @@ -25,51 +25,29 @@ Nom de l'icône pour Ad-hoc ouvert - + After output job done sleep n second(s) Faire une pause de n secondes lorsque l'éxécution est terminée - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + Allow whitespace synth. shortnames Autoriser les espaces dans les noms courts - + Altitudes are absolute and not clamped to ground Les altitudes sont absolue et idépendantes du sol @@ -78,18 +56,18 @@ Ajouter icon_descr à la description - + Append realtime positioning data to the output file instead of truncating Ajoute les données de position en temps réel au fichier de sortie plutôt que de le tronquer - + Base URL for link tag in output URL de base pour l'étiquette de lien en sortie - - + + Bitmap of categories Cartographie des catégories @@ -98,7 +76,7 @@ Nom de la catégorie - + Category number to use for written waypoints Numéro de catégorie pour les balises écrites @@ -107,23 +85,22 @@ Couleur des lignes ou des notes - - + Command unit to power itself down Ordonner au GPS de s'éteindre - + Complete date-free tracks with given date (YYYYMMDD). Ajouter une date donnée (AAAAMMJJ) à une trace sans horodatage - + Create unique waypoint names (default = yes) Créer des noms de balises uniques (oui par défaut) - + Create waypoints from geocache log entries Créer des balises à partir des entrés de log géocache @@ -136,7 +113,7 @@ Nom de la base de données (nom de fichier) - + Datum (default=NAD27) Datum (défaut=NAD27) @@ -145,79 +122,70 @@ Nombre de jours après lesquels les points sont considérés comme anciens - + Decimal seconds to pause between groups of strings Dixième de seconde de pause entre les groups de chaines - + Default category on output Catégorie par défaut en sortie - + Default category on output (1..16) Catégorie par défaut en sortie (1..16) - - - - - - + + + Default icon name Nom d'icone par défaut - Default location - Endroit par défaut + Endroit par défaut - + Default proximity Proximité par défaut - + Default speed Vitesse par défaut - Default speed for waypoints (knots/hr) - Vitesse par défaut pour les balises (noeuds par heures) + Vitesse par défaut pour les balises (noeuds par heures) - - + + Degrees output as 'ddd', 'dmm'(default) or 'dms' Ecrire les dégrés en 'd°d°d°', 'd°m'm''(défaut) ou 'd°m's''' - Delete all routes - Supprimer toutes les routes + Supprimer toutes les routes - Delete all track points - Supprimer tous les points de traces + Supprimer tous les points de traces - - Delete all waypoints - Supprimer toutes les balises + Supprimer toutes les balises - + Display labels on track and routepoints (default = 1) Afficher les labels sur les traces et les points de routes (défaut = 1) - + Distance unit [m=metric, s=statute] Unité de distance [m = métrique, s=stature] @@ -230,29 +198,29 @@ Ne pas ajouter les URLs aux descriptions - + Don't show gpi bitmap on device Ne pas afficher les images gpi sur le périphérique - + Draw extrusion line from trackpoint to ground Générer une ligne d'extrusion entre le sol et le point de trace - + Drop route points that do not have an equivalent waypoint (hidden points) Eliminer les points de route qui n'ont pas de balises équivallentes (points cachés) - + Enable alerts on speed or proximity distance Activer les alertes de vitesse ou de proximité - - - + + + Encrypt hints using ROT13 Encrypter les signes en ROT13 @@ -261,24 +229,22 @@ Encrypter les signes avec ROT13 - - - - - - - - + + + + + + Erase device data after download Effacer les données du périphérique après téléchargement - + Export linestrings for tracks and routes Exporter les chaînes de caractères pour les traces et les routes - + Export placemarks for tracks and routes Exporter les marqueurs pour les traces et les routes @@ -301,39 +267,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + GPS datum (def. WGS 84) @@ -346,25 +290,24 @@ Ignorer les marqueurs d'événements lors de la lecture - + Include extended data for trackpoints (default = 1) Inclure les données étendues pour les points de trace (défaut = 1) - - + + Include groundspeak logs if present Inclure les logs groundspeak si disponible - + Include major turn points (with description) from calculated route Inclure les points de virage (avec description) de la route calculée - Include only via stations in route - Inclure seulement les étapes dans la route + Inclure seulement les étapes dans la route Include short name in bookmarks @@ -379,7 +322,7 @@ Index du champ URL dans le .dbf - + Indicate direction of travel in track icons (default = 0) Indiquer la direction de déplacement dans les icones de la trace (défaut = 0) @@ -392,95 +335,50 @@ Nom de l'icône pour l'Infrastructure ouverte - Keep turns if simplify filter is used - Garder les virages si le filtre simplifié est utilisé + Garder les virages si le filtre simplifié est utilisé - - + + Length of generated shortnames Longueur des nom courts générés - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Max synthesized shortname length Length of generated shortnames (default 16) Longueur des nom courts générés (défaut : 16) - + Line color, specified in hex AABBGGRR Couleur de la ligne, spécifié en hexadécimal AABBGGRR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Make synth. shortnames unique Les noms courts sont tous différents @@ -505,68 +403,27 @@ Type de marqueur pour les points non trouvés - + Max length of waypoint name to write Longueur maximum du nom de la balise - - - Max number of comments to write (maxcmts=200) - Nombre maximum de commentaires à écrire (maxcmts=200) + Nombre maximum de commentaires à écrire (maxcmts=200) Max shortname length when used with -s Longueur maximum du nom court lorsque utilisé avec l'option -s - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Max synthesized shortname length - Longueur max. de noms courts générés - Merge output with existing file Fusionner la sortie avec un fichier existant - - - - + + + + MTK compatible CSV output file Fichier de sortie CSV compatible MTK @@ -575,16 +432,15 @@ Nom de la catégorie 'non assignée' - New name for the route - Nouveau nom pour la route + Nouveau nom pour la route No separator lines between waypoints Supprimer les lignes de séparation entre les balises - + No whitespace in generated shortnames Supprimer les espaces dans les noms courts générés @@ -597,32 +453,30 @@ Ne pas récupérer les noms d'icones non encryptés - Numeric value of bitrate (baud=4800) - Valeur numérique de la vitesse de transfert (4800 bauds) + Valeur numérique de la vitesse de transfert (4800 bauds) - + Omit Placer name Omettre le nom du Placer - Only read turns; skip all other points - Lire seulement les virages; ne pas tenire compte des autres points + Lire seulement les virages; ne pas tenire compte des autres points - + Path to HTML style sheet Chemin vers une feuille de style HTML - + Precision of coordinates Précision des coordonnées - + Proximity distance Distance de proximité @@ -631,57 +485,55 @@ Rayon des cercles - Radius of our big earth (default 6371000 meters) - Rayon de la terre (défaut : 6371000 mètres) + Rayon de la terre (défaut : 6371000 mètres) - Read control points as waypoint/route/none - Lire les points de contrôle en temps à la balise/route/rien + Lire les points de contrôle en temps à la balise/route/rien Read/Write date format (i.e. DDMMYYYY) Lire/Ecrire le format date (i.e. JJMMYYYY) - + Read/Write date format (i.e. yyyy/mm/dd) Lire/Ecrire le format de date (i.e. YYYY/MM/DD) - + Read/write GPGGA sentences Lire/Ecrire des séquences GPGGA - + Read/write GPGSA sentences Lire/Ecrire des séquences GPGSA - + Read/write GPRMC sentences Lire/Ecrire des séquences GPRMC - + Read/write GPVTG sentences Lire/ECrire des séquences GPVTG - + Read/Write time format (i.e. HH:mm:ss xx) Lire/Ecrire le format horaire (i.e. HH:mm:ss xx) - + Retain at most this number of position points (0 = unlimited) Retenir au maximum ce nombre de points de positions (0 = illimité) - - + + Return current position as a waypoint Renvoyer la position courante en tant que balise @@ -692,37 +544,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Basename prepended to URL on output Set waypoint name to source filename. Faire correspondre les nom de la balise au nom du fichier source. @@ -732,79 +562,32 @@ Le nom court est l'adresse MAC - + Speed in bits per second of serial port (baud=4800) Vitesse du port série en bits par seconde (baud=4800) - Split input into separate files - Découper l'entrée en fichiers séparés + Découper l'entrée en fichiers séparés - Split into multiple routes at turns - Séparer en plusieurs routes à chaque virage + Séparer en plusieurs routes à chaque virage - + Write course rather than history, default yes - + Sport: Biking (deflt), Running, MultiSport, Other - - - Geogrid-Viewer ascii overlay file (.ovl) - - - - - Geogrid-Viewer tracklogs (.log) - - - - - Index of track to write (if more than one in source) - - - - - iGO2008 points of interest (.upoi) - - - - - IGO8 .trk - - - - - Track identification number - - - - - Track title - - - - - Track description - - Starting seed of the internal number generator Racine du générateur de nombres internes - - - Index of route to write (if more than one in source) - - Stealth encrypted icon name Récupérer les noms d'icones encryptés @@ -814,104 +597,89 @@ Récupérer les noms d'icones non encryptés - + Set location finder target location as lat,lng - + Configure logging parameter as tmin:tmax:dmin:dmax - - - + + + Seconds that GPS time tracks UTC (0: best guess) - - - + + Image Offset Time (+HH:MM or -HH:MM) + + + + + Google Takeout Location History + + + + + + GPS week rollover period we're in (-1: best guess) - + codec to use for reading and writing strings (default windows-1252) - + SkyTraq Venus based loggers (download) - + First sector to be read from the file - + Last sector to be read from the file (-1: read till empty sector) - + SkyTraq Venus based loggers Binary File Format - + Format for subtitles - + SubRip subtitles for video mapping (.srt) - - Swiss Map 25/50/100 (.xol) - - - - + Tab delimited fields useful for OpenOffice - - Teletype [ Get Jonathon Johnson to describe - - - - - TomTom Places Itineraries (.itn) - - - - - Index of track (if more than one in source) - - - - + Write name(s) of format(s) from input session(s) - + Write filename(s) from input session(s) - - - Wintec TES file - - String to separate concatenated address fields (default=", ") Chaine de caractère pour séparer les champs d'adresse (", " par défaut) @@ -925,14 +693,13 @@ Suypprimer les géocaches désactivées - + Suppress separator lines between waypoints Supprimer les lignes séparatrices entre les balises - Suppress use of handshaking in name of speed - Supprimer les controles pour améliorer les performances + Supprimer les controles pour améliorer les performances Suppress whitespace in generated shortnames @@ -943,22 +710,21 @@ Symbole à utiliser pour les données de type point - + Sync GPS time to computer time Synchroniser l'heure du GPS avec l'heure du PC - Synthesize track times - Simplifier l'horodatage des traces + Simplifier l'horodatage des traces - + Target GPX version for output Version du fichier GPX pour la sortie - + Temperature unit [c=Celsius, f=Fahrenheit] Unité de température (c=Celsius, f=Farenheit) @@ -975,13 +741,13 @@ Type de fichier .an1 - - + + Units for altitude (f)eet or (m)etres Unités d'altitude (p)ieds ou (m)ètres - + Units used for names with @speed ('s'tatute or 'm'etric) Unités utilisées avec @vitess ('s'tatute ou 'm'étrique) @@ -992,38 +758,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + UPPERCASE synth. shortnames Noms courts en MAJUSCULE @@ -1038,48 +782,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Use shortname instead of description Utiliser le nom court au lieu de la description - + Use specified bitmap on output Utiliser l'images spécifiée en sortie - + Version of gdb file to generate (1..3) Version du fichier gbd à générer (1..3) @@ -1088,12 +809,12 @@ Version du fichier mapsource à créer (3,4,5) - + Waypoint background color Couleur de fond de la balise - + Waypoint foreground color Couleur de la balise @@ -1106,54 +827,65 @@ Largeur de la carte en pixels - + Width of lines, in pixels Largeur des lignes en pixels - + Write additional node tag key/value pairs Ecrire des étiquettes de noeuds additionnelles clé/valeurs - + Write additional way tag key/value pairs Ecrire des étiquettes de chemins additionnelles clé/valeurs - + Write all tracks into one file Ecrire toutes les traces dans un fichier - + Write description to address field Ecrire la description dans le champ d'adresse - + Write each waypoint in a separate file Ecrire chaque balise dans un fichier séparé - + Write notes to address field Ecrire les notes dans le champ d'adresse - + Write position to address field Ecrire la position dans le champ d'adresse - - + + Write position using this grid. Ecrire la position en utilisant cette grille. - - + + + + + + + + + + + + + Write timestamps with offset x to UTC time Ecrire l'horodatage avec un décalage de x par rapport à l'heure UTC @@ -1162,7 +894,7 @@ Ecrire des traces compatibles avec CartoExploreur - + Write tracks for Gisteq Phototracker Ecrire les traces pour Gisteq Phototracker @@ -1172,911 +904,542 @@ - Brauniger IQ Series Barograph Download - - - - - Cambridge/Winpilot glider software + Columbus/Visiontac V900 files (.csv) - Columbus/Visiontac V900 files (.csv) + Comma separated values - - Comma separated values + + Data Logger iBlue747 csv - - Data Logger iBlue747 csv + + Embedded Exif-GPS data (.jpg) - - DeLorme GPL + + Set waypoint name to source filename - - DeLorme Street Atlas Plus + + Data Logger iBlue757 csv - - DeLorme Street Atlas Route + + Time-frame (in seconds) - - Destinator Itineraries (.dat) + + Locate waypoint for tagging by this name - - Destinator Points of Interest (.dat) + + !OVERWRITE! the original file. Default=N - - Destinator TrackLogs (.dat) + + Source for name field in .dbf - - EasyGPS binary format + + Source for URL field in .dbf - - Embedded Exif-GPS data (.jpg) - - - - - Set waypoint name to source filename - - - - - Data Logger iBlue757 csv - - - - - Time-frame (in seconds) - - - - - Locate waypoint for tagging by this name - - - - - !OVERWRITE! the original file. Default=N - - - - - Energympro GPS training watch - - - - - Enigma binary waypoint file (.ert) - - - - - Source for name field in .dbf - - - - - Source for URL field in .dbf - - - - + ESRI shapefile - - F90G Automobile DVR GPS log file - - - - + FAI/IGC Flight Recorder Data Format - + Read all points even if latitude or longitude is missing - + Flexible and Interoperable Data Transfer (FIT) Activity file - - FlySight GPS File - - - - - Franson GPSGate Simulation - - - - - Fugawi - - - - + Garmin 301 Custom position and heartrate - + Garmin G1000 datalog input filter file - - Garmin Logbook XML - - - - + Garmin MapSource - gdb - + Garmin MapSource - txt (tab delimited) - + Garmin POI database - + codec to use for writing strings - + language code to use for reading dual language files - + Garmin Points of Interest (.gpi) - + Erase existing courses when writing new ones - + Speed in bits per second of serial port (baud=9600) Vitesse du port série en bits par seconde (baud=4800) {9600)?} - - Garmin serial/USB protocol + + override codec to use for device - - Garmin Training Center (.tcx/.crs/.hst/.xml) + + Garmin serial/USB protocol - - Geocaching.com .loc + + Garmin Training Center (.tcx/.crs/.hst/.xml) - - GEOnet Names Server (GNS) + + Geocaching.com .loc - + GlobalSat DG-100/BT-335 Download - - - - + + + + Only erase device data, do not download anything - + Google Earth (Keyhole) Markup Language - - Google Navigator Tracklines (.trl) - - - - + GPS TrackMaker - + GPSBabel arc filter file - + GpsDrive Format - + GpsDrive Format for Tracks - + GPX XML - + Add info (depth) as Humminbird extension - + Add info (depth) as Garmin extension - - HikeTech - - - - - Holux (gm-100) .wpo Format - - - - + Holux M-241 (MTK based) Binary File Format - + Holux M-241 (MTK based) download - - - + + Enable logging after download - + HTML Output - + Humminbird tracks (.ht) - + Humminbird waypoints and routes (.hwr) - - IGN Rando track files - - - - - Kompass (DAV) Track (.tk) - - - - - Kompass (DAV) Waypoints (.wp) - - - - + Lowrance USR - + (USR output) Write version - - Magellan SD files (as for eXplorist) - - - - - Magellan SD files (as for Meridian) - - - - - Magellan serial protocol - - - - - MagicMaps IK3D project file (.ikt) - - - - - Map&Guide 'TourExchangeFormat' XML - - - - - MapAsia track file (.tr7) - - - - - Mapopolis.com Mapconverter CSV - - - - - MapTech Exchange Format - - - - - Memory-Map Navigator overlay files (.mmo) - - - - - Write items 'locked' [default no] - - - - - Write items 'visible' [default yes] - - - - - Write files with internal version [n] - - - - - Microsoft Streets and Trips 2002-2007 - - - - - Motorrad Routenplaner (Map&Guide) .bcr files - - - - + MTK Logger (iBlue 747,...) Binary File Format - + MTK Logger (iBlue 747,Qstarz BT-1000,...) download - + National Geographic Topo .tpg (waypoints) - + National Geographic Topo 2.x .tpo - + National Geographic Topo 3.x/4.x .tpo - - Navigon Waypoints - - - - - NaviGPS GT-11/BGT-11 Download - - - - - Clear the datalog - - - - - Read from datalogger buffer - - - - - NaviGPS GT-31/BGT-31 datalogger (.sbp) - - - - - NaviGPS GT-31/BGT-31 SiRF binary logfile (.sbn) - - - - - + Time zone ID - + Attempt to recovery data from corrupt file - + Don't create waypoints for non-user points - - Geogrid-Viewer binary overlay file (.ovl) - - - - + Compact Output. Default is off. - + GeoJson - + GlobalSat DG-200 Download - + list tracks - + get track - - - - + + + + Dump raw data to this file - + GlobalSat GH625XT GPS training watch - - Google Directions XML - - - - + Write KML track (default = 0) - + Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical, 'a'viation) - + Rotate colors for tracks and routes (default automatic) - + Precision of coordinates, number of decimals - + GPS Tracking Key Pro text - + Precision of elevations, number of decimals - - + + Size of blocks in KB to request from device - - iGo Primo points of interest (.upoi) - - - - + (USR input) Ignore event marker icons on read - + (USR output) Treat waypoints as icons on write - + (USR output) Merge into one segmented trail - + (USR input) Break segments into separate trails - + (USR output) Output file title string - + (USR output) Device serial number - + (USR output) Output file content description - - Mainnav - - - - - Mapbar (China) navigation track for Sonim Xp3300 - - - - - Mapfactor Navigator - - - - - Speed in bits per second of serial port (autodetect=0) - - - - - Download logged fixes - - - - - Show device status - - - - - MediaTek Locus - - - - - + + First sector to be read from the device - - + + Baud rate used to init device (0=autodetect) - - + + Last sector to be read from the device (-1: smart read everything) - - + + Disable output (useful with erase) - - + + Number of sectors to read at once (0=use single sector mode) - + POI for Home Symbol as lat:lng[:alt] - + POI for Car Symbol as lat:lng[:alt] - + POI for Boat Symbol as lat:lng[:alt] - + POI for Heart Symbol as lat:lng[:alt] - + POI for Bar Symbol as lat:lng[:alt] - + MiniHomer, a skyTraq Venus 6 based logger (download tracks, waypoints and get/set POI) - + Garmin Mobile XT ([ATRK]/STRK) - + Track name processing option ([0]-nrm/1-ign) - + Mobile Garmin XT Track files - - Motoactiv CSV - - - - - MyNav TRC format - - - - - Navitel binary track (.bin) - - - - - Navitrak DNA marker format - - - - - NIMA/GNIS Geographic Names File - - - - + Accept position fixes in gpgga marked invalid - + NMEA 0183 sentences - - Compact binary representation - - - - - Nokia Landmark Exchange - - - - + OpenStreetMap data files - + Use this value as custom created_by value - + OziExplorer - + Unit used in altitude values - + Unit used in proximity values - - Raymarine Waypoint File (.rwf) - - - - - Ricoh GPS Log File - - - - - See You flight analysis data - - - - - + + Baud rate used for download - + Qstarz BL-1000 - + Video position for which exact GPS time is known (hhmmss[.sss], default is 00:00:00,000) - + GPS time at position video_time (hhmmss[.sss], default is first timestamp of track) - + GPS date at position video_time (yyyymmdd, default is first timestamp of track) - + Textual Output - - TomTom Itineraries (.itn) - - - - - TomTom POI file (.asc) - - - - - TomTom POI file (.ov2) - - - - - TrackLogs digital mapping (.trl) - - - - + Universal csv with field structure in first line - + Vcard Output (for iPod) - - - Wintec WBT-100/200 Binary File Format - - - - - Wintec WBT-100/200 GPS Download - - - - - Wintec WBT-201/G-Rays 2 Binary File Format - - - - - XAiOX iTrackU Logger - - - - - - Appends the input to a backup file - - - - - - Only waypoints that are not the backup file - - - - - XAiOX iTrackU Logger Binary File Format - - diff --git a/gui/coretool/gpsbabel_hu.qm b/gui/coretool/gpsbabel_hu.qm index 57bcfd6f078057945011cf34da8fe8bcace7ac59..71496ce1d34704d352be6a636242310216460d39 100644 GIT binary patch delta 740 zcmW-fdq@;f6vn@O%+Aj4?2PW}`gVQfW0k@XgC2&KK~kBOrY?bo8WyHVR*Kl7W?}}Z z<6>qMk|A1(v1J*Wi4U+4$_g|xv&_mO3CRpaI{Me;-h0mZzWe*`-|Sx&>yF16uFvOh z*hYOl`_h_vCtCn8S!YxCChh{{1xVOF3TX3XVz)EE>t)BIBLIU=midbAoqo%zY`uWb zIoUwm5g;&Bwh|UV>l3+pssZraEazOp0rxri;o5%yYfu<1&4BEqB3@4C0b8w#s~-M< zuSt0;ryJ01QQk}YOofHYe$N>aysVtD!~ntm%Ec;gau&hljGY0zzcB^89@sF?6o+th z{)HKORtJdb%*eW6G4uXtDG;)eSuhR&9)l`AcopzlQi(lffH0-nnN|UC)>YO1IRoHw zOqG!61Sn3cF8!EuvcWXKz&jEQ+QSYOuGKHI zY58g%2cMVtw^N$40TT<5j0nGNh#j}&0WqKm=9Q8Be{}78{qtj zvxmnL{6}0@7&QcSaxX?+6QX)eO>%?d>yRta^RN-2)$uZr;;WB z$A`LvW`97HuPY9YAXI_6p|=Vm5GHu$835Nd;ZOk$@@f-O9Lvdgo?uC)y?2z5ncP5; zxC<@q6rI{tSg1}XqSL}sBnkRgircc46y;6v{KQ&x4Pt9_p)Uy@6g#f$1{|8iuBY|% z>B_`Exo-e{(Mbw$%Zj|~%%I)_q83fx}gzytAAQkrR_LAlH=iJ>( zazUE{woXUe3foMT>a-w>Jf+*bW`uU!>@rQ!z#kz|iaL9FW=Q^UqnCtRGi;3K;+_BdzqPnwg^)-X2 zrQjY4E(Ff7`~FrR_W$8Na|FaIKXIS^-4BS$_qt!^MA$|5$Y1U{K-BTPdn$Sw46pM9 zW1kXTchD0)d5~zqJDywjJV@mK$aCj=5u#ed)4Qz#3Mrm%zyBSgCFi{@DFBs!;*H1K zh+HSU-Tf9(>tgROKYf#E(NXW|w-B)XkKQu{oM%bzo2Q`2;#X)%fFP2c{)DE6y;KWTda04=`p z&O33;m;kWB84~ z=znw+8O1FB$Gg@N1*QVKst~aDQecnrEBvy6#+7M!!Ft6J9a(uaIJo+4@VPrUcGX8z zx#UCS%NH_I-fmGSW41z!24@Ub(#Uf_;I#Cu)kqNTQ zbS-a+h8LN*QkpJ0pfue`8<3+)X>eDqkGz#%zQ*~B5Ub`On!1q6vT26%aa+N!zTxvZ zRm>t-YrNIt>qF~(4ZXA$#03b&r5na`0?Ej>P!n7*>%NNmZvOqhNOd;xBu=ZvbQ|wb zQ*u5nGEJ2WY(Ns2VcMlKn50?eOVz7chL$HMcY=gR~gA%xAjj>{bFvQfnk_3>JVJS^fMD7VwV}rVc z>c$jdD5aQ2cSj--x3rq?-rhuOY!T;+#l_o;kSbCcnB$V@Msbj-f+E_cGyBD9uUH?} zJkoGI-G)?6h%tdDCp?LFE=d+Bpl|JG_03Hi^NOfTDK;R;dB~q(NeS-Y+>$~*-F^Ly zoLO#>QlFbwXhxa2<*@!x*}OYuN8#Q{;*ttNuM$5_$!OL93yu^AO?Y|l) zZ4y{3*fVXH%vLI~MMz6|gXgd1b!gDXL_s(ESu8y>J8tOgTA4^Bx|o8t)Q$N3w%Jab z?3SJ$8O$Cj8kh`#i@_7NK3-DSgSj!kuI;EO?_x}rq9I$ia3NBfYU-LilR6WO;z((? z$3eTQspD5_54lISpw8SCyw)N@a@_?;BVf(v7qj2FJV~tO8TA=T%JGSTSLqVwmr}v_DpJ;GnCTw2C|**K~BcRW%s@H>cZN4<{74F zjhT?2N3%#{=`|W4pkRrvcc+nas1>_-<>xPUEK|6fqK z)@~l8sN#@ZL|?u&pUdf@VRt%rK);}-jea33seMR#y1($*p6*s core - + (integer sec or 'auto') Barograph to GPS time diff Barométer adatok GPS pozícióba (másodperc vagy 'auto') @@ -25,51 +25,29 @@ Ad-hoc nyílt hálózat ikonnév - + After output job done sleep n second(s) Feltöltés után x másodperccel kikapcsolás - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + Allow whitespace synth. shortnames Szóközök engedélyezése rövidnevek készítésekor - + Altitudes are absolute and not clamped to ground A magasság abszolút, nincs a felszínhez kötve @@ -78,18 +56,18 @@ icon_descr hozzáføzése a megjegyzéshez - + Append realtime positioning data to the output file instead of truncating A kimeneti fájl csonkítása helyett valósidõ hozzáføzése a pozícióhoz - + Base URL for link tag in output Alapért. URL a hivatkozásokban - - + + Bitmap of categories Raszter kategória @@ -98,7 +76,7 @@ Kategória név (Cache) - + Category number to use for written waypoints A készülõ útpontok kategória-száma @@ -107,23 +85,22 @@ Vonalak és térkép-megjegyzések színe - - + Command unit to power itself down Zárásként a készülék kikapcsolása - + Complete date-free tracks with given date (YYYYMMDD). Dátum nélküli nyomvonalak új idõpontja (ÉÉÉÉHHNN) - + Create unique waypoint names (default = yes) Egyedi útpont nevek (alapért. = igen) - + Create waypoints from geocache log entries Útpontok készítése a geocaching bejegyzésekbõl @@ -136,7 +113,7 @@ Adatbázis név (fájlnév) - + Datum (default=NAD27) Térképdátum (alapért.=NAD27) @@ -145,79 +122,70 @@ Ennyi nap után a pontok elévültnek számítanak - + Decimal seconds to pause between groups of strings Ennyi másodpercnyi szünet az adatfolyamban - + Default category on output Alapért. kimeneti kategória - + Default category on output (1..16) Alapértelmezett kimeneti kategória (1.. 16) - - - - - - + + + Default icon name Alapértelmezett ikonnév - Default location - Alapértelmezett pozíció + Alapértelmezett pozíció - + Default proximity Alapért. távolság - + Default speed Alapért. sebesség - Default speed for waypoints (knots/hr) - Alapértelmezett sebesség a pontokhoz (csomó/ó) + Alapértelmezett sebesség a pontokhoz (csomó/ó) - - + + Degrees output as 'ddd', 'dmm'(default) or 'dms' Pozíció formátum 'fff', 'fpp'(alapért.) vagy 'fpm' - Delete all routes - Minden útvonal törlése + Minden útvonal törlése - Delete all track points - Minden nyomvonalpont törlése + Minden nyomvonalpont törlése - - Delete all waypoints - Minden útpont törlése + Minden útpont törlése - + Display labels on track and routepoints (default = 1) Címke megjelenítése nyomvonalakon és útvonalakon (alapért.=1) - + Distance unit [m=metric, s=statute] Távolság mértékegysége [m=metrikus, s=angolszász] @@ -230,29 +198,29 @@ URL mezõ kihagyása a megjegyzésbõl - + Don't show gpi bitmap on device gpi raszter rejtése a készüléken - + Draw extrusion line from trackpoint to ground Meghosszabított vonal rajzolása útponttól felszínig - + Drop route points that do not have an equivalent waypoint (hidden points) Útvonalpont elhagyása, aminek nincs megegyezõ útpontja (rejtett pontok) - + Enable alerts on speed or proximity distance Figyelmeztetés engedélyezése sebességnél vagy közeledéskor - - - + + + Encrypt hints using ROT13 Megjegyzések kódolása ROT13 használatával @@ -261,24 +229,22 @@ Megyjegyzések kódolása ROT13-al - - - - - - - - + + + + + + Erase device data after download A készülék memóriájának törlése letöltés után - + Export linestrings for tracks and routes Vonal-szöveg exportálása nyomvonalakba és útvonalakba - + Export placemarks for tracks and routes Hely-jelölések exportálása nyomvonalakba és útvonalakba @@ -301,39 +267,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + GPS datum (def. WGS 84) GPS dátum (alapért. WGS 84) @@ -346,25 +290,24 @@ Esemény pontok kihagyása - + Include extended data for trackpoints (default = 1) Bõvített információk használata a nyomvonalakban (alapért.=1) - - + + Include groundspeak logs if present Groundspeak bejegyzések használata (ha van) - + Include major turn points (with description) from calculated route Fõ kanyarodási pontok használata a számított útvonalból (megjegyzéssel) - Include only via stations in route - Csak az állomások használata az útvonalban + Csak az állomások használata az útvonalban Include short name in bookmarks @@ -379,7 +322,7 @@ URL mezõ hivatkozása a .dbf fájlban - + Indicate direction of travel in track icons (default = 0) Irány mutatása a nyomvonal ikonjánál @@ -392,95 +335,50 @@ Nyitott HotSpot ikonnév - Keep turns if simplify filter is used - Fordulópontok megtartása egyszerøsítés esetén is. + Fordulópontok megtartása egyszerøsítés esetén is. - - + + Length of generated shortnames Rövidnevek hosszúsága - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Max synthesized shortname length Length of generated shortnames (default 16) Rövidnevek hosszúsága (alapért. 16) - + Line color, specified in hex AABBGGRR Vonal színe (hexa érték AABBGGRR) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Make synth. shortnames unique A készülõ rövidnevek egyediek legyenek @@ -505,68 +403,27 @@ Meg nem talált pont jele - + Max length of waypoint name to write Útpont nevének max. hosszúsága - - - Max number of comments to write (maxcmts=200) - Megjegyzés max. hossza (maxcmts=200) + Megjegyzés max. hossza (maxcmts=200) Max shortname length when used with -s Rövidnév hosszának értéke -s használatával - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Max synthesized shortname length - Elõállított rövidnevek max. hosszúsága - Merge output with existing file A jelenleg és a kész fájl összeføzése - - - - + + + + MTK compatible CSV output file MTK kompatibilis CSV készítés @@ -575,16 +432,15 @@ Az 'unassigned' kategória neve - New name for the route - Az útvonal új neve + Az útvonal új neve No separator lines between waypoints Nincs elválasztó karakter az útpontok között - + No whitespace in generated shortnames Szóközök mellõzése a rövidnevekben @@ -597,32 +453,30 @@ Nem elcsent, nem titkosított ikonnév - Numeric value of bitrate (baud=4800) - Bitráta értéke (baud=4800) + Bitráta értéke (baud=4800) - + Omit Placer name Elhelyezõ nevének elhagyása - Only read turns; skip all other points - Csak a fordulópontok használata (a többi pont kihagyása) + Csak a fordulópontok használata (a többi pont kihagyása) - + Path to HTML style sheet Hivatkozás HTML style sheet-be - + Precision of coordinates Koordináták pontossága - + Proximity distance Közelesédi riasztás értéke @@ -631,57 +485,55 @@ Kör sugara - Radius of our big earth (default 6371000 meters) - A Föld sugara (alapért. 6371000 méter) + A Föld sugara (alapért. 6371000 méter) - Read control points as waypoint/route/none - Pontok beolvasása, mint útpont/útvonal/nincs + Pontok beolvasása, mint útpont/útvonal/nincs Read/Write date format (i.e. DDMMYYYY) Dátum formátum írása/olvasása (NN/HH/ÉÉÉÉ) - + Read/Write date format (i.e. yyyy/mm/dd) Dátum formátum írása/olvasása (éééé/hh/nn) - + Read/write GPGGA sentences GPGGA montadok írása/olvasása - + Read/write GPGSA sentences GPGSA montadok írása/olvasása - + Read/write GPRMC sentences GPRMC montadok írása/olvasása - + Read/write GPVTG sentences GPVTG montadok írása/olvasása - + Read/Write time format (i.e. HH:mm:ss xx) Idõ írása/olvasása (ÓÓ:pp:mm xx) - + Retain at most this number of position points (0 = unlimited) Max. pontszám megtartása a 'snail tail' elõállításakor (0= végtelen) - - + + Return current position as a waypoint Visszatérés a jelenlegi pozícióba, mint útpont @@ -694,79 +546,32 @@ A rövidnév, mint MAC cím - + Speed in bits per second of serial port (baud=4800) Soros port sebessége (bps; baud=4800) - Split input into separate files - Beviteli adatok darabolása külön fájlokba + Beviteli adatok darabolása külön fájlokba - Split into multiple routes at turns - Összetett útvonalakba és fordulópontokba darabolás + Összetett útvonalakba és fordulópontokba darabolás - + Write course rather than history, default yes - + Sport: Biking (deflt), Running, MultiSport, Other - - - Geogrid-Viewer ascii overlay file (.ovl) - - - - - Geogrid-Viewer tracklogs (.log) - - - - - Index of track to write (if more than one in source) - - - - - iGO2008 points of interest (.upoi) - - - - - IGO8 .trk - - - - - Track identification number - - - - - Track title - - - - - Track description - - Starting seed of the internal number generator Kezdõérték a belsõ indexhez - - - Index of route to write (if more than one in source) - - Stealth encrypted icon name Titkosan kódolt ikonnevek @@ -776,104 +581,89 @@ Nem titkosított ikonnevek elcsenése - + Set location finder target location as lat,lng - + Configure logging parameter as tmin:tmax:dmin:dmax - - - + + + Seconds that GPS time tracks UTC (0: best guess) - - - + + Image Offset Time (+HH:MM or -HH:MM) + + + + + Google Takeout Location History + + + + + + GPS week rollover period we're in (-1: best guess) - + codec to use for reading and writing strings (default windows-1252) - + SkyTraq Venus based loggers (download) - + First sector to be read from the file - + Last sector to be read from the file (-1: read till empty sector) - + SkyTraq Venus based loggers Binary File Format - + Format for subtitles - + SubRip subtitles for video mapping (.srt) - - Swiss Map 25/50/100 (.xol) - - - - + Tab delimited fields useful for OpenOffice - - Teletype [ Get Jonathon Johnson to describe - - - - - TomTom Places Itineraries (.itn) - - - - - Index of track (if more than one in source) - - - - + Write name(s) of format(s) from input session(s) - + Write filename(s) from input session(s) - - - Wintec TES file - - String to separate concatenated address fields (default=", ") Összeføzött címnevek elválasztása (alapért.=", ") @@ -887,14 +677,13 @@ Kiöregedett geoládák elhagyása - + Suppress separator lines between waypoints Elválasztó vonalak elhagyása útpontok között - Suppress use of handshaking in name of speed - Kézfogás elhagyása a sebességneveknél + Kézfogás elhagyása a sebességneveknél Suppress whitespace in generated shortnames @@ -905,22 +694,21 @@ Útpontok szimbóluma - + Sync GPS time to computer time GPS idõ szinkronizálása a számítógéppel - Synthesize track times - Nyomvonal idejének elõállítása + Nyomvonal idejének elõállítása - + Target GPX version for output A kimeneti GPX fájl verziója - + Temperature unit [c=Celsius, f=Fahrenheit] Hõmérséklet mértékegysége [c=Celsius, f=Fahrenheit] @@ -937,13 +725,13 @@ A .an1 fájl típusa - - + + Units for altitude (f)eet or (m)etres Magasság mértékegysége (méter vagy láb) - + Units used for names with @speed ('s'tatute or 'm'etric) Sebesség mértékegysége a neveknél ('s' angolszász vagy 'm' metrikus) @@ -954,38 +742,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + UPPERCASE synth. shortnames NAGYBETØS rövidnevek elõállítása @@ -1000,48 +766,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Use shortname instead of description Rövid név használata a megyjegyzés helyett - + Use specified bitmap on output Meghatározott raszter használata a kimenetben - + Version of gdb file to generate (1..3) A készülõ gdb fájl típusa (1..3) @@ -1050,12 +793,12 @@ A készülõ MapSource fájl típusa (3,4,5) - + Waypoint background color Útpont háttérszíne - + Waypoint foreground color Útpont színe @@ -1068,54 +811,65 @@ Térképi szélesség (pixel) - + Width of lines, in pixels Vonalvastagság (pixel) - + Write additional node tag key/value pairs További kulcs/érték címkepár írása (pont) - + Write additional way tag key/value pairs További kulcs/érték címkepár írása (út) - + Write all tracks into one file Az összes nyomvonal összeføzése egy fájlba - + Write description to address field Megjegyzést a cím mezõbe - + Write each waypoint in a separate file Minden útpont külön fájlba - + Write notes to address field Megjegyzés írása a cím megjegyzésbe - + Write position to address field Pozíció írása a cím megjegyzésbe - - + + Write position using this grid. Pozíció készítése ezzel a ráccsal - - + + + + + + + + + + + + + Write timestamps with offset x to UTC time Idõértékek eltolása x értékkel UTC-hez képest @@ -1124,7 +878,7 @@ Carto Exploreur kompatibilis nyomvonal készítése - + Write tracks for Gisteq Phototracker Gisteq Phototracker kompatibilis nyomvonal készítése @@ -1135,947 +889,556 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Basename prepended to URL on output - Brauniger IQ Series Barograph Download - - - - - Cambridge/Winpilot glider software + Columbus/Visiontac V900 files (.csv) - Columbus/Visiontac V900 files (.csv) + Comma separated values - - Comma separated values + + Data Logger iBlue747 csv - - Data Logger iBlue747 csv + + Embedded Exif-GPS data (.jpg) - - DeLorme GPL + + Set waypoint name to source filename - - DeLorme Street Atlas Plus + + Data Logger iBlue757 csv - - DeLorme Street Atlas Route + + Time-frame (in seconds) - - Destinator Itineraries (.dat) + + Locate waypoint for tagging by this name - - Destinator Points of Interest (.dat) + + !OVERWRITE! the original file. Default=N - - Destinator TrackLogs (.dat) + + Source for name field in .dbf - - EasyGPS binary format + + Source for URL field in .dbf - - Embedded Exif-GPS data (.jpg) - - - - - Set waypoint name to source filename - - - - - Data Logger iBlue757 csv - - - - - Time-frame (in seconds) - - - - - Locate waypoint for tagging by this name - - - - - !OVERWRITE! the original file. Default=N - - - - - Energympro GPS training watch - - - - - Enigma binary waypoint file (.ert) - - - - - Source for name field in .dbf - - - - - Source for URL field in .dbf - - - - + ESRI shapefile - - F90G Automobile DVR GPS log file - - - - + FAI/IGC Flight Recorder Data Format - + Read all points even if latitude or longitude is missing - + Flexible and Interoperable Data Transfer (FIT) Activity file - - FlySight GPS File - - - - - Franson GPSGate Simulation - - - - - Fugawi - - - - + Garmin 301 Custom position and heartrate - + Garmin G1000 datalog input filter file - - Garmin Logbook XML - - - - + Garmin MapSource - gdb - + Garmin MapSource - txt (tab delimited) - + Garmin POI database - + codec to use for writing strings - + language code to use for reading dual language files - + Garmin Points of Interest (.gpi) - + Erase existing courses when writing new ones - + Speed in bits per second of serial port (baud=9600) Soros port sebessége (bps; baud=4800) {9600)?} - - Garmin serial/USB protocol + + override codec to use for device - - Garmin Training Center (.tcx/.crs/.hst/.xml) + + Garmin serial/USB protocol - - Geocaching.com .loc + + Garmin Training Center (.tcx/.crs/.hst/.xml) - - GEOnet Names Server (GNS) + + Geocaching.com .loc - + GlobalSat DG-100/BT-335 Download - - - - + + + + Only erase device data, do not download anything - + Google Earth (Keyhole) Markup Language - - Google Navigator Tracklines (.trl) - - - - + GPS TrackMaker - + GPSBabel arc filter file - + GpsDrive Format - + GpsDrive Format for Tracks - + GPX XML - + Add info (depth) as Humminbird extension - + Add info (depth) as Garmin extension - - HikeTech - - - - - Holux (gm-100) .wpo Format - - - - + Holux M-241 (MTK based) Binary File Format - + Holux M-241 (MTK based) download - - - + + Enable logging after download - + HTML Output - + Humminbird tracks (.ht) - + Humminbird waypoints and routes (.hwr) - - IGN Rando track files - - - - - Kompass (DAV) Track (.tk) - - - - - Kompass (DAV) Waypoints (.wp) - - - - + Lowrance USR - + (USR output) Write version - - Magellan SD files (as for eXplorist) - - - - - Magellan SD files (as for Meridian) - - - - - Magellan serial protocol - - - - - MagicMaps IK3D project file (.ikt) - - - - - Map&Guide 'TourExchangeFormat' XML - - - - - MapAsia track file (.tr7) - - - - - Mapopolis.com Mapconverter CSV - - - - - MapTech Exchange Format - - - - - Memory-Map Navigator overlay files (.mmo) - - - - - Write items 'locked' [default no] - - - - - Write items 'visible' [default yes] - - - - - Write files with internal version [n] - - - - - Microsoft Streets and Trips 2002-2007 - - - - - Motorrad Routenplaner (Map&Guide) .bcr files - - - - + MTK Logger (iBlue 747,...) Binary File Format - + MTK Logger (iBlue 747,Qstarz BT-1000,...) download - + National Geographic Topo .tpg (waypoints) - + National Geographic Topo 2.x .tpo - + National Geographic Topo 3.x/4.x .tpo - - Navigon Waypoints - - - - - NaviGPS GT-11/BGT-11 Download - - - - - Clear the datalog - - - - - Read from datalogger buffer - - - - - NaviGPS GT-31/BGT-31 datalogger (.sbp) - - - - - NaviGPS GT-31/BGT-31 SiRF binary logfile (.sbn) - - - - - + Time zone ID - + Attempt to recovery data from corrupt file - + Don't create waypoints for non-user points - - Geogrid-Viewer binary overlay file (.ovl) - - - - + Compact Output. Default is off. - + GeoJson - + GlobalSat DG-200 Download - + list tracks - + get track - - - - + + + + Dump raw data to this file - + GlobalSat GH625XT GPS training watch - - Google Directions XML - - - - + Write KML track (default = 0) - + Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical, 'a'viation) - + Rotate colors for tracks and routes (default automatic) - + Precision of coordinates, number of decimals - + GPS Tracking Key Pro text - + Precision of elevations, number of decimals - - + + Size of blocks in KB to request from device - - iGo Primo points of interest (.upoi) - - - - + (USR input) Ignore event marker icons on read - + (USR output) Treat waypoints as icons on write - + (USR output) Merge into one segmented trail - + (USR input) Break segments into separate trails - + (USR output) Output file title string - + (USR output) Device serial number - + (USR output) Output file content description - - Mainnav - - - - - Mapbar (China) navigation track for Sonim Xp3300 - - - - - Mapfactor Navigator - - - - - Speed in bits per second of serial port (autodetect=0) - - - - - Download logged fixes - - - - - Show device status - - - - - MediaTek Locus - - - - - + + First sector to be read from the device - - + + Baud rate used to init device (0=autodetect) - - + + Last sector to be read from the device (-1: smart read everything) - - + + Disable output (useful with erase) - - + + Number of sectors to read at once (0=use single sector mode) - + POI for Home Symbol as lat:lng[:alt] - + POI for Car Symbol as lat:lng[:alt] - + POI for Boat Symbol as lat:lng[:alt] - + POI for Heart Symbol as lat:lng[:alt] - + POI for Bar Symbol as lat:lng[:alt] - + MiniHomer, a skyTraq Venus 6 based logger (download tracks, waypoints and get/set POI) - + Garmin Mobile XT ([ATRK]/STRK) - + Track name processing option ([0]-nrm/1-ign) - + Mobile Garmin XT Track files - - Motoactiv CSV - - - - - MyNav TRC format - - - - - Navitel binary track (.bin) - - - - - Navitrak DNA marker format - - - - - NIMA/GNIS Geographic Names File - - - - + Accept position fixes in gpgga marked invalid - + NMEA 0183 sentences - - Compact binary representation - - - - - Nokia Landmark Exchange - - - - + OpenStreetMap data files - + Use this value as custom created_by value - + OziExplorer - + Unit used in altitude values - + Unit used in proximity values - - Raymarine Waypoint File (.rwf) - - - - - Ricoh GPS Log File - - - - - See You flight analysis data - - - - - + + Baud rate used for download - + Qstarz BL-1000 - + Video position for which exact GPS time is known (hhmmss[.sss], default is 00:00:00,000) - + GPS time at position video_time (hhmmss[.sss], default is first timestamp of track) - + GPS date at position video_time (yyyymmdd, default is first timestamp of track) - + Textual Output - - TomTom Itineraries (.itn) - - - - - TomTom POI file (.asc) - - - - - TomTom POI file (.ov2) - - - - - TrackLogs digital mapping (.trl) - - - - + Universal csv with field structure in first line - + Vcard Output (for iPod) - - - Wintec WBT-100/200 Binary File Format - - - - - Wintec WBT-100/200 GPS Download - - - - - Wintec WBT-201/G-Rays 2 Binary File Format - - - - - XAiOX iTrackU Logger - - - - - - Appends the input to a backup file - - - - - - Only waypoints that are not the backup file - - - - - XAiOX iTrackU Logger Binary File Format - - diff --git a/gui/coretool/gpsbabel_it.qm b/gui/coretool/gpsbabel_it.qm index 7fbd3e6eaa3536ce9a1e115417c65a8bf066d341..061125588197530913a6ccf88aa9b1587d7f26d9 100644 GIT binary patch delta 739 zcmW+zYe-XJ7=F%nE;~DC=af@3UDn#B&a&(xWNCCG5JI}lN+ncGNUD`2rG$;l3bn90 zjk2N$6|w7JVXm|b)6$~AN-*hyC5942Sy4Eww|>2R-}ija?Y&oCSKvu&+Zy%c%LVT< ztL1+F<&L+_0J!4PybRY0KvxFWl4pR-GHM`#=2@m-c?w|8V2XO_Jwjt@y&b^JQYM(W z0Z6#ZgpwVA)2%bSuLq``(TP(Q02a4y{i)x8P@<2_X#|*%eyxt~cqp zi9hnW8i@7@afRe?(q6&ooCC0Th4gJ28Lbm;P4oj(#)aSj2|B+Do#lj&*&_6JQ1a+( zVYr*9|_o#jApJ0m})of_Y#pw#zp{B4GF-Kl;>3$rs6kYfr<2*xm9-cNL&_$m2m;L3o;p z*Iol*jLFq#qiWks6$vSTGGOZJ(^C_yVkt3`k#EYnG9sLwsANw*OaW4roX!8vLrT%+ zdLYiCG+(C`8mg4B6NSWoRr!@p!j9wW;vFol^rE`&b(ocaH`SKq<-lZ3y>VlGOY6w?Af`{(P2MQyvOQM;$y_FtLw$Dq|%-ua_q2X$Jr^^$gZW{uWr%k|%}&tn?0 T;(0A^&Q&cix85I29+&WEr=c?A~^5H)!7{N>F=b#Lc&J@YYz)tG#)#@)@CL%yi6X<^;uCv_N)CEIyX^_0qOW?_{;ia#s^8nQVH#21i{8iI{~FQU zDqnpRz^5MZH8w6Ha{tt~q7Q(Y!oDA0e~W0&4&T@x;IQTEzLP_||2Mw3M!`(Y0~z0Y zCxCd?yS|Se1mf9a1y6q&)GpXl@XQk%@IO>=;=4e+tiyl*rprV@)1Rp~iK_SdzcMsT zRQZ(u`9*v2{u2L4a|aRq(*KhP-dkGk|Mjcqz~uA(cYX+mO{WV>JuiZx-G%F-X`&6srgbzh&<16K`GKR?{6qy;1E>Fb66W>=-dT@;8!iMc{|fl>>jM8CgOW3Q zf?n%9(X?g3o`bbeA`aeeV;5^kc_*5ZNloFexWA6f+ zBhTf%=P#W{>q#Sn6xxMTBb8)pRiL_LO1m7F(g{-}w5Vh%nrfMWAGuQ2`9RqEy?6E& zg#`AiWRgreP6LOGwJ_E+is4xkt~yE7SO5*li?cp!(@4p3OvE)^3`j#MO;Jrlg!@&^ zG@APKMr%g!RP`cSgLhSm!fFDC1luO1ak5823G0iczu!0Dz*Qd={n}b(=gE3Q=qW!{wHrZtRolII6ykTp9wSW4w8*Jrb961{d z`ZF7;!;UL~XqYDf<}^g8*>@%)%_=dO<0Rtd{Tw}1%CVy3O=d;P1ya+YMic3nEHpJS zBz7v2FicxRLnvy-A!>3^yKPKto%t5u&0Z6fv>VJU#DahyNkUQCPd%&67A>Ml@#5Vzs*|7g_4K{-B zOP>t*j}bXo^^+!i=dRs5nnajGE(|4^N+|Im5myqXtP8~u zX+w^U94`MLFVjbzaLhI3I7-4K_b>%(6ON;}PujbjkQmS>RRCKU1hgc;8?=I!Pz1+B z_glD58Wd_exgAin>bQt%$)wDkZ-U*VG#E{q#)>78NTaoX){%7!Y?PW!9alZ0`NaCn z5mDAD4+vFC%65x2`(&q-tOXU%wsg{cz{%alsa!S30@Lb5&b2RSJGfvOBr>h4n%bFj zJJU&7SE6F4lt`nu#Km?6>0!#&Lp8IklNDPs57Ann>$R)?#;$g20<^)tW1BlW=dx3b z*$&U5_u6s`8!hkUwUpg1kX*S~>+j_rr^`}IRNBh738P<0*%LuS==yjQA1SF^>8g8x zx?s;iI1#HeU3%SXXf2OF`;OrONuFJgQ-AKgN|MyOS;)7 z!m;t;xwN@;aU>EENen67xT#I;oRMu)F)>{-a`U;#o~})*rjD$dUF>b`qHahL zvz_jQG>-EG`Z)vWg-gc`!{wFno^SOptjJ7=SJjOIHPOdYY5qka7;;MDoZ_0jd6>7~ z*5?h@;e~0+ej;$1-;#O-G=KbSq&DjuZj<=ZQBsNVLNSD7I&H*SU3(m9eebyZ+|{_B z@zmm>&7?bnvH{<1-1lNw=evHabIjacIE9^7!$L|nH*AF)36D?~l?%Y6Kj#El(49`D zblE`5sxjvhE=j#bYSDFmCNnAyY}p#>nGy{ek}gZL%|8 diff --git a/gui/coretool/gpsbabel_it.ts b/gui/coretool/gpsbabel_it.ts index 0419c25ef..10f628a3c 100644 --- a/gui/coretool/gpsbabel_it.ts +++ b/gui/coretool/gpsbabel_it.ts @@ -4,7 +4,7 @@ core - + (integer sec or 'auto') Barograph to GPS time diff (sec interi o 'auto') Differenza temporale tra barografo e GPS @@ -25,51 +25,29 @@ Nome ad-hoc icona aperta - + After output job done sleep n second(s) Attendi n secondi dopo il termine dell'elaborazione - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + Allow whitespace synth. shortnames Permetti spazi nei nomi brevi sintetizzati - + Altitudes are absolute and not clamped to ground Le quote sono assolute e non relative al terreno @@ -78,50 +56,28 @@ Aggiungi icon_descr alla descrizione - + Base URL for link tag in output Url di base per i tag link in uscita - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Basename prepended to URL on output Nome base anteposto all'URL in uscita - - + + Bitmap of categories Bitmap delle categorie @@ -130,7 +86,7 @@ Nome della categoria (cache) - + Category number to use for written waypoints Numero categoria da usare per i punti d'interesse scritti @@ -139,23 +95,22 @@ Colore per le linee o le note della mappa - - + Command unit to power itself down Chiedi al dispositivo di spegnersi - + Complete date-free tracks with given date (YYYYMMDD). Completa le tracce senza data con la data fornita (AAAAMMGG). - + Create unique waypoint names (default = yes) Crea punti d'interesse con nomi univoci (predefinito: sì) - + Create waypoints from geocache log entries Crea punti d'interesse dagli elementi nel registro geocache @@ -168,7 +123,7 @@ Nome della banca dati (nome file) - + Datum (default=NAD27) Datum (predefinito: NAD27) @@ -177,79 +132,70 @@ Giorni dopo i quali i punti sono considerati vecchi - + Decimal seconds to pause between groups of strings Pausa (in decimi di secondo) tra gruppi di stringhe - + Default category on output Categoria predefinita in uscita - + Default category on output (1..16) Categoria predefinita in uscita (1... 16) - - - - - - + + + Default icon name Nome dell'icona predefinita - Default location - Posizione predefinita + Posizione predefinita - + Default proximity Prossimità predefinita - + Default speed Velocità predefinita - Default speed for waypoints (knots/hr) - Velocità predefinita per i punti di interesse (nodi/ora) + Velocità predefinita per i punti di interesse (nodi/ora) - - + + Degrees output as 'ddd', 'dmm'(default) or 'dms' Gradi in uscita come 'ggg', 'gmm' (predefinito) o 'gms' - Delete all routes - Cancella tutte le rotte + Cancella tutte le rotte - Delete all track points - Cancella tutti i punti traccia + Cancella tutti i punti traccia - - Delete all waypoints - Cancella tutti i punti d'interesse + Cancella tutti i punti d'interesse - + Display labels on track and routepoints (default = 1) Mostra le etichette su tracce e punti rotta (predefinito: 1) - + Distance unit [m=metric, s=statute] Unità di lunghezza [m=metrico, s=statutario] @@ -259,31 +205,21 @@ - Brauniger IQ Series Barograph Download - - - - - Cambridge/Winpilot glider software - - - - Columbus/Visiontac V900 files (.csv) - + Comma separated values - + Data Logger iBlue747 csv - + Data Logger iBlue757 csv @@ -292,321 +228,230 @@ Non aggiungere url alla descrizione - - DeLorme GPL - - - - - DeLorme Street Atlas Plus - - - - - DeLorme Street Atlas Route - - - - - Destinator Itineraries (.dat) - - - - - Destinator Points of Interest (.dat) - - - - - Destinator TrackLogs (.dat) - - - - - EasyGPS binary format - - - - + Set waypoint name to source filename - + Time-frame (in seconds) - + Locate waypoint for tagging by this name - + !OVERWRITE! the original file. Default=N - + Embedded Exif-GPS data (.jpg) - - + Time zone ID - - Energympro GPS training watch - - - - - Enigma binary waypoint file (.ert) - - - - + Source for name field in .dbf - + Source for URL field in .dbf - + ESRI shapefile - - F90G Automobile DVR GPS log file - - - - + FAI/IGC Flight Recorder Data Format - + Read all points even if latitude or longitude is missing - + Attempt to recovery data from corrupt file - + Flexible and Interoperable Data Transfer (FIT) Activity file - - FlySight GPS File - - - - - Franson GPSGate Simulation - - - - - Fugawi - - - - + Garmin 301 Custom position and heartrate - + Garmin G1000 datalog input filter file - - Garmin Logbook XML - - - - + Don't create waypoints for non-user points - + Garmin MapSource - gdb - + Garmin MapSource - txt (tab delimited) - + Garmin POI database - + Don't show gpi bitmap on device Non mostrare la bitmap gpi sul dispositivo - + codec to use for writing strings - + language code to use for reading dual language files - + Garmin Points of Interest (.gpi) - + Erase existing courses when writing new ones - + Speed in bits per second of serial port (baud=9600) Velocità in bit/secondo della porta seriale (baud=4800) {9600)?} - + + override codec to use for device + + + + Garmin serial/USB protocol - + Write course rather than history, default yes - + Sport: Biking (deflt), Running, MultiSport, Other - + Garmin Training Center (.tcx/.crs/.hst/.xml) - + Geocaching.com .loc - - Geogrid-Viewer ascii overlay file (.ovl) + + Compact Output. Default is off. - - Geogrid-Viewer binary overlay file (.ovl) + + GeoJson - - Geogrid-Viewer tracklogs (.log) + + + + + Only erase device data, do not download anything - - Compact Output. Default is off. + + GlobalSat DG-100/BT-335 Download - - GeoJson - - - - - GEOnet Names Server (GNS) - - - - - - - - Only erase device data, do not download anything - - - - - GlobalSat DG-100/BT-335 Download - - - - + GlobalSat DG-200 Download - + list tracks - + get track - - - - + + + + Dump raw data to this file - + GlobalSat GH625XT GPS training watch - - Google Directions XML - - - - + Draw extrusion line from trackpoint to ground Disegna linee estruse dai punti traccia al terreno - + Drop route points that do not have an equivalent waypoint (hidden points) Ometti i punti rotta che non hanno un punto di interesse equivalente (punti nascosti) - + Enable alerts on speed or proximity distance Abilita avvisi su velocità o prossimità - - - + + + Encrypt hints using ROT13 Cripta le note usando ROT13 @@ -615,24 +460,22 @@ Cripta le note con ROT13 - - - - - - - - + + + + + + Erase device data after download Cancella i dati dal dispositivo dopo lo scaricamento - + Export linestrings for tracks and routes Esporta le linee stringa da tracce e rotte - + Export placemarks for tracks and routes Esporta segnaposti da tracce e rotte @@ -655,39 +498,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + GPS datum (def. WGS 84) Datum GPS (predefinito: WGS 84) @@ -700,25 +521,24 @@ Ignora le icone dei marcatori in fase di lettura - + Include extended data for trackpoints (default = 1) Includi dati estesi sui punti traccia (predefinito: 1) - - + + Include groundspeak logs if present Includi registri groundspeak (se presenti) - + Include major turn points (with description) from calculated route Includi i punti di svolta principali (con descrizione) dalla rotta calcolata - Include only via stations in route - Includi solo stazioni intermedie nella rotta + Includi solo stazioni intermedie nella rotta Include short name in bookmarks @@ -733,65 +553,62 @@ Indice della rotta (se nell'origine ce nè più d'una) - Index of route to write (if more than one in source) - Indice della rotta da scrivere (se nell'origine ce nè più d'una) + Indice della rotta da scrivere (se nell'origine ce nè più d'una) Index of route/track to write (if more than one in source) Indice della rotta/traccia da scrivere (se nell'origine ce nè più d'una) - Index of track (if more than one in source) - Indice della traccia (se nell'origine ce nè più d'una) + Indice della traccia (se nell'origine ce nè più d'una) - Index of track to write (if more than one in source) - Indice della traccia da scrivere (se nell'origine ce nè più d'una) + Indice della traccia da scrivere (se nell'origine ce nè più d'una) Index of URL field in .dbf Indice del campo url nel .dbf - + Indicate direction of travel in track icons (default = 0) Indica la direzione di viaggio nelle icone di traccia (predefinito: 0) - + Video position for which exact GPS time is known (hhmmss[.sss], default is 00:00:00,000) - + GPS time at position video_time (hhmmss[.sss], default is first timestamp of track) - + GPS date at position video_time (yyyymmdd, default is first timestamp of track) - + Write name(s) of format(s) from input session(s) - + Write filename(s) from input session(s) - + Universal csv with field structure in first line - + Vcard Output (for iPod) @@ -804,309 +621,203 @@ Nome icona per infrastrutture aperte - Keep turns if simplify filter is used - Mantieni le svolte se si usa il filtro di semplificazione + Mantieni le svolte se si usa il filtro di semplificazione - - + + Length of generated shortnames Lunghezza dei nomi brevi generati - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Max synthesized shortname length Length of generated shortnames (default 16) Lunghezza dei nomi brevi generati (predefinito: 16) - + Line color, specified in hex AABBGGRR Colore delle linee, indicato in esadecimale AABBVVRR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Make synth. shortnames unique Crea nomi brevi sintetizzati univoci - + Write KML track (default = 0) - + Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical, 'a'viation) - + Rotate colors for tracks and routes (default automatic) - + Precision of coordinates, number of decimals - + Google Earth (Keyhole) Markup Language - - Google Navigator Tracklines (.trl) - - - - + GPS Tracking Key Pro text - + GPS TrackMaker - + GPSBabel arc filter file - + GpsDrive Format - + GpsDrive Format for Tracks - + Add info (depth) as Humminbird extension - + Add info (depth) as Garmin extension - + Precision of elevations, number of decimals - + GPX XML - - HikeTech - - - - - Holux (gm-100) .wpo Format - - - - + Holux M-241 (MTK based) Binary File Format - - - + + Enable logging after download - - + + Size of blocks in KB to request from device - + Holux M-241 (MTK based) download - + HTML Output - + Humminbird tracks (.ht) - + Humminbird waypoints and routes (.hwr) - - IGN Rando track files - - - - - iGo Primo points of interest (.upoi) - - - - - iGO2008 points of interest (.upoi) - - - - - Track identification number - - - - - Track title - - - - - Track description - - - - - IGO8 .trk - - - - - Kompass (DAV) Track (.tk) - - - - - Kompass (DAV) Waypoints (.wp) - - - - + (USR input) Ignore event marker icons on read - + (USR output) Treat waypoints as icons on write - + (USR output) Merge into one segmented trail - + (USR input) Break segments into separate trails - + (USR output) Write version (USR input) Read version - + (USR output) Output file title string - + (USR output) Device serial number - + (USR output) Output file content description - + Lowrance USR @@ -1115,445 +826,235 @@ Versione del file TRK di MapSend da generare (3, 4) - - Magellan SD files (as for eXplorist) - - - - - Magellan SD files (as for Meridian) - - - - - Magellan serial protocol - - - - - MagicMaps IK3D project file (.ikt) - - - - - Mainnav - - - - - Map&Guide 'TourExchangeFormat' XML - - - - - MapAsia track file (.tr7) - - - - - Mapbar (China) navigation track for Sonim Xp3300 - - - - - Mapfactor Navigator - - - - - Mapopolis.com Mapconverter CSV - - - - - MapTech Exchange Format - - - - - Speed in bits per second of serial port (autodetect=0) - - - - - Download logged fixes - - - - - Show device status - - - - - MediaTek Locus - - - - - Write items 'locked' [default no] - - - - - Write items 'visible' [default yes] - - - - - Write files with internal version [n] - - - - - Memory-Map Navigator overlay files (.mmo) - - - - - Microsoft Streets and Trips 2002-2007 - - - - - + + Baud rate used for download - - + + First sector to be read from the device - - + + Baud rate used to init device (0=autodetect) - - + + Last sector to be read from the device (-1: smart read everything) - - + + Disable output (useful with erase) - - + + Number of sectors to read at once (0=use single sector mode) - + POI for Home Symbol as lat:lng[:alt] - + POI for Car Symbol as lat:lng[:alt] - + POI for Boat Symbol as lat:lng[:alt] - + POI for Heart Symbol as lat:lng[:alt] - + POI for Bar Symbol as lat:lng[:alt] - + MiniHomer, a skyTraq Venus 6 based logger (download tracks, waypoints and get/set POI) - + Garmin Mobile XT ([ATRK]/STRK) - + Track name processing option ([0]-nrm/1-ign) - + Mobile Garmin XT Track files - - Motoactiv CSV - - - - - Motorrad Routenplaner (Map&Guide) .bcr files - - - - + MTK Logger (iBlue 747,...) Binary File Format - + MTK Logger (iBlue 747,Qstarz BT-1000,...) download - - MyNav TRC format - - - - + National Geographic Topo .tpg (waypoints) - - National Geographic Topo 2.x .tpo - - - - - National Geographic Topo 3.x/4.x .tpo - - - - - Navigon Waypoints - - - - - Clear the datalog - - - - - Read from datalogger buffer - - - - - NaviGPS GT-11/BGT-11 Download - - - - - NaviGPS GT-31/BGT-31 datalogger (.sbp) - - - - - NaviGPS GT-31/BGT-31 SiRF binary logfile (.sbn) - - - - - Navitel binary track (.bin) - - - - - Navitrak DNA marker format + + National Geographic Topo 2.x .tpo - - NIMA/GNIS Geographic Names File + + National Geographic Topo 3.x/4.x .tpo - + Append realtime positioning data to the output file instead of truncating - + Accept position fixes in gpgga marked invalid - + NMEA 0183 sentences - - Compact binary representation - - - - - Nokia Landmark Exchange - - - - + Use this value as custom created_by value - + OpenStreetMap data files - + Unit used in altitude values - + Unit used in proximity values - + codec to use for reading and writing strings (default windows-1252) - + OziExplorer - + Qstarz BL-1000 - - Raymarine Waypoint File (.rwf) - - - - - Ricoh GPS Log File + + Set location finder target location as lat,lng - - See You flight analysis data + + Configure logging parameter as tmin:tmax:dmin:dmax - - Set location finder target location as lat,lng + + + + Seconds that GPS time tracks UTC (0: best guess) - - Configure logging parameter as tmin:tmax:dmin:dmax + + Image Offset Time (+HH:MM or -HH:MM) - - - - Seconds that GPS time tracks UTC (0: best guess) + + Google Takeout Location History - - - + + + GPS week rollover period we're in (-1: best guess) - + SkyTraq Venus based loggers (download) - + First sector to be read from the file - + Last sector to be read from the file (-1: read till empty sector) - + SkyTraq Venus based loggers Binary File Format - + Format for subtitles - + SubRip subtitles for video mapping (.srt) - - Swiss Map 25/50/100 (.xol) - - - - + Tab delimited fields useful for OpenOffice - - Teletype [ Get Jonathon Johnson to describe - - - - + Textual Output - - - TomTom Itineraries (.itn) - - - - - TomTom Places Itineraries (.itn) - - - - - TomTom POI file (.asc) - - - - - TomTom POI file (.ov2) - - - - - TrackLogs digital mapping (.trl) - - Margin for map. Degrees or percentage Margine della mappa. Gradi o percentuale @@ -1571,68 +1072,27 @@ Tipo di marcatore per i punti non trovati - + Max length of waypoint name to write Lunghezza massima dei nomi dei punti d'interesse da scrivere - - - Max number of comments to write (maxcmts=200) - Numero massimo di commenti da scrivere (maxcmts=200) + Numero massimo di commenti da scrivere (maxcmts=200) Max shortname length when used with -s Lunghezza massima dei nomi brevi quando si usa -s - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Max synthesized shortname length - Lunghezza massima dei nomi brevi sintetizzati - Merge output with existing file Unisci la destinazione con un file esistente - - - - + + + + MTK compatible CSV output file File di destinazione CVS compatibile con MTK @@ -1641,16 +1101,15 @@ Nome della categoria 'Non assegnato' - New name for the route - Nuovo nome della rotta + Nuovo nome della rotta No separator lines between waypoints Nessuna linea di separazione tra punti d'interesse - + No whitespace in generated shortnames Nessuno spazio nei nomi brevi generati @@ -1663,32 +1122,30 @@ Nome dell'icona non nascosta/non codificata - Numeric value of bitrate (baud=4800) - Valore numerico del bitrate (baud=4800) + Valore numerico del bitrate (baud=4800) - + Omit Placer name Ometti nome localizzatore - Only read turns; skip all other points - Leggi solo le svolte; tralascia tutti gli altri punti + Leggi solo le svolte; tralascia tutti gli altri punti - + Path to HTML style sheet Percorso del foglio di stile html - + Precision of coordinates Precisione delle coordinate - + Proximity distance Distanza di prossimità @@ -1697,57 +1154,55 @@ Raggio dei cerchi - Radius of our big earth (default 6371000 meters) - Raggio della Terra (predefinito: 6371000 metri) + Raggio della Terra (predefinito: 6371000 metri) - Read control points as waypoint/route/none - Leggi i punti di controllo come punti di interesse/rotte/nessuno + Leggi i punti di controllo come punti di interesse/rotte/nessuno Read/Write date format (i.e. DDMMYYYY) Formato data in lettura/scrittura (per es. DDMMYYYY) - + Read/Write date format (i.e. yyyy/mm/dd) Formato data in lettura/scrittura (per es. yyyy/mm/dd) - + Read/write GPGGA sentences Leggi/scrivi frasi GPGGA - + Read/write GPGSA sentences Leggi/scrivi frasi GPGSA - + Read/write GPRMC sentences Leggi/scrivi frasi GPRMC - + Read/write GPVTG sentences Leggi/scrivi frasi GPVTG - + Read/Write time format (i.e. HH:mm:ss xx) Formato ora in lettura/scrittura (per es. HH:mm:ss xx) - + Retain at most this number of position points (0 = unlimited) Mantieni almeno questo numero di punti posizione (0 = illimitati) - - + + Return current position as a waypoint Ritorna la posizione corrente sotto forma di punto d'interesse @@ -1764,19 +1219,17 @@ Il nome breve è un indirizzo MAC - + Speed in bits per second of serial port (baud=4800) Velocità in bit/secondo della porta seriale (baud=4800) - Split input into separate files - Suddividi l'ingresso in più file separati + Suddividi l'ingresso in più file separati - Split into multiple routes at turns - Suddividi in più rotte alle svolte + Suddividi in più rotte alle svolte Starting seed of the internal number generator @@ -1790,48 +1243,6 @@ Stealth non-encrypted icon name Nome dell'icona nascosta/non codificata - - - Wintec TES file - - - - - Wintec WBT-100/200 Binary File Format - - - - - Wintec WBT-100/200 GPS Download - - - - - Wintec WBT-201/G-Rays 2 Binary File Format - - - - - - Appends the input to a backup file - - - - - - Only waypoints that are not the backup file - - - - - XAiOX iTrackU Logger - - - - - XAiOX iTrackU Logger Binary File Format - - String to separate concatenated address fields (default=", ") Stringa per separare i campi indirizzo concatenati (predefinito: ", ") @@ -1845,14 +1256,13 @@ Ometti i geocache obsoleti - + Suppress separator lines between waypoints Ometti le linee di separazione tra punti d'interesse - Suppress use of handshaking in name of speed - Ometti l'uso dell'handshake per aumentare la velocità + Ometti l'uso dell'handshake per aumentare la velocità Suppress whitespace in generated shortnames @@ -1863,22 +1273,21 @@ Simbolo da usare per i punti - + Sync GPS time to computer time Sincronizza l'ora del GPS con quella del computer - Synthesize track times - Sintetizza gli orari delle tracce + Sintetizza gli orari delle tracce - + Target GPX version for output Versione GPX del file di destinazione - + Temperature unit [c=Celsius, f=Fahrenheit] Unità di temperatura [c=Celsius, f=Fahrenheit] @@ -1895,13 +1304,13 @@ Tipo del file .an1 - - + + Units for altitude (f)eet or (m)etres Unità di misura della quota [m: metri, f: piedi] - + Units used for names with @speed ('s'tatute or 'm'etric) Untià di misura per nomi con @speed [m: metrico, s: statutario] @@ -1912,38 +1321,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + UPPERCASE synth. shortnames Nomi brevi sintetizzati in MAIUSCOLO @@ -1958,48 +1345,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Use shortname instead of description Usa il nome breve invece della descrizione - + Use specified bitmap on output Usa la bitmap specificata nella destinazione - + Version of gdb file to generate (1..3) Versione del file gdb da generare (1... 3) @@ -2008,12 +1372,12 @@ Versione del file MapSource da generare (3, 4, 5) - + Waypoint background color Colore di sfondo dei punti d'interesse - + Waypoint foreground color Colore dei punti d'interesse @@ -2026,54 +1390,65 @@ Larghezza della mappa, in pixel - + Width of lines, in pixels Larghezza delle linee, in pixel - + Write additional node tag key/value pairs Scrivi coppie addizionali di tag chiave/valore per i nodi - + Write additional way tag key/value pairs Scrivi coppie addizionali di tag chiave/valore per le vie - + Write all tracks into one file Scrivi tutte le tracce in un solo file - + Write description to address field Scrivi la descrizione nel campo indirizzo - + Write each waypoint in a separate file Scrivi ciascun punto d'interesse in un file separato - + Write notes to address field Scrivi le note nel campo indirizzo - + Write position to address field Scrivi la posizione del campo indirizzo - - + + Write position using this grid. Scrivi la posizione usando questa griglia. - - + + + + + + + + + + + + + Write timestamps with offset x to UTC time Scrivi date e ore con scostamento X rispetto al tempo UTC @@ -2082,7 +1457,7 @@ Scrivi tracce compatibili con Carto Exploreur - + Write tracks for Gisteq Phototracker Scrivi tracce per Gisteq Phototracker diff --git a/gui/coretool/gpsbabel_ru.qm b/gui/coretool/gpsbabel_ru.qm index c6666caf62414b99a3add16a92089e7800ffe9f7..fe8b14bf7b7e1bf4e76cb0161ec7fc3663bdb05a 100644 GIT binary patch delta 1850 zcmW+$dsI~Q8r|p2oHKJ~&YTet3o7I9X)C*b!rx3A(7@HZ!}>I_eSjB8rD0@&~__s7)nz{W^kbG;47 z@aOfKalpJHUjH2xT>gZYM)(0y(Y*H_mF^`z`tTs&yot|R*92Hr@y7?Vf$6{TwVz7B zERMeu)@lPr+4!I8i0SwP{7}Z9K*VT%Xg!_bw>A2pL}J*faY?EHqD4yBnE5W z&$$42*tP#mwLPK^d$i{(zX8VV&|Y@$A_?2HSJY}C@|LzMDU77LtbM+36yRVJI0r2d zbVPX7;z>#!5tawh2z-7PvR)y8NxeeOy*wcK3!zAM1lH{pw)qfK$LB)TOF*+#s9V!V z#HI+JeCZ098ii)t7jFZv?hpt~$eSSaxsYVbQ$^Y91+ZqWXl^W}??f>; zbvN+J7IATp6A-pTjENl%$Ub6m&q`p6tGMe&V!U*nct9Boyw)$CU9AD8o)XVRP#r+* z4~?PG_USC?gg5qMoz2^OGB7M#7qnI-6W!7+n$b<8FzM0;Vu84NU6m7cx?+>Ax~K+- z@7JAu@c@|fRM+$^HJ+29yJ{uCWlp-Ac~)RTvaTgR6ew`hJ-9?(S>m93+?YqR9@O)* z#u5He{h<8qrkDcQi3RB7mLIxw=_;3U)n z3q~8pjFvm3wC%MOMla9~@O@|uzD80l&NIeOru+{tFy_AWKvbKt z;MZIrw8Xe|h|$c7Xa6fjb$oio6p2wfyu;0+t)(p(d*TdVon(+bIA3&rFUV&TV5{Q3*@-+;sCc+!5}|&@a?UnLi($GF*q#W?wfUWx!F&%oVZtc7`Oyj zSfuoor&B}4%5OoWz?wGmw6hhoNnOmdHfU)S0p{Sx-W2n*<^_?Nv|_{GHW#+NTo|6_ zL)W8$m2=JYAy$%jgZb3{P;&b+bHl$Y0YkR=-gPQ8EyMgUnl|L3&E|pJZ-9VLNuGiP zRwL~+vMbK98r9jYn#m(Yp6&HmuVpXBc5~|N@gFj~#gAjNeS9_S*`%#JYo6-Mvmw81 zo^=Q0^6H71vFypL5Rnyz$XYf%JcCnv7w%SnkLYHFksdr7yEKAV$Eq#Hrm_5tDs~sC^)bBSAvQ4?eIQDFFfvE1ZHnZKuqQJV|y2vr5w1i^= zWjc-ezCE8s+TA&}ai1TrUio_^`|O~^u@Q&rICXwSJ^SPx!N96MIHP3~>yK$z@5w5T JRh@R={s%SgE;;}J delta 13056 zcmcIqd3+o7m4A}QhiqBS;Ul(_c;Y0E9TMBI+CsTX+0xP?LbqFbun>;W!Y8Hd0_7$^DRfIeEel!N?tb5l?u0IX?0ynk z(s=al_kG829zSDv;4R~Ii$bPLh{6(4#l=)|{{)e>k*bb7Mbu%V#;4X19dgn@OBa#3 zghpC^MYQB~a{Q^2Xy{=Y%bq4mdxkESmJxmV6FT(8Akq3(dg%W7MAsPU^xV6MMrY`E z+tP?G|Dhr8#|1=7>kV_}Jx`Q#siE-pGZdnxm4>EE_7aV(HZ<3-C))g9h7G@3Mb!GC zq4PNlQRbV5u2X-(=XArca)zk(6~n&DS)!ZH81{AFOmy3q4R&h-QP&Fw=~O$>V5edB zFa)wbYdHARJBcp&x#92{m1ys@;i_XlCAv~E-2Q+O3WN-g4%$LQx2!h&wRSmPUpA&a z@gmW+zcps1EhXCbhB50kFbM87nu_X){7)FGz5+sfo-__0JwsIVoY8sUQKFhpjKLs2 zE4z)?d<2G<4j8|FMkZ?i*m%cx))O5L81F3HLe$x9ytB6opFc9*{UZ}m|F4YCc7|Yz z?7g6{cjN!Zx{ag#@`TCZWbO{cpBHc zgnw0G8P}V_Z(n#3E_^_Ewe>jB)Z0Sn^zKfgZ>W@e>2@M7lLga zOSdcop^8V+msBi+7HNv5rkdozW!pO-k+q; zm|>wCYSRy`gsBU5rQgm1&K*m?XZ+8wXjl5Z-+&YYZ+Ht$`KRKW;{5WM$~dR<9Ht!5oLVv z2WZst+l)VmcOzK$W&EXMgy<_n8E1;XaNC@Wzc+Lc?R-5mSAv53_heQ$>WR*q&aA4c zCYm>rxp6`z3SHyN+}!v!f^Scz{iAI}2M01QwSaNeFEVeRk1tMd$h>m~8ee=<=KZCI zh;D7keDLotfN)plqc2@g^!1N2ADhMfzOQ7S^v@El`CaDI0WiMjXPLk3Ur!{8nJ@fw zIgw{Y<~tAji3Uz&zV96)%2P5wzOWeizvJ>OWAjodbaU3aU-cncjamCg?j;(wWL@;` zi$ojESzr5N0|2BX>*$pbaQo|74}ZOY==S4TC-Qa?ed+eBrx(7A`>)P={>EnjNL5*< z-^TZ@`exRd(&vaSI&Et6Tuvm6nzrA1l<3YyrX9Q91CW)P_GF$${;%F>I`l^X&Vm6` zs3L$Utu$RadkliyZ@T(+ndsXd(~aqu!L-??Z&l-U^Hx*19)f16riW@F&^LUhCx@WG zf-6l=e`7xGKVy3ODKNhIpy`=|r=h?R)5{VVUeINF?c4ag=1ZnGesCB#Bba_)69R+g z7So?QZzS6F6Vs=s97N?8XU|WEPo*cb7jMRmZO>+l0SNT9`s~i@(qXz!vIiVNBJUm9 z+p?aA0;jUKeWwb*QkcE(XRt`wvFwA#3W!SnkbNxYUZT?Lvu`?$p6#XkKX`-HTPw|UTh{ZhO$qaZYJ8@k^QH=@a5w1?7uAo;h6t-3ml5Uu(LB@-S9N?~-u{!ffQUDT%sXEKvUz6AyZ508HT=$eLEDcJwbz>` zzGxyka)o)i1vf5!+I^BY@{MpIqp z_nu@4hs>Wo3IY0Nax>HyQ8X^fop%SW8?3qI*T7^)x^q`=2BU8l<&NC76eeAqyK659 zd47_6;pq24xFz>cB?Mb>EccsLGSd0o+;5$PuQNC1-t{pUU-*9R!*%$(nxFev$ztSx z%bwg5fqMa&i*ipq4^8H{b5CZ!1&#A_PnH6BzOXO%)$hFt0Y1%rryf4tbW`qoMfafE zy<#!W?jo}1Su8z3wDIMZgVUc#; zjH0y8a_GYck;g|Zm#(dc01sG>{>R10qSr0A4deb@OD*?&?=*_gA1(j#?2q8GIhK=u z;ovN^ywWm2Bwu6s^K}knQNHDqjgKM!kB0K<9z2G|;my3YzXXA@^YWTq0*caYd9CkM z5#80B*JfP=m@sVEwU^d0%^C81?@|-o4gY zqPkD=zJH_x)pKFqLq9`$XUloNegb^jdh=cxMp>V{GVlFoOJLHaC-Od0euECCGw*LF z5Un>_WZ>st!+SF>&slVVkT0|fYlK>%PG}K^ga)CVM7;09)wQa3L(y;@K6m2p>xCA) z+k`tB@v{l{Y{Wh5ajhAzZ9yj2eep%&CwmQA3@S8JIwiPTO$vQv;eB$JaQd=dq#CIz_S z?|pQBjCV!5&mQ#1PRS?soiExXpDg*scDqk;`t05bu~V7$xD@+XCd5?tuE-8G3uVG$ z&})PKwa|%mW1b!0=%!Kdl4(riT0=YV-a}sec9BAX7|-$!yL;3pk2$599Z*+xDFM;x zlE)x}Ul|Wf+kF!A6C8?9GNj?%1;QezxB<-6O$9f1uM`#wJ+NROBxo1^{xHWA=dEr8vV+7vvicvQ{VjN$lC$pKOG>v%YDg0H{d#7XTeAe!JiWKi+S} zyCC^vREwijL$-iVk^-VN;IjM0t*)RynMsqd5Xx;5dhyf2!Toue##og^StW5AR)PU` zYPfCThXzBfTD!PdeQRq`N$hKLI;C-Y&=n9}ibFG(x@7T#h6#1<{zCP5abX4wkAzb% zZJ)2+TAbg;3D5!u)lrSmLsc;{6;U#NuOy9$SmlTjhyUQi|Sfv#6)y65RmXTtc2)Z0K zobz=tDn$uY0zM?Us0*0tigQY*nP6dgUVe;Rew>{8NWp^8+GHOJTOwZcBS1JI?Re$z z6RDD_k*xeVZox&Jl0Sg>4Zw7Lcq94j8YWa$BX6pbMI6-NkQ0I-Z4;6KIjVlRw!pz`!F!n#+KJA=+H{V*is(nOWnZ8 zS+Z#=O@L3TiRN~@W^J-_BA}7!R=>AuJX9wv(Sp1~!;EgcAHw&#VFo*l?0P zi6zAxSJLgXd;E%r$@SO)A~x9_bZJCQdk-(}|LYzS;8_)CNo~|JeD#4)Ljf#)LKZWvJ*)wQM$?=7H!xuFA+i` z@UIPhLm&RFPUxAmDvm^02gSI)vW0sP&$RA>tRjH_4KBcX+n z$5wBbrDUjL=FVBjO!fg zseUf#Q4}ZVo$Qkw-0%3=)#^h{$3neADg4O3L|I6zh?-{;84V)nr?iYrE>hg*Bzm_z z!fen!B|EiJr6IWs<%%^4_!8Z!_N;#|G>3XYcM?jBXo^h45-Y1$o|Hx;$3${wtp!vh zqH!x%oI^C<+)Yevs+11ltMeJs* z4lik5Wi+f(5A>E+^uf@B`1-JhA7cpw3i^5m#bLW=Oc4X>FM1bL%tM;=AfvgmR>KcI znv8KX_4N!jiBNko+_qtdam!vb>0FK3x>JipMo8PRVxBulKZmj4OI0lx(~yVF8%0)jA(5NG11E zwQAYH1tF@`ifM}`0hiGxt+i&USng)6ysnAJ+^c=UkcGeTu+y3l(`)-YW73R>jzMe5 zcy^lh$pF|&d0cd3hCtVE_ds?Yt}tN)eGaKA6SHQ*gt0qC;Aq>%qs{-7oae>l%`F%E&!(S3p5Y-*eo->{9q|zbI1#?E?TPfzrf938_3r}^oJV;V{&A}z zqI7n$i!+2A-yZ+$%4bDRU4zQR)MZb z)`$hkf*3156tlZTw6_7pp}3OKsWWQYNIYWV2kCaL`_xIxD0KrAvO_5jmOi+*UbizLS|AKnaX?z4BzLdKOIqZk~7;n~I5_IbfGP9{W^OT2<`2 zEYzvp?4=5ze-OOK;AfFmpo}T_?8B5W17RmLpL2wCYfj)EJ%GDXt2AWwR`dk1YY|tB z013Nh9Kc4Wq*bQC3NG1E?)vHlEpNP4PeesFlouJ~hfL9VfU6QtEMp24gPYZla-qXX zWDE%S8dKt}I-+BwG(+l`R;ytnR*SoAeP;s2VhoDFfJ?U+(L;TtxiB<_Z4obMnouWd zwQAN1NaBHwt6D?{5Y#moh4k7ij73lr2LbK^CdBf}2DUu+xHVgP5eM~L^;lC-bu!p%}mU;5UvX z6NtvTpCpPQ+7KbBz(L%!a7I>xI3r+GZT{pzuceQ0{F`@pHrgIzv>1#Oui}#Z)egli z;*&%1pnqn#?XYc6;z<+Q&Y>9y||q#XoDspFuvlT5DGC-(8@-cA!{Ya1|a^lGOwD8POATkAgF*Jfv}BsfKlFtkApdGY)sazp)OzmfF(& zoe(XA4J0HB2PcOW4<@{Ib0BHrdojy^1o#_~CNZ8kQg>n7qmi!_u5-2i%z}qg9|poyugB@h4$UHs@VD?{DX@W~wj^de5>sk5VHXQE|ew0w}$u1P!$$~^i@(16PdYodo} zC0ltjE+)dE-hhv?MPll#V)j0teN5C=j~*}TAHt^+w$|~lN~|7r_|(@2@(+j*C$ZHZ zfIIaBWaAA}M~v#6fmtM-I5OP9IM9$M^TBd<#~~e)sb4WrKlAs1oC~* z#7Z^V0MM7PnJF9W8?e^&4EEVXZC1k;UUo#L^lmIR!Y6wd7!A#;y>Wg|6eYCX4yg7( zT%JnSfNp#IQ%w9tj2OHW=^0tQW=&1I_9Aww=dUOTx&Gnco4TYqH|P2!&iskPQich; z@s7JJKlTKkgbGm;m8c1_)axSEufb|$xI4NXnW#;ih+a?3=5v|06U89b zd%OuTfE&oC~gq4S5xoXv0$G5C}=GsKxYZTUm{@LW;~y$&ntJ%P?wbEfx=9 z`6!+xU=(M}Nf{qCOEhLa`=r=8XcgUd-z3b#xv(@f8J1~>Hr)O5o|FgCAr-@9QQ@F8 zEqbtZ(mGH+^3ujO^*5Uz*jf#~yhPGliheEe$F%x@aTij>+5#8=T|vyqMT5#D+Khf6 z7K;>Z2c+=KmP|wLZea!ZTQO;18d3Aw7pQN^^UN4EqFrUJ8r;96c-dgkjkeJtPT5^S z%(~;SCrlZT)SvAy35WXU7(yP65;qCw8mZ5oc6i3o+t)VCHdb_*(Qigi8d|lXm(L)$ zKg85D(tIA_;h=%|I=pe^T~p=MYL@LcOlMDEDGaJFx*ja!N2KvyZ;6rqnTHm)YlYF6H|X}j#y6Uz;_9y!lUIO#f1lP9|0<%3ImK*X_~hyxbwj7>kf z6vx$$`nln22c|Oc6p{$#*TNAn1c(+P=r%y@CUwbfQK5Bcs~Q0qyinmukPrJf4fu#B zUNLKj?PGG#&%QzP3ja7ooazN8#LBVA@zJ{aMl4)vMK_LVeEyX1kKuE4r`^Mg7v7R{ z56D@?jV2?65Br?)1jdVp?X!q1?3ZGBEHWAc8GO^@RqDsK=hn}p1P7aaV?>E_x)*A4 zKr};|rJ0zL)fjeb^wVJ_;58ZDPa$X_m_Z$qrvfU$rpZjBtN}xRYJi_EfK>o zD0i6?FlqAP!@ObHp-k`|oVUW79mD^+>nVf18SumFgJ>e~drl1qtE~q(!CJ82)<-oP zyv6?71t!6m&V@{I96OF4 z#t?Llz()1S{g;I=+rQAD9vHLa#m^RFPYHBGEts3Ll6Pc@!4b{1_?csw4V#WYYHAj#*#9NA1-KO9Tg7UJ(6n7mjeJ$5;U8Cn?n^feHh zJpSmzDqGOYhveG&hSM6;=$L=PJ}G;gysgvf1TJgGxtZ#dc)(^Y3Oo)*&`NNVs}FG^ z+Svv)Jq>V7O$0^sM4mx#ByNsNY|}Eham!uTP}5Lb1GGRA&nT`c^@QVYTb(c;;_J^f zH0k(*5R9G2?qA|(u@X4c6Sdxw#oU7uk2kfma z*3kL!c&Go?RhQ90C-w=&BZ?dUQ%-f|Kx&gP98GHVrL}9eo=ulmXpV&VFO1OLI@A~4 zdEm4q1$vW+;_N3?SU$f=MEY|ORi^4vh&KPPcHjpgct+uq=(ts!iDnU_;=Ak)3|z@) z-e+59As#;A$9Jq6QsMEBgkXqo1?G;h|J5>g$^K^SZaK@j6f|iYPX>KnvL~)3csS;o z$A@^)*ou=Y)yRoh+js)GJ$ zmGxjg(|Zn%$2fGXOrTs>yQZdRH5v}g-7IkU$uB%0q~W0i_0*1nP^>^Os^W(qEMp8{ zXyVG*pl!JrgEt{Y5efX6_5ca?C0Ir~AK|eIt%HpIiEZser4+H?@$>3xk7r+U1L4yi zifB`x-!Zq5AA#Ep%DgniQlHAXKI0lU*f>#&!KPlxH{gV)oMljdShJ{uC2UWSWyuar z7M$0({o)Ed{WB?ztq}J_`#F!2BFBE+4lB-2r`=aW0ZtVB}wPyCH3}kgvYFcEtsJFvtV&P-L~kpShI{ zYFj`#0kF&Eo*^VdQ?!3XebxN0KWh_2SDAvdc+Q7e*rF^Hklw0w%)I^jEH=yJ9!1>h QlikWcU=+URV42~60L$ScN&o-= diff --git a/gui/coretool/gpsbabel_ru.ts b/gui/coretool/gpsbabel_ru.ts index 9c1d7e467..13b9d145d 100644 --- a/gui/coretool/gpsbabel_ru.ts +++ b/gui/coretool/gpsbabel_ru.ts @@ -4,1808 +4,1561 @@ core - Brauniger IQ Series Barograph Download - Загрузка барографа Brauniger серии IQ + Загрузка барографа Brauniger серии IQ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Max synthesized shortname length Максимальная длина генерируемых коротких названий - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + Allow whitespace synth. shortnames Разрешить пробелы в коротких названиях - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + UPPERCASE synth. shortnames Создавать короткие названия в ВЕРХНЕМ РЕГИСТРЕ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Make synth. shortnames unique Делать короткие названия уникальными - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Basename prepended to URL on output Добавлять перед URL-адресом базовое имя при выводе - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Use shortname instead of description Использовать короткое название вместо описания - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + GPS datum (def. WGS 84) Система координат GPS (по умолчанию: WGS 84) - Cambridge/Winpilot glider software - ПО планера Cambridge/Winpilot + ПО планера Cambridge/Winpilot - + Columbus/Visiontac V900 files (.csv) Файлы Columbus/Visiontac V900 (.csv) - + Comma separated values Значения, разделённые запятыми - - - - - - + + + Default icon name Стандартный значок - + Data Logger iBlue747 csv Средство записи данных iBlue747 (.csv) - + Data Logger iBlue757 csv Средство записи данных iBlue757 (.csv) - DeLorme GPL - DeLorme GPL + DeLorme GPL - DeLorme Street Atlas Plus - DeLorme Street Atlas Plus + DeLorme Street Atlas Plus - Keep turns if simplify filter is used - Сохранять повороты при использовании фильтра упрощения + Сохранять повороты при использовании фильтра упрощения - Only read turns; skip all other points - Читать только повороты и пропускать все остальные точки + Читать только повороты и пропускать все остальные точки - Split into multiple routes at turns - Разделять маршрут на поворотах + Разделять маршрут на поворотах - Read control points as waypoint/route/none - Читать контрольные точки как маршрутную точку/маршрут/ничего + Читать контрольные точки как маршрутную точку/маршрут/ничего - Synthesize track times - Генерировать время треков + Генерировать время треков - DeLorme Street Atlas Route - Маршрут DeLorme Street Atlas + Маршрут DeLorme Street Atlas - Destinator Itineraries (.dat) - Маршруты Destinator (.dat) + Маршруты Destinator (.dat) - Destinator Points of Interest (.dat) - Достопримечательности Destinator (.dat) + Достопримечательности Destinator (.dat) - Destinator TrackLogs (.dat) - Журналы треков Destinator (.dat) + Журналы треков Destinator (.dat) - EasyGPS binary format - Двоичный формат EasyGPS + Двоичный формат EasyGPS - + Set waypoint name to source filename Задавать имя маршрутной точки на основе имени входного файла - + Time-frame (in seconds) Интервал времени (в секундах) - + Locate waypoint for tagging by this name Найти маршрутную точку для пометки этим именем - + !OVERWRITE! the original file. Default=N !ПЕРЕЗАПИСАТЬ! исходный файл. По умолчанию=N - + Embedded Exif-GPS data (.jpg) Встроенные данные Exif-GPS (.jpg) - - + Time zone ID Идентификатор часового пояса - Energympro GPS training watch - Спортивные часы Energympro GPS + Спортивные часы Energympro GPS - Enigma binary waypoint file (.ert) - Двоичный файл маршрутных точек Enigma (.ert) + Двоичный файл маршрутных точек Enigma (.ert) - + Source for name field in .dbf Источник для поля имени в .dbf - + Source for URL field in .dbf Источник для поля URL-адреса в .dbf - + ESRI shapefile Файл формы ESRI - F90G Automobile DVR GPS log file - Файл журнала F90G Automobile DVR GPS + Файл журнала F90G Automobile DVR GPS - + (integer sec or 'auto') Barograph to GPS time diff Разница во времени между барографом и GPS (целые секунды или "авто") - + FAI/IGC Flight Recorder Data Format Формат данных бортового регистратора FAI/IGC - + Read all points even if latitude or longitude is missing Читать все точки, даже если отсутствует широта или долгота - + Attempt to recovery data from corrupt file Пытаться восстановить данные из повреждённого файла - + Flexible and Interoperable Data Transfer (FIT) Activity file Файл активности Flexible and Interoperable Data Transfer (FIT) - FlySight GPS File - Файл FlySight GPS + Файл FlySight GPS - Default speed for waypoints (knots/hr) - Скорость по умолчанию для маршрутных точек (узлов/ч) + Скорость по умолчанию для маршрутных точек (узлов/ч) - Split input into separate files - Разделять входные данные на отдельные файлы + Разделять входные данные на отдельные файлы - Franson GPSGate Simulation - Симуляция Franson GPSGate + Симуляция Franson GPSGate - Fugawi - Fugawi + Fugawi - + Garmin 301 Custom position and heartrate Пользовательское положение и частота сердечных сокращений Garmin 301 - + Garmin G1000 datalog input filter file Файл входного фильтра журнала данных Garmin G1000 - Garmin Logbook XML - Garmin Logbook XML + Garmin Logbook XML - + Default category on output (1..16) Стандартная категория при выводе (1..16) - - + + Bitmap of categories Битовая карта категорий - + Version of gdb file to generate (1..3) Версия GDB (1..3) - + Drop route points that do not have an equivalent waypoint (hidden points) Удалить путевые точки без соответствующей маршрутной точки (скрытые точки) - + Don't create waypoints for non-user points Не создавать маршрутные точки для непользовательских точек - + Include major turn points (with description) from calculated route Включать основные точки поворота (с описанием) из рассчитанного маршрута - + Garmin MapSource - gdb Garmin MapSource — gdb - - + + Length of generated shortnames Длина генерируемых коротких названий - + Read/Write date format (i.e. yyyy/mm/dd) Формат даты для чтения/записи (например, гггг/мм/дд) - + Distance unit [m=metric, s=statute] Единица расстояния [m=метрическая, s=английская] - - + + Write position using this grid. Записывать положение с использованием этой сетки. - + Precision of coordinates Точность координат - + Temperature unit [c=Celsius, f=Fahrenheit] Единица температуры [c=Цельсий, f=Фаренгейт] - + Read/Write time format (i.e. HH:mm:ss xx) Формат времени для чтения/записи (например, ЧЧ:мм:сс кадры) - - + + + + + + + + + + + + + Write timestamps with offset x to UTC time Записывать временные метки со смещением x относительно времени в формате UTC - + + Image Offset Time (+HH:MM or -HH:MM) + + + + Garmin MapSource - txt (tab delimited) Garmin MapSource — txt (с разделением табуляцией) - + Garmin POI database База данных достопримечательностей Garmin - + Enable alerts on speed or proximity distance Включить оповещения для скорости или расстояния близости - + Use specified bitmap on output Использовать указанную битовую карту при выводе - + Default category on output Стандартная категория при выводе - + Don't show gpi bitmap on device Не показывать битовую карту gpi на устройстве - + Write description to address field Записывать описание в поле адреса - + Write notes to address field Записывать заметки в поле адреса - + Write position to address field Записывать положение в поле адреса - + Default proximity Стандартное приближение - + After output job done sleep n second(s) После выполнения задания вывода сделать паузу n (в секундах) - + Default speed Стандартная скорость - + Create unique waypoint names (default = yes) Создавать уникальные имена маршрутных точек (по умолчанию = yes) - + Units used for names with @speed ('s'tatute or 'm'etric) Единицы измерения скорости ('s' — английские или 'm' — метрические) - + codec to use for writing strings кодек, который используется для записи строк - + language code to use for reading dual language files код языка, который используется для чтения двуязычных файлов - + Garmin Points of Interest (.gpi) Достопримечательности Garmin (.gpi) - - + + Return current position as a waypoint Возвращать текущее положение как маршрутную точку - - + Command unit to power itself down Отдавать модулю команду на самовыключение - + Erase existing courses when writing new ones Удалять существующие курсы при записи новых - + Sync GPS time to computer time Синхронизировать время GPS с временем компьютера - + Category number to use for written waypoints Номер категории для записанных маршрутных точек - + Speed in bits per second of serial port (baud=9600) Скорость последовательного порта в битах в секунду (baud=9600) - + + override codec to use for device + + + + Garmin serial/USB protocol Последовательный/USB-протокол Garmin - + Write course rather than history, default yes Записывать курс, а не журнал, по умолчанию: да - + Sport: Biking (deflt), Running, MultiSport, Other Виды спорта: велоспорт (по умолчанию), бег, различные виды спорта, другое - + Garmin Training Center (.tcx/.crs/.hst/.xml) Тренировочный центр Garmin (.tcx/.crs/.hst/.xml) - + Omit Placer name Опускать имя разместившего - + Geocaching.com .loc Geocaching.com .loc - Geogrid-Viewer ascii overlay file (.ovl) - ASCII-файл наложения Geogrid Viewer (.ovl) + ASCII-файл наложения Geogrid Viewer (.ovl) - Geogrid-Viewer binary overlay file (.ovl) - Двоичный файл наложения Geogrid Viewer (.ovl) + Двоичный файл наложения Geogrid Viewer (.ovl) - Geogrid-Viewer tracklogs (.log) - Журналы треков Geogrid-Viewer (.log) + Журналы треков Geogrid-Viewer (.log) - + Compact Output. Default is off. Компактный вывод. По умолчанию отключено. - + GeoJson GeoJson - GEOnet Names Server (GNS) - Сервер имён GEOnet (GNS) + Сервер имён GEOnet (GNS) - - - - - - - - + + + + + + Erase device data after download Удалять данные устройства после загрузки - - - - + + + + Only erase device data, do not download anything Только удалять данные устройства, ничего не загружать - + GlobalSat DG-100/BT-335 Download Загрузка GlobalSat DG-100/BT-335 - + GlobalSat DG-200 Download Загрузка GlobalSat DG-200 - + list tracks вывести треки - + get track получить трек - - - - + + + + Dump raw data to this file Записать дамп необработанных данных в этот файл - + GlobalSat GH625XT GPS training watch Спортивные часы GlobalSat GH625XT GPS - Google Directions XML - Google Directions XML + Google Directions XML - + Export linestrings for tracks and routes Экспортировать данные линий для треков и маршрутов - + Export placemarks for tracks and routes Экспортировать метки мест для треков и маршрутов - + Width of lines, in pixels Ширина линий, в пикселах - + Line color, specified in hex AABBGGRR Цвет линии (шестнадцатеричное значение AABBGGRR) - + Altitudes are absolute and not clamped to ground Высоты абсолютны и не привязаны к земле - + Draw extrusion line from trackpoint to ground Рисовать соединительную линию от точки трека до земли - + Write KML track (default = 0) Записывать трек KML (по умолчанию = 0) - + Include extended data for trackpoints (default = 1) Включать расширенные данные для точек треков (по умолчанию = 1) - + Indicate direction of travel in track icons (default = 0) Указывать направление движения на значках треков (по умолчанию = 0) - + Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical, 'a'viation) Единицы, используемые при написании комментариев ('s' — английские, 'm' — метрические, 'n' — морские, 'a' — авиационные) - + Display labels on track and routepoints (default = 1) Показывать подписи в точках трека и пути (по умолчанию = 1) - + Retain at most this number of position points (0 = unlimited) Сохранять не более этого количества точек положения (0 = без ограничений) - + Rotate colors for tracks and routes (default automatic) Варьировать цвета для треков и маршрутов (по умолчанию: автоматически) - + Precision of coordinates, number of decimals Точность координат, количество цифр после запятой - + Google Earth (Keyhole) Markup Language Язык разметки Google Earth (Keyhole) - Google Navigator Tracklines (.trl) - Линии треков Google Navigator (.trl) + Линии треков Google Navigator (.trl) - + Complete date-free tracks with given date (YYYYMMDD). Добавлять в треки без даты указанную дату (ГГГГММДД). - + GPS Tracking Key Pro text Текст GPS Tracking Key Pro - + + Google Takeout Location History + + + + GPS TrackMaker GPS TrackMaker - + GPSBabel arc filter file Файл дугового фильтра GPSBabel - + GpsDrive Format Формат GpsDrive - + GpsDrive Format for Tracks Формат GpsDrive для треков - + No whitespace in generated shortnames Запретить пробелы в генерируемых коротких названиях - + Create waypoints from geocache log entries Создавать маршрутные точки на основе записей журнала геокэша - + Base URL for link tag in output Базовый URL-адрес для тега ссылки в выводе - + Target GPX version for output Целевая версия GPX для вывода - + Add info (depth) as Humminbird extension Добавлять информацию (глубину) как расширение Humminbird - + Add info (depth) as Garmin extension Добавлять информацию (глубину) как расширение Garmin - + Precision of elevations, number of decimals Точность высот, количество цифр после запятой - + GPX XML GPX XML - HikeTech - HikeTech + HikeTech - Holux (gm-100) .wpo Format - Формат Holux (gm-100) .wpo + Формат Holux (gm-100) .wpo - - - - + + + + MTK compatible CSV output file Выходной файл CSV, совместимый с MTK - + Holux M-241 (MTK based) Binary File Format Формат двоичных файлов Holux M-241 (на основе MTK) - - - + + Enable logging after download Включить ведение журнала после загрузки - - + + Size of blocks in KB to request from device Размер блоков в КБ для запроса у устройства - + Holux M-241 (MTK based) download Загрузка Holux M-241 (на основе MTK) - + Path to HTML style sheet Путь к таблице стилей HTML - - - + + + Encrypt hints using ROT13 Зашифровывать подсказки с помощью ROT13 - - + + Include groundspeak logs if present Включать журналы Groundspeak (если доступны) - - + + Degrees output as 'ddd', 'dmm'(default) or 'dms' Вывод градусов как "ddd" (десятичные градусы), "dmm" (десятичные минуты, по умолчанию) или "dms" (десятичные секунды) - - + + Units for altitude (f)eet or (m)etres Единицы высоты, "f" (футы) или "m" (метры) - + HTML Output Вывод HTML - + Humminbird tracks (.ht) Треки Humminbird (.ht) - + Humminbird waypoints and routes (.hwr) Маршрутные точки и маршруты Humminbird (.hwr) - Index of track to write (if more than one in source) - Индекс трека для записи (если в источнике больше одного) + Индекс трека для записи (если в источнике больше одного) - IGN Rando track files - Файлы треков IGN Rando + Файлы треков IGN Rando - iGo Primo points of interest (.upoi) - Достопримечательности iGo Primo (.upoi) + Достопримечательности iGo Primo (.upoi) - iGO2008 points of interest (.upoi) - Достопримечательности iGO2008 (.upoi) + Достопримечательности iGO2008 (.upoi) - Track identification number - Идентификационный номер трека + Идентификационный номер трека - Track title - Название трека + Название трека - Track description - Описание трека + Описание трека - IGO8 .trk - IGO8 .trk + IGO8 .trk - Kompass (DAV) Track (.tk) - Трек Kompass (DAV) (.tk) + Трек Kompass (DAV) (.tk) - Kompass (DAV) Waypoints (.wp) - Маршрутные точки Kompass (DAV) (.wp) + Маршрутные точки Kompass (DAV) (.wp) - + (USR input) Ignore event marker icons on read (ввод USR) Игнорировать значки маркеров событий при чтении - + (USR output) Treat waypoints as icons on write (вывод USR) Рассматривать маршрутные точки как значки при записи - + (USR output) Merge into one segmented trail (вывод USR) Объединять в один сегментированный след - + (USR input) Break segments into separate trails (ввод USR) Разбивать сегменты на отдельные следы - + (USR output) Write version (USR input) Read version (вывод USR) Версия для записи - + (USR output) Output file title string (вывод USR) Строка названия выходного файла - + (USR output) Device serial number (вывод USR) Серийный номер устройства - + (USR output) Output file content description (вывод USR) Описание содержимого выходного файла - + Lowrance USR Lowrance USR - - - Max number of comments to write (maxcmts=200) - Максимальное количество комментариев для записи (maxcmts=200) + Максимальное количество комментариев для записи (maxcmts=200) - Magellan SD files (as for eXplorist) - Файлы Magellan SD (для eXplorist) + Файлы Magellan SD (для eXplorist) - Magellan SD files (as for Meridian) - Файлы Magellan SD (для Meridian) + Файлы Magellan SD (для Meridian) - Numeric value of bitrate (baud=4800) - Числовое значение скорости потока (baud=4800) + Числовое значение скорости потока (baud=4800) - Suppress use of handshaking in name of speed - Подавлять использование рукопожатий для увеличения скорости + Подавлять использование рукопожатий для увеличения скорости - - Delete all waypoints - Удалять все маршрутные точки + Удалять все маршрутные точки - Magellan serial protocol - Последовательный протокол Magellan + Последовательный протокол Magellan - MagicMaps IK3D project file (.ikt) - Файл проекта MagicMaps IK3D (.ikt) + Файл проекта MagicMaps IK3D (.ikt) - Mainnav - Mainnav + Mainnav - Include only via stations in route - Принимать только точки от станций для маршрута + Принимать только точки от станций для маршрута - Map&Guide 'TourExchangeFormat' XML - Map&Guide 'TourExchangeFormat' XML + Map&Guide 'TourExchangeFormat' XML - MapAsia track file (.tr7) - Файл трека MapAsia (.tr7) + Файл трека MapAsia (.tr7) - Mapbar (China) navigation track for Sonim Xp3300 - Навигационный трек Mapbar (Китай) для Sonim Xp3300 + Навигационный трек Mapbar (Китай) для Sonim Xp3300 - Mapfactor Navigator - Mapfactor Navigator + Mapfactor Navigator - Mapopolis.com Mapconverter CSV - Mapopolis.com Mapconverter CSV + Mapopolis.com Mapconverter CSV - MapTech Exchange Format - MapTech Exchange Format + MapTech Exchange Format - Speed in bits per second of serial port (autodetect=0) - Скорость последовательного порта в битах в секунду (автоопределение=0) + Скорость последовательного порта в битах в секунду (автоопределение=0) - Download logged fixes - Загружать занесённые в журнал исправления + Загружать занесённые в журнал исправления - Show device status - Показывать состояние устройства + Показывать состояние устройства - MediaTek Locus - MediaTek Locus + MediaTek Locus - Write items 'locked' [default no] - Записывать объекты "заблокированными" [по умолчанию: нет] + Записывать объекты "заблокированными" [по умолчанию: нет] - Write items 'visible' [default yes] - Записывать объекты "видимыми" [по умолчанию: да] + Записывать объекты "видимыми" [по умолчанию: да] - Write files with internal version [n] - Записывать файлы с внутренней версией [n] + Записывать файлы с внутренней версией [n] - Memory-Map Navigator overlay files (.mmo) - Файлы наложения Memory-Map Navigator (.mmo) + Файлы наложения Memory-Map Navigator (.mmo) - Microsoft Streets and Trips 2002-2007 - Microsoft Streets and Trips 2002-2007 + Microsoft Streets and Trips 2002-2007 - - + + Baud rate used for download Скорость загрузки в бодах - - + + First sector to be read from the device Первый сектор для чтения с устройства - - + + Baud rate used to init device (0=autodetect) Скорость инициализации устройства в бодах (0=автоопределение) - - + + Last sector to be read from the device (-1: smart read everything) Последний сектор для чтения с устройства (-1: интеллектуальное чтение всего) - - + + Disable output (useful with erase) Отключать вывод (полезно при удалении) - - + + Number of sectors to read at once (0=use single sector mode) Количество секторов для одновременного чтения (0=использовать односекторный режим) - + POI for Home Symbol as lat:lng[:alt] Указать расположение значка дома как lat:lng[:alt] - + POI for Car Symbol as lat:lng[:alt] Указать расположение значка автомобиля как lat:lng[:alt] - + POI for Boat Symbol as lat:lng[:alt] Указать расположение значка корабля как lat:lng[:alt] - + POI for Heart Symbol as lat:lng[:alt] Указать расположение значка сердца как lat:lng[:alt] - + POI for Bar Symbol as lat:lng[:alt] Указать расположение значка ресторана как lat:lng[:alt] - + MiniHomer, a skyTraq Venus 6 based logger (download tracks, waypoints and get/set POI) MiniHomer, средство записи данных на основе skyTraq Venus 6 (загрузка треков, маршрутных точек, а также получение/установка точек интереса) - + Garmin Mobile XT ([ATRK]/STRK) Garmin Mobile XT ([ATRK]/STRK) - + Track name processing option ([0]-nrm/1-ign) Параметр обработки названий треков ([0]-nrm/1-ign) - + Mobile Garmin XT Track files Файлы треков Mobile Garmin XT - Motoactiv CSV - Motoactiv CSV + Motoactiv CSV - Index of route to write (if more than one in source) - Индекс маршрута для записи (если в источнике больше одного) + Индекс маршрута для записи (если в источнике больше одного) - New name for the route - Новое имя маршрута + Новое имя маршрута - Radius of our big earth (default 6371000 meters) - Радиус Земли (по умолчанию: 6371000 метров) + Радиус Земли (по умолчанию: 6371000 метров) - Motorrad Routenplaner (Map&Guide) .bcr files - Файлы Motorrad Routenplaner (Map&Guide) .bcr + Файлы Motorrad Routenplaner (Map&Guide) .bcr - + MTK Logger (iBlue 747,...) Binary File Format Формат двоичных файлов MTK Logger (iBlue 747,...) - + MTK Logger (iBlue 747,Qstarz BT-1000,...) download Загрузка MTK Logger (iBlue 747,Qstarz BT-1000,...) - MyNav TRC format - Формат MyNav TRC + Формат MyNav TRC - + Datum (default=NAD27) Система координат (по умолчанию=NAD27) - + National Geographic Topo .tpg (waypoints) National Geographic Topo .tpg (маршрутные точки) - + National Geographic Topo 2.x .tpo National Geographic Topo 2.x .tpo - + National Geographic Topo 3.x/4.x .tpo National Geographic Topo 3.x/4.x .tpo - Navigon Waypoints - Маршрутные точки Navigon + Маршрутные точки Navigon - Delete all track points - Удалять все точки треков + Удалять все точки треков - Delete all routes - Удалять все маршруты + Удалять все маршруты - Clear the datalog - Очищать журнал данных + Очищать журнал данных - Read from datalogger buffer - Читать из буфера средства записи данных + Читать из буфера средства записи данных - NaviGPS GT-11/BGT-11 Download - Загрузка NaviGPS GT-11/BGT-11 + Загрузка NaviGPS GT-11/BGT-11 - NaviGPS GT-31/BGT-31 datalogger (.sbp) - Средство записи данных NaviGPS GT-31/BGT-31 (.sbp) + Средство записи данных NaviGPS GT-31/BGT-31 (.sbp) - NaviGPS GT-31/BGT-31 SiRF binary logfile (.sbn) - Двоичный файл журнала NaviGPS GT-31/BGT-31 SiRF (.sbn) + Двоичный файл журнала NaviGPS GT-31/BGT-31 SiRF (.sbn) - Navitel binary track (.bin) - Двоичный трек Navitel (.bin) + Двоичный трек Navitel (.bin) - Navitrak DNA marker format - Формат маркеров ДНК Navitrak + Формат маркеров ДНК Navitrak - NIMA/GNIS Geographic Names File - Файл географических названий NIMA/GNIS + Файл географических названий NIMA/GNIS - + Max length of waypoint name to write Максимальная длина имени маршрутной точки для записи - + Read/write GPRMC sentences Читать/записывать последовательности GPRMC - + Read/write GPGGA sentences Читать/записывать последовательности GPGGA - + Read/write GPVTG sentences Читать/записывать последовательности GPVTG - + Read/write GPGSA sentences Читать/записывать последовательности GPGSA - + Decimal seconds to pause between groups of strings Пауза (в секундах) между группами строк - + Append realtime positioning data to the output file instead of truncating Добавлять данные о расположении в реальном времени в конце выходного файла, а не усекать их - + Speed in bits per second of serial port (baud=4800) Скорость последовательного порта в битах в секунду (baud=4800) - + Write tracks for Gisteq Phototracker Записывать треки для Gisteq Phototracker - + Accept position fixes in gpgga marked invalid Принимать исправления расположения в gpgga, отмеченные как некорректные - + NMEA 0183 sentences Последовательности NMEA 0183 - Compact binary representation - Компактное двоичное представление + Компактное двоичное представление - Nokia Landmark Exchange - Nokia Landmark Exchange + Nokia Landmark Exchange - + Write additional way tag key/value pairs Записывать дополнительные пары ключ/значение меток пути - + Write additional node tag key/value pairs Записывать дополнительные пары ключ/значение меток узлов - + Use this value as custom created_by value Использовать это значение как пользовательское значение created_by - + OpenStreetMap data files Файлы данных OpenStreetMap - + Write all tracks into one file Записывать все треки в один файл - + Waypoint foreground color Цвет переднего плана маршрутных точек - + Waypoint background color Цвет фона маршрутных точек - + Proximity distance Расстояние близости - + Unit used in altitude values Единица для значений высот - + Unit used in proximity values Единица для значений близости - + codec to use for reading and writing strings (default windows-1252) кодек для чтения и записи строк (по умолчанию: windows-1252) - + OziExplorer OziExplorer - + Qstarz BL-1000 Qstarz BL-1000 - Default location - Стандартное расположение + Стандартное расположение - Raymarine Waypoint File (.rwf) - Файл маршрутных точек Raymarine (.rwf) + Файл маршрутных точек Raymarine (.rwf) - Ricoh GPS Log File - Файл журнала Ricoh GPS + Файл журнала Ricoh GPS - See You flight analysis data - Данные анализа полёта See You + Данные анализа полёта See You - + Set location finder target location as lat,lng Задать расположение цели средства поиска расположений как lat,lng - + Configure logging parameter as tmin:tmax:dmin:dmax Настроить параметр ведения журнала как tmin:tmax:dmin:dmax - + Video position for which exact GPS time is known (hhmmss[.sss], default is 00:00:00,000) Позиция в видео, для которой известно точное время GPS (ччммсс[.ссс], по умолчанию: 00:00:00,000) - + GPS time at position video_time (hhmmss[.sss], default is first timestamp of track) Время GPS в позиции video_time (ччммсс[.ссс], по умолчанию: первая временная метка трека) - + GPS date at position video_time (yyyymmdd, default is first timestamp of track) Дата GPS в позиции video_time (ггггммдд, по умолчанию: первая временная метка трека) - - - + + + Seconds that GPS time tracks UTC (0: best guess) Количество секунд смещения времени GPS от UTC (0: наилучшее предполагаемое) - - - + + + GPS week rollover period we're in (-1: best guess) Актуальный период сброса номера недели GPS (-1: наилучшее предполагаемое) - + SkyTraq Venus based loggers (download) Средства записи данных на основе SkyTraq Venus (загрузка) - + First sector to be read from the file Первый сектор для чтения из файла - + Last sector to be read from the file (-1: read till empty sector) Последний сектор для чтения из файла (-1: читать до достижения пустого сектора) - + SkyTraq Venus based loggers Binary File Format Формат двоичных файлов средств записи данных на основе SkyTraq Venus - + Format for subtitles Формат для субтитров - + SubRip subtitles for video mapping (.srt) Субтитры SubRip для видеокартографирования (.srt) - Swiss Map 25/50/100 (.xol) - Swiss Map 25/50/100 (.xol) + Swiss Map 25/50/100 (.xol) - + Tab delimited fields useful for OpenOffice Разделённые табуляциями поля для OpenOffice - Teletype [ Get Jonathon Johnson to describe - Телетайп + Телетайп - + Suppress separator lines between waypoints Подавлять разделительные линии между маршрутными точками - + Write each waypoint in a separate file Записывать каждую маршрутную точку в отдельный файл - + Textual Output Текстовый вывод - TomTom Itineraries (.itn) - Маршруты TomTom (.itn) + Маршруты TomTom (.itn) - TomTom Places Itineraries (.itn) - Маршруты TomTom Places (.itn) + Маршруты TomTom Places (.itn) - TomTom POI file (.asc) - Файл достопримечательностей TomTom (.asc) + Файл достопримечательностей TomTom (.asc) - TomTom POI file (.ov2) - Файл достопримечательностей TomTom (.ov2) + Файл достопримечательностей TomTom (.ov2) - Index of track (if more than one in source) - Индекс трека (если в источнике больше одного) + Индекс трека (если в источнике больше одного) - TrackLogs digital mapping (.trl) - Цифровая картография TrackLogs (.trl) + Цифровая картография TrackLogs (.trl) - + Write name(s) of format(s) from input session(s) Записывать названия форматов из входных сеансов - + Write filename(s) from input session(s) Записывать имена файлов из входных сеансов - + Universal csv with field structure in first line Универсальный csv со структурой полей в первой строке - + Vcard Output (for iPod) Вывод Vcard (для iPod) - Wintec TES file - Файл Wintec TES + Файл Wintec TES - Wintec WBT-100/200 Binary File Format - Формат двоичных файлов Wintec WBT-100/200 + Формат двоичных файлов Wintec WBT-100/200 - Wintec WBT-100/200 GPS Download - Загрузка Wintec WBT-100/200 GPS + Загрузка Wintec WBT-100/200 GPS - Wintec WBT-201/G-Rays 2 Binary File Format - Формат двоичных файлов Wintec WBT-201/G-Rays 2 + Формат двоичных файлов Wintec WBT-201/G-Rays 2 - - Appends the input to a backup file - Добавляет входные данные в файл резервной копии + Добавляет входные данные в файл резервной копии - - Only waypoints that are not the backup file - Только маршрутные точки, которые не хранятся в резервном файле + Только маршрутные точки, которые не хранятся в резервном файле - XAiOX iTrackU Logger - Средство записи данных XAiOX iTrackU + Средство записи данных XAiOX iTrackU - XAiOX iTrackU Logger Binary File Format - Формат двоичных файлов средства записи данных XAiOX iTrackU + Формат двоичных файлов средства записи данных XAiOX iTrackU diff --git a/gui/gpsbabelfe_de.qm b/gui/gpsbabelfe_de.qm index 86d1536dd1f2736ee25252f019ed72988510d6d3..d9f31d0ea5d326cde9370b2eb2e1aef5c4486cae 100644 GIT binary patch delta 1006 zcmXAoe@xV69LL{$pYIR8cgKAJVKMYDPPw`C&d7l_>E=vuu`x-|9JXW$V+csaO6tfT z#qN$Q2R&z|Rb|M)&F z$JvvkY-Zkf6=}l{J3JRNXAG6^4UQiKAXQYZTb92Rh;M95UA<+`DS$Nt4GF|u#07wS z1=y1gC??|WDMqZsmubEU)N^7Tu&Dv?RYP#z0*tdD9{3QL_AkVd5O8u3Vk8Tg-Ue~( z3t(aI6xVH^;>jBje`y7Sf2{5AjIv-Kq=K`+whl7I3|WvO|=D`y;H?llomzl>1}A=1SDpPP$&gN8<|8yBT`# zIDp3a2&_@b`6%$h&bUDo(RsQk}I_Y*LNt zbW!w4!>Zes0p#e_&yF){_7&B$pZ?o9X0^THH{kjA)oc0WXVDeiJm(gmt4Ejp-cOX) zH#+;Od!(?CUzBa>=c;tKtBL_?Tt{(`0LfXG&UQ@ zueJjE4aS)LD=KfJmQuS6sOi!cPQO+RyD9Xn&^m bsQ(5<<*x=JrQB;;92k!;ZVG(wij@2hdNemK delta 1413 zcmc&yi&Io(6#sGW-g|eK6_JM+)p}XwF@Z~1ffYlhBaO@yG`t)f6WG1N9oSvkUED&9 z9Ed<1jlKY9SYQAjfr$t;rcHwnV!=vGrKXo!&ZJh8I!>dFlXMnml==s{cg}b2?|k3+ zo%1{2y>*apJj92mer#QE@|w5h%cw_23cEl3aRs1lXkM6C(2)V~b%1LQ`S-{_0f^@S z?;b#U6zEud&!0I={%OKCz`{3p2jOF+;fX!g7ggx-PX^HE^r`Q}NZexw|l zZ{GoWikoj43y!8hNdF9|i-VB2is}tPC}}5L3}KrFSaJlyzCxhsDTsYM)p!Zw0M+nT zLG*Kmz6xo1Hq~s0I*rT`5R=i9ifn5qa9l$6_!Lm7j@+RQ5L=3Od0T18C zXu~T+yO%x3#h99k0_sf%fydqr_y}1*>vk?|&_H8dz(wBtR zXzuUiVVaAE7shD&L@OVXN?O|odDD%vKyW!9z3>fSVm+JY%v`U;68ZU&txNf_egW8e znD-5|kdNelK5`m3mB-fe^SRx%%)_T~U0!yGH=D-$gygV6ph6W=KOh}r`-K-*kgtA0 z$mFlnn0GQsW8{3RS*&KGsU}RAyh?>f+J(E9t^wg`V*I=?Ag)PV(vl5~+t`T49O4TW ze~Wk-Fb#=!mpxAXhOuc)Oi0&BY0K~;px7(bCDqaludoy$jjMf2x|ZGahsBw6t*-NcT&bJ-W;w9=j_!w5)c&$_`h@x# zpgU2YYr_jzs};6hoW!4`6YJVIrFR(NcCmN|JWOZ>RY*unUq|-?l9%>+-L_ zt{N7hHS2xVLEnFOg;>`f#Oc6u%MKXLMFp?53|ivQ4bYROr43^Dc^rehLvJYcC0qE#{aDn za?O~Gm2kj@3gY&2IVo>Aa>mlSM1{t}?q1*=@+Glud#9@b73wlJdlGPhz zOQ~WhQ>+QHyHt_$-KtG-$*u~;qHa(Xt6Zu$6}gD4xX4A&VV^lx?ywY<%NB>NqSCE6 zV_mX8O|Ej-6|*d75|PuRx)fP;%c@Jx%~@$?QCq^F?Vr{6|1!Dzx- + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> @@ -471,17 +494,17 @@ p, li { white-space: pre-wrap; } default - + Select one or more input files eine oder mehrere Originaldateien markieren - + Output File Name Zieldatei-Name - + Error reading format configuration. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. @@ -490,7 +513,7 @@ This program cannot continue. Das Programm muss abgebrochen werden. - + Some file/device formats were not found during initialization. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. @@ -499,7 +522,7 @@ This program cannot continue. Das Prgramm muss abgebrochen werden. - + Input and output formats do not support %1 Keine Unterstützung für %1 im Ein- oder Ausgabeformat @@ -512,68 +535,68 @@ Das Prgramm muss abgebrochen werden. Eingabeformat unterstützt %1. Keine Unterstützung für %2 im Ausgabeformat - + Input does not support %1; output format supports %1 Keine Unterstützung für %1 im Eingabeformat; Ausgabeformat unterstützt %1 {1;?} - + Input format supports %1; output format does not support %1 Eingabeformat unterstützt %1. Keine Unterstützung für %1 im Ausgabeformat {1;?} - + Both input and output formats support %1 Ein- und Ausgabeformat unterstützen %1 - + waypoints Wegpunkte - + tracks tracks - + routes Routen - + There are no input options for format "%1" Es gibt keine Eingabeoptionen für das Format "%1" - - + + Options for %1 Optionen für %1 - + There are no output options for format "%1" Es gibt keine Ausgabeoptionen für das Format "%1" - + No valid waypoints/routes/tracks translation specified keine gültige Angabe von Wegpunkt-/Routen-/Trackfiltern - + No input file specified keine Quelldatei angegeben - + No valid output specified keine gültiges Ziel angegeben - + No output file specified keine Zieldatei angegeben @@ -586,33 +609,33 @@ Das Prgramm muss abgebrochen werden. Prozess endete mit code %1 - + Translation successful Konvertierung erfolgreich - + Error running gpsbabel: %1 Fehler beim Aufruf von gpsbabel: %1 - + Are you sure you want to reset all format options to default values? Sind Sie sicher, dass Sie alle Formatoptionen auf die Vorgaben stellen wollen? - + About %1 Über %1 - + One or more data filters are active Einer oder mehrere Datenfilter sind aktiviert - + No data filters are active Keine Datenfilter sind aktiv @@ -865,17 +888,17 @@ Das Prgramm muss abgebrochen werden. Map - + Error opening "gmapbase.html" file. Check installation - + Missing "gmapbase.html" file. Check installation Datei "gmapbase.html" nicht gefunden. Prüfen Sie die Installation - + Failed to load Google maps base page Fehler beim Laden der Google maps Hauptseite @@ -884,28 +907,28 @@ Das Prgramm muss abgebrochen werden. MiscFltWidget - - - - + + + + Tracks Tracks - - - - + + + + Waypoints Wegpunkte - - - - + + + + Routes Routen @@ -1137,7 +1160,7 @@ Manche Dateiformate unterstuetzen nur eine Teilmenge, entweder Wegpunkte oder Tr QObject - + Error processing formats from running process "gpsbabel -^3" at line %1 Fehler beim Verarbeiten der Formate vom laufenden Process "gpsbabel-^3" in Zeile %1 @@ -1352,7 +1375,7 @@ Diese Option korrigiert die Uhrzeit aller Trackpunkte. Dies kann nützlich sein, - + days Tage @@ -1364,7 +1387,7 @@ Diese Option korrigiert die Uhrzeit aller Trackpunkte. Dies kann nützlich sein, - + mins shortform variant seemed sensible Min. @@ -1396,28 +1419,43 @@ Diese Option wird zusammen mit ihrem Gegenspieler verwendet, um Trackpunkte zu v Start - + + + If checked, times specified here are based on this computer's current time zone. + + + + + + If checked, times specified here are UTC. + + + + + UTC + + + If checked, time specified here is based on this computer's current time zone. - Wenn angekreuzt, richtet sich die angegebene Zeit nach der Zeitzone dieses Computers. + Wenn angekreuzt, richtet sich die angegebene Zeit nach der Zeitzone dieses Computers. - If checked, the times specified here are based on the local computer's time zone. Otherwise it is UTC. - Wenn angekreuzt, richtet sich die angegebene Zeit nach der Zeitzone dieses Computers. Wenn nicht, wird UTC angenommen. + Wenn angekreuzt, richtet sich die angegebene Zeit nach der Zeitzone dieses Computers. Wenn nicht, wird UTC angenommen. - + Local Time Lokale Zeit - - + + Use track pts before this time. Nur Trackpunkte vor diesem Zeitpunkt behalten. - + Use only track points before this timestamp. This option is used in conjunction with the start option to discard all trackpoints outside of a given period of time. This option defines the end of the time period. @@ -1426,18 +1464,18 @@ This option is used in conjunction with the start option to discard all trackpoi Diese Option wird zusammen mit ihrem Gegenstück verwendet, um alle Trackpunkte auβerhalb eines Zeitfensters zu verwerfen. Diese Option definiert das Ende des Fensters. - + Stop Stop - + Pack all tracks into one. no sentence Tracks zu einem Track verketten - + Pack all tracks into one. This option causes all tracks to be appended to one another to form a single track. This option does not work if any two tracks overlap in time; in that case, consider using the merge option. @@ -1450,18 +1488,18 @@ Diese Option sorgt dafür, daβ alle Tracks hintereinander zu einen gemeinsamen Diese Option eignet sich am besten dafuer, Tracks zu verbinden, die durch eine Fehlfunktion oder eine automatische 'über-Nacht-Auftrennung' aufgeteilt wurden. - + Pack guesswork, depends on context Verketten - + Merge multiple tracks for the same way. Tracks auf einem Weg mischen. - + Merge multiple tracks for the same way. This option puts all track points from all tracks into a single track and sorts them by time stamp. Points with identical time stamps will be dropped. @@ -1470,12 +1508,12 @@ This option puts all track points from all tracks into a single track and sorts Diese Option übernimmt alle Punkte aus allen Tracks in einen einzigen Track und sortiert sie nach der Zeit. Punkte mit den gleichen Zeitdaten werden entfernt. - + Merge Mischen - + Split by Date Split tracks. nach Datum teilen @@ -1499,43 +1537,43 @@ Mehrere Tracks, die sich ueber Tagesgrenzen verteilen, können so ebenfalls an D Aufspalten - + If nonzero, the track will be split if the time between two points is greater than this parameter. If zero, the track will be split by date. Falls nicht Null, und wenn die Zeitdaten aufeinanderfolgender Trackpunkte gröβer sind als der angegebene Wert, wird der Track dort aufgesplittet. Bei Null wird der Track an den Datumsgrenzen aufgeteilt. - + hrs abbr point Std. - + Split by Dist. nach Entf. teilen - + If nonzero, the input track will be split into several tracks if the distance between successive track points is greater than the distance given as a parameter. Falls nicht Null, und wenn die Distanz aufeinanderfolgender Trackpunkte gröβer ist als der angegebene Wert, wird der Track dort aufgesplittet. - + ft ft - + m m - + km km - + mi meilen @@ -1557,43 +1595,43 @@ Diese Option erzeugt GPS Fixwerte und setzt diese für alle Trackpunkte auf die Die Option wird eingesetzt, um ein Format, das keine Fixdaten enthält in eines zu konvertieren, das sie voraussetzt. - + GPS Fixes GPS Fixdaten - + none keine - + pps PPS - + dgps DGPS - + 3d 3d - + 2d 2d - + Synthesize course. no sentence Kurswerte generieren - + Synthesize course. This option computes (or recomputes) a value for the GPS heading at each trackpoint. This is most useful with trackpoints from formats that don't support heading information or for trackpoints synthesized by the interpolate filter. The heading at each trackpoint is simply the course from the previous trackpoint in the track. The first trackpoint in each track is arbitrarily assigned a heading of 0 degrees. @@ -1602,23 +1640,23 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo Diese Option erzeugt oder errechnet einen Wert für den GPS-Kurs an jeden Trackpunkt. Das ist insbesondere dann nützlich, wenn ein Format konvertiert werden soll, das keine Kursdaten enthält - oder für Trackpunkte die vom Mittelwert-Filter generiert wurden. Der Kurs an einem Trackpunkt ist einfach die Richtung vom vorherigen Trackpunkt zum aktuellen. Dem ersten Trackpunkt in jedem Track wird automatisch ein Wert von null Grad zugewiesen. - + Course Kurs - + Synthesize speed. no sentence Tempodaten generieren - + Split by Time nach Zeit teilen - + Synthesize speed. This option computes a value for the GPS speed at each trackpoint. This is most useful with trackpoints from formats that don't support speed information or for trackpoints synthesized by the interpolate filter. The speed at each trackpoint is the average speed from the previous trackpoint (distance divided by time). The first trackpoint in each track is assigned a speed of "unknown." @@ -1628,7 +1666,7 @@ This option computes a value for the GPS speed at each trackpoint. This is most Diese Option generiert für jeden Trackpunkt einen Geschwindigkeitswert. Sie wird eingesetzt, wenn ein Format konvertiert werden soll, das diese Daten nicht enthält - oder bei Trackpunkten, die vom Mittelwert-Filter generiert wurden. Das Tempo an jedem Trackpunkt ist die mittlere Geschwindigkeit vom vorherigen (Weg durch Zeit). Dem ersten Trackpunkt in allen Tracks wird der Wert 'unbekannt' zugewiesen. - + Speed Geschwindikgkeit @@ -1644,44 +1682,44 @@ Diese Option generiert für jeden Trackpunkt einen Geschwindigkeitswert. Sie wir UpgradeCheck - - - + + + HTTP HTTP - + Unexpected reply. - + Download failed: %1. Download fehlgeschlagen: %1. - + Download failed: %1: %2. - + Error - + Invalid return data at line %1: %2. - + A new version of GPSBabel is available.<br />Your version is %1 <br />The latest version is %2 Eine neue Version von GPSBabel ist verfügbar.<br />Die installierte Version ist %1 <br />Die neueste Version ist %2 - + Do you wish to download an upgrade? Möchten Sie die Aktualisierung herunter laden? @@ -1690,7 +1728,7 @@ Diese Option generiert für jeden Trackpunkt einen Geschwindigkeitswert. Sie wir <center><b>Eine neue GPSBabel-Version ist verf&uumlgbar</b><br>Die Version auf diesem Computer ist %1 <br>Die neueste Version ist %2</center> - + Upgrade Update diff --git a/gui/gpsbabelfe_es.qm b/gui/gpsbabelfe_es.qm index 25587a7abe18e97db17bdb5f06cfbf0c93d37f19..4106d7b10bf643817205fa68933a8ae1dab34e2c 100644 GIT binary patch delta 947 zcmXAoZA?>F7{~wIbI-lpQioR5j$s{j)HtLWCOA!4S#X79go&vmyqFEci*xHR6P!+B zVd7fKG*gdlleLJ|h&ndLR*eoBuDlHfsEfnJ1WcwzXBMX<)9?kdhw$O#mwS?Ppa07_ zL!IoGcD5q(a)t4?Cn4Wha?;hZ@XwQH0r1M2_w9~sAl7(vNnw2`3b2Df?PcO|;vGQw z0|+e#R9d0nJjV)&8|eE!uu~9s0efnImTE}udw{+aa@%Ks;ZMjT{Xmxy@{JVWrPm?f zIt;8Yo@ZIoJiF|WZyy0e`1_-eO(j=e0nZr#8q>fF?SO0q-%g_&OTiDxKw1dAy$oo! zKsnEV-~f~k8Xug3GB?hU2lY({$tRGa|1ufZ`i4jib# z7O4-2wxej6j_dwH$wwD}rdpJoqZGVTD2*fa{vwpMJ_Q;+#7^g&>y2VOCMPjGf%6aR zfPE4oMH-pBfc~cU=(i_DhGa=>-V)m&^vg;iPFV`?bSI8r#|3t{cE` zF1!DGIS}t=)1!%i@kP0M#0s417WvF3wJs5dnI*fgfUisF1U~tXXMRf#qI-FMHqqte zo7htd_)G4q?r>0rbU+FJ!ABI;s4#Y%^f)QD)b_27FyC24st&)vkUXSqYS9sRz>=fk3>N zk!{j}4DklHNIj#XlDE}&OlYOv)4=H8T2*8l@Nu5z+_V+2FVdV(%T1gULYLcltoZzrf0~`r#DfmCd43O&2HBG|BH3W2#l^%@s4MNxGUP cmdBdZK-CUlY`<8LWRG}aYh983-jR3y2jq+&_W%F@ delta 1307 zcmc&yjc-#`6#w?0rqA%%!$V=Q#*=7Kd2oL`7YA`(r&gbzakc-jQSzrdT^d(Q8i zdp>^W-V^)zi9`IHykoBPFE4ktpL!&7q^fuL>=Gd9v9_$$<=q7U-wXtfk=#Y{XFxm+ zbaeyLJfNF)T*kg5xrlHz;A7;!3e>BFuYha00L-d@cJK|rFazyW1Q`0LEoRgYMWOxv z1EAm5cEeacJP2Xw81U|=5LOog+H?ptdkCL}5Yz&>oe=g{0l~cx_wiI?8N`EBqf3Pt z&uMrG(&7@T8H5y%?>-J`Pan|pF!O25%lkDbadiPB#VDCL12kVlDR&ZxvfdxC8|Lc70KDa?jKM^H1PJH@Ok3Y#@IQ{(v1E}?7O%TXy6cDqXXt1LFD~P z>ej^aIdewvTTP4UF!1{Yk}2jqlmg6;iMj11z}QySsN~xLTZ0egWl581oWlqZT_zS>w9{8*(GXd9%~h?8PTWo zztt4eb2TLA)YE^p4JBKgH2;xJY(}(leLYN)?D_$2)QYtq*&1xi@)S9z{ z#&MK|BrDgE%%UVBlkA3Mr)9q&eUvT}hlCLNXfQBNW$aN%NEDhdY5?iMRmj$QSp-ar~w$fvjXL zOyqHrO(mNQC!Jmd?q%^c!9r$*+%n2giUL@ZKue@u^J2B^tW})r6qiK~)GBhoy2iY9dT-@Oc%hEEiE8f4y5( zWOqPztFpGNw7|+%?VKYV_&)}8k89C?xDwC1G@ri9lbXGcCZYQnI_vy?#T)pSDLemW LTKHPa)XIMVUuJ(D diff --git a/gui/gpsbabelfe_es.ts b/gui/gpsbabelfe_es.ts index 8102a6d5c..25b2f449d 100644 --- a/gui/gpsbabelfe_es.ts +++ b/gui/gpsbabelfe_es.ts @@ -16,12 +16,13 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2023 Robert Lipe</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> @@ -31,6 +32,28 @@ p, li { white-space: pre-wrap; } <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> @@ -548,31 +571,31 @@ Higher number provides more detailed diagnostics. Defecto - + Select one or more input files Seleccionar uno o más archivos de entrada - + Output File Name Nombre del fichero de salida - + Error reading format configuration. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. Se ha producido un error cuando se intentaba leer la configuración. Compruebe que el núcleo de "gpsbabel" está instalado correctamente y que se halla en la RUTA actual. Este programa no puede continuar. - + Some file/device formats were not found during initialization. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. El formato de alfunos ficheros o dispositivos no se halló durante la inicialización. Compruebe que el núcleo de "gpsbabel" está instalado correctamente y que se halla en la RUTA actual. Este programa no puede continuar. - + Input and output formats do not support %1 Formatos de entrada y salida inadmisibles %1 @@ -581,68 +604,68 @@ This program cannot continue. Formatos de entrada inadmisible %1; Formatos de salida inadmisible %2 - + Input does not support %1; output format supports %1 Formatos de entrada inadmisible %1; Formatos de salida inadmisible %1 {1;?} - + Input format supports %1; output format does not support %1 - + Both input and output formats support %1 Formatos de entrada y salida admisibles (ambos) %1 - + waypoints Puntos de interés - + tracks Registro de trazados - + routes Rutas - + There are no input options for format "%1" No hay opciones de entrada para el formato "%1" - - + + Options for %1 Opciones de %1 - + There are no output options for format "%1" No hay opciones de salida para el formato "%1" - + No valid waypoints/routes/tracks translation specified Se han especificicado puntos de interés, trazados o rutas no traducibles - + No input file specified No se ha especificado el fichero de entrada - + No valid output specified El fichero de salida no es válido - + No output file specified No se ha especificado el fichero de salida @@ -655,33 +678,33 @@ This program cannot continue. El proceso terminó sin suerte y con el código %1 - + Translation successful Traducción realizada con éxito - + Error running gpsbabel: %1 Error ejecutando gpsbabel: %1 - + Are you sure you want to reset all format options to default values? ¿Estás seguro de que quieres volver a los formatos por defecto? - + About %1 Acerca de %1 - + One or more data filters are active Uno o más filtros de datos están activos - + No data filters are active Ningún filtro de datos está activo @@ -922,17 +945,17 @@ This program cannot continue. Map - + Error opening "gmapbase.html" file. Check installation - + Missing "gmapbase.html" file. Check installation No se encuentra el fichero ""gmapbase.html". Compruebe la instalación - + Failed to load Google maps base page Fallo al buscar la página básica de los mapas de Googe @@ -941,28 +964,28 @@ This program cannot continue. MiscFltWidget - - - - + + + + Tracks Trazados - - - - + + + + Waypoints Puntos de interés - - - - + + + + Routes Rutas @@ -1189,7 +1212,7 @@ Algunos formatos de datos de los GPS solo permiten utilizar una parte de los pun QObject - + Error processing formats from running process "gpsbabel -^3" at line %1 Error al procesar los formatos seleccionados en el proceso "gpsbabel -^3" en la línea %1 @@ -1398,7 +1421,7 @@ This option changes the time of all trackpoints. This might be useful if your tr - + days días @@ -1409,7 +1432,7 @@ This option changes the time of all trackpoints. This might be useful if your tr - + mins minutos @@ -1439,45 +1462,60 @@ Esta opción se utiliza junto con la de parar (stop) para descartar puntos que f Comenzar - + + + If checked, times specified here are based on this computer's current time zone. + + + + + + If checked, times specified here are UTC. + + + + + UTC + + + If checked, time specified here is based on this computer's current time zone. - Si seleccionado, los datos especificados se basan en la zona horaria de tu ordenador. + Si seleccionado, los datos especificados se basan en la zona horaria de tu ordenador. - If checked, the times specified here are based on the local computer's time zone. Otherwise it is UTC. - Si seleccionado, los datos especificados se basan en la zona horaria de tu ordenador. En caso contrario, es UTC. + Si seleccionado, los datos especificados se basan en la zona horaria de tu ordenador. En caso contrario, es UTC. - + Local Time Hora local - - + + Use track pts before this time. Usa los puntos del trazado tomados antes de esta hora. - + Use only track points before this timestamp. This option is used in conjunction with the start option to discard all trackpoints outside of a given period of time. This option defines the end of the time period. Usa los puntos del trazado tomados antes de esta marca de tiempo. Esta opción se usa junto con la opción comenzar para descartar todos los puntos no tomados en determinado período temporal. Esta opción define el final del período. - + Stop Parar - + Pack all tracks into one. Junta todos los trazados en uno. - + Pack all tracks into one. This option causes all tracks to be appended to one another to form a single track. This option does not work if any two tracks overlap in time; in that case, consider using the merge option. @@ -1490,17 +1528,17 @@ Esta opción hace que todos los trazados se añadan uno tras otros hasta formar Esta opción es muy útil para juntar trazados que se interrumpieron por un error en el equipo o por una parada para descansar. - + Pack Juntar - + Merge multiple tracks for the same way. Unir diversos trazados repetitivos. - + Merge multiple tracks for the same way. This option puts all track points from all tracks into a single track and sorts them by time stamp. Points with identical time stamps will be dropped. @@ -1509,12 +1547,12 @@ This option puts all track points from all tracks into a single track and sorts Esta opción pone todos los puntos de todos los trazados en un único trazado y los ordena por la marca de tiempo. Los puntos con idénticas marcas de tiempo son borrados. - + Merge Unir - + Split by Date Split tracks. Dividir trazados por fecha @@ -1537,42 +1575,42 @@ Si la entrada tiene múltiples trazados, júntalos antes de dividirlos por día. Dividir - + If nonzero, the track will be split if the time between two points is greater than this parameter. If zero, the track will be split by date. Si "nonzero", el trazado será dividido si el tiempo entre dos puntos es mayor que el parámetro. Si "zero", el trazado será dividido por día. - + hrs hrs - + Split by Dist. Dividir trazados por distancia. - + If nonzero, the input track will be split into several tracks if the distance between successive track points is greater than the distance given as a parameter. Si "nonzero", el trazado será dividido en varios trazados si la distancia entre dos puntos es mayor que el parámetro dado. - + ft ft - + m m - + km Km - + mi mi @@ -1594,42 +1632,42 @@ Esta opción fija el estatus de las correcciones GPS de todos los puntos del tra Esta opción es muy útil cuando se trata de convertir de un formato que no contiene ninguna corrección GPS a uno que la requiere. - + GPS Fixes Correcciones GPS - + none ninguno - + pps pps - + dgps dgps - + 3d 3d - + 2d 2d - + Synthesize course. Sintetizar el rumbo. - + Synthesize course. This option computes (or recomputes) a value for the GPS heading at each trackpoint. This is most useful with trackpoints from formats that don't support heading information or for trackpoints synthesized by the interpolate filter. The heading at each trackpoint is simply the course from the previous trackpoint in the track. The first trackpoint in each track is arbitrarily assigned a heading of 0 degrees. @@ -1638,22 +1676,22 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo Esta opción calcula (o recalcula) un valor para el rumbo de cada punto del trazado. Es muy útil para puntos de trazado en formatos que no contienen información sobre el rumbo o para puntos de trazado calculados con el filtro interpolar. El rumbo de cada punto es simplemente la dirección desde el punto previo en el trazado. El primer punto de cada trazado tiene el valor arbitrario de 0 grados. - + Course Dirección - + Synthesize speed. Calcular velocidad. - + Split by Time Dividir trazados en función del tiempo - + Synthesize speed. This option computes a value for the GPS speed at each trackpoint. This is most useful with trackpoints from formats that don't support speed information or for trackpoints synthesized by the interpolate filter. The speed at each trackpoint is the average speed from the previous trackpoint (distance divided by time). The first trackpoint in each track is assigned a speed of "unknown." @@ -1662,7 +1700,7 @@ This option computes a value for the GPS speed at each trackpoint. This is most Esta opción calcula (o recalcula) un valor para la velocidad de cada punto del trazado. Es muy útil para puntos de trazado en formatos que no contienen información sobre la velocidad o para puntos de trazado calculados con el filtro interpolar. La velocidad de cada punto es simplemente la media (distancia partido por tiempo) desde el punto previo en el trazado. El primer punto de cada trazado tiene el valor arbitrario de "desconocido". - + Speed Velocidad @@ -1678,44 +1716,44 @@ Esta opción calcula (o recalcula) un valor para la velocidad de cada punto del UpgradeCheck - - - + + + HTTP HTTP - + Unexpected reply. - + Download failed: %1. La descarga falló: %1. - + Download failed: %1: %2. - + Error Error - + Invalid return data at line %1: %2. Ha devuelto datos no válidos en la línea %1: %2. - + A new version of GPSBabel is available.<br />Your version is %1 <br />The latest version is %2 Una nueva versióon de GPSBabel ha salido ya. <br />Tu versión es la %1 <br />La última versióon sería %2 - + Do you wish to download an upgrade? ¿Quieres bajarte una actualización? @@ -1724,7 +1762,7 @@ Esta opción calcula (o recalcula) un valor para la velocidad de cada punto del <center><b>Una nueva versión de GPSBabel está disponible </b><br>La versión actual es %1 <br> La versión más reciente es %2</center> - + Upgrade Actualizar diff --git a/gui/gpsbabelfe_fr.qm b/gui/gpsbabelfe_fr.qm index 5210c75750959575a32164c9faca2d6192d382f3..8a277d4dbbcba713ecfce52b0c9f6c98ec97fb71 100644 GIT binary patch delta 35 tcmV+;0Nnqj53dgzJh)^S%I}<&%^@7WV4=O;rvLx|1!i(zMpCg5l?M*w4kG{n delta 25 hcmZ3_zm#9VW=D#|srPfHo>i3DpRjQ6-HlRH*#VID3#b49 diff --git a/gui/gpsbabelfe_fr.ts b/gui/gpsbabelfe_fr.ts index 13d403bfe..1575b5e41 100644 --- a/gui/gpsbabelfe_fr.ts +++ b/gui/gpsbabelfe_fr.ts @@ -16,12 +16,13 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2023 Robert Lipe</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> @@ -31,6 +32,28 @@ p, li { white-space: pre-wrap; } <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> @@ -432,128 +455,128 @@ Higher number provides more detailed diagnostics. MainWindow - + Select one or more input files - + Output File Name - + Error reading format configuration. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. - + Some file/device formats were not found during initialization. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. - + Input and output formats do not support %1 - + Input does not support %1; output format supports %1 - + Input format supports %1; output format does not support %1 - + Both input and output formats support %1 - + waypoints - + tracks - + routes - + There are no input options for format "%1" - - + + Options for %1 Options pour %1 - + There are no output options for format "%1" - + No valid waypoints/routes/tracks translation specified - + No input file specified - + No valid output specified - + No output file specified - + Translation successful - + Error running gpsbabel: %1 - + Are you sure you want to reset all format options to default values? - + About %1 - + One or more data filters are active - + No data filters are active @@ -782,17 +805,17 @@ This program cannot continue. Map - + Error opening "gmapbase.html" file. Check installation - + Missing "gmapbase.html" file. Check installation - + Failed to load Google maps base page @@ -801,28 +824,28 @@ This program cannot continue. MiscFltWidget - - - - + + + + Tracks Traces - - - - + + + + Waypoints Waypoints - - - - + + + + Routes Routes @@ -1014,7 +1037,7 @@ Some GPS data formats support only some subset of waypoints, tracks, and routes. QObject - + Error processing formats from running process "gpsbabel -^3" at line %1 @@ -1210,7 +1233,7 @@ This option changes the time of all trackpoints. This might be useful if your tr - + days @@ -1221,7 +1244,7 @@ This option changes the time of all trackpoints. This might be useful if your tr - + mins @@ -1249,45 +1272,35 @@ This option is used along with the stop to discard trackpoints that were recorde - - If checked, time specified here is based on this computer's current time zone. - - - - - If checked, the times specified here are based on the local computer's time zone. Otherwise it is UTC. - - - - + Local Time - - + + Use track pts before this time. - + Use only track points before this timestamp. This option is used in conjunction with the start option to discard all trackpoints outside of a given period of time. This option defines the end of the time period. - + Stop - + Pack all tracks into one. - + Pack all tracks into one. This option causes all tracks to be appended to one another to form a single track. This option does not work if any two tracks overlap in time; in that case, consider using the merge option. @@ -1296,139 +1309,156 @@ This option is most useful for rejoining tracks that might have been interrupted - + Pack - + Merge multiple tracks for the same way. - + Merge multiple tracks for the same way. This option puts all track points from all tracks into a single track and sorts them by time stamp. Points with identical time stamps will be dropped. - + Merge - + Split by Date Split tracks. - + If nonzero, the track will be split if the time between two points is greater than this parameter. If zero, the track will be split by date. - + hrs - + Split by Dist. - + If nonzero, the input track will be split into several tracks if the distance between successive track points is greater than the distance given as a parameter. - + ft - + m - + km - + mi - + GPS Fixes - + none - + pps - + dgps - + 3d - + 2d - + Synthesize course. - + Synthesize course. This option computes (or recomputes) a value for the GPS heading at each trackpoint. This is most useful with trackpoints from formats that don't support heading information or for trackpoints synthesized by the interpolate filter. The heading at each trackpoint is simply the course from the previous trackpoint in the track. The first trackpoint in each track is arbitrarily assigned a heading of 0 degrees. - + Course - + + + If checked, times specified here are based on this computer's current time zone. + + + + + + If checked, times specified here are UTC. + + + + + UTC + + + + Synthesize speed. - + Split by Time - + Synthesize speed. This option computes a value for the GPS speed at each trackpoint. This is most useful with trackpoints from formats that don't support speed information or for trackpoints synthesized by the interpolate filter. The speed at each trackpoint is the average speed from the previous trackpoint (distance divided by time). The first trackpoint in each track is assigned a speed of "unknown." - + Speed @@ -1444,49 +1474,49 @@ This option computes a value for the GPS speed at each trackpoint. This is most UpgradeCheck - - - + + + HTTP - + Unexpected reply. - + Download failed: %1. - + Download failed: %1: %2. - + Error - + Invalid return data at line %1: %2. - + A new version of GPSBabel is available.<br />Your version is %1 <br />The latest version is %2 - + Do you wish to download an upgrade? - + Upgrade diff --git a/gui/gpsbabelfe_hu.qm b/gui/gpsbabelfe_hu.qm index dbcefd6fc1060ac547a320161913a2aba67f9214..af5aa8ce10fa8f4036a09a241c2adf0dd97ba99e 100644 GIT binary patch delta 35 tcmV+;0Nnq~3DyZ3Jh)^S%I}<&%^@7WV4=O;rvLx|1!#3&NL8^AyaX6T4wC=? delta 25 hcmcb{d4^NKW=D#|srPfHo>i3DpRjQ6-HlRvSOAxO3=RMQ diff --git a/gui/gpsbabelfe_hu.ts b/gui/gpsbabelfe_hu.ts index d3aabb811..45337420a 100644 --- a/gui/gpsbabelfe_hu.ts +++ b/gui/gpsbabelfe_hu.ts @@ -16,12 +16,13 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2023 Robert Lipe</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> @@ -31,6 +32,28 @@ p, li { white-space: pre-wrap; } <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> @@ -432,128 +455,128 @@ Higher number provides more detailed diagnostics. MainWindow - + Select one or more input files - + Output File Name - + Error reading format configuration. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. - + Some file/device formats were not found during initialization. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. - + Input and output formats do not support %1 - + Input does not support %1; output format supports %1 - + Input format supports %1; output format does not support %1 - + Both input and output formats support %1 - + waypoints - + tracks - + routes - + There are no input options for format "%1" - - + + Options for %1 - + There are no output options for format "%1" - + No valid waypoints/routes/tracks translation specified - + No input file specified - + No valid output specified - + No output file specified - + Translation successful - + Error running gpsbabel: %1 - + Are you sure you want to reset all format options to default values? - + About %1 - + One or more data filters are active - + No data filters are active @@ -777,17 +800,17 @@ This program cannot continue. Map - + Error opening "gmapbase.html" file. Check installation - + Missing "gmapbase.html" file. Check installation - + Failed to load Google maps base page @@ -796,28 +819,28 @@ This program cannot continue. MiscFltWidget - - - - + + + + Tracks Nyomvonalak - - - - + + + + Waypoints Útpontok - - - - + + + + Routes Útvonalak @@ -1009,7 +1032,7 @@ Some GPS data formats support only some subset of waypoints, tracks, and routes. QObject - + Error processing formats from running process "gpsbabel -^3" at line %1 @@ -1205,7 +1228,7 @@ This option changes the time of all trackpoints. This might be useful if your tr - + days @@ -1216,7 +1239,7 @@ This option changes the time of all trackpoints. This might be useful if your tr - + mins @@ -1244,45 +1267,35 @@ This option is used along with the stop to discard trackpoints that were recorde - - If checked, time specified here is based on this computer's current time zone. - - - - - If checked, the times specified here are based on the local computer's time zone. Otherwise it is UTC. - - - - + Local Time - - + + Use track pts before this time. - + Use only track points before this timestamp. This option is used in conjunction with the start option to discard all trackpoints outside of a given period of time. This option defines the end of the time period. - + Stop - + Pack all tracks into one. - + Pack all tracks into one. This option causes all tracks to be appended to one another to form a single track. This option does not work if any two tracks overlap in time; in that case, consider using the merge option. @@ -1291,139 +1304,156 @@ This option is most useful for rejoining tracks that might have been interrupted - + Pack - + Merge multiple tracks for the same way. - + Merge multiple tracks for the same way. This option puts all track points from all tracks into a single track and sorts them by time stamp. Points with identical time stamps will be dropped. - + Merge - + Split by Date Split tracks. - + If nonzero, the track will be split if the time between two points is greater than this parameter. If zero, the track will be split by date. - + hrs - + Split by Dist. - + If nonzero, the input track will be split into several tracks if the distance between successive track points is greater than the distance given as a parameter. - + ft - + m - + km - + mi - + GPS Fixes - + none - + pps - + dgps - + 3d - + 2d - + Synthesize course. - + Synthesize course. This option computes (or recomputes) a value for the GPS heading at each trackpoint. This is most useful with trackpoints from formats that don't support heading information or for trackpoints synthesized by the interpolate filter. The heading at each trackpoint is simply the course from the previous trackpoint in the track. The first trackpoint in each track is arbitrarily assigned a heading of 0 degrees. - + Course - + + + If checked, times specified here are based on this computer's current time zone. + + + + + + If checked, times specified here are UTC. + + + + + UTC + + + + Synthesize speed. - + Split by Time - + Synthesize speed. This option computes a value for the GPS speed at each trackpoint. This is most useful with trackpoints from formats that don't support speed information or for trackpoints synthesized by the interpolate filter. The speed at each trackpoint is the average speed from the previous trackpoint (distance divided by time). The first trackpoint in each track is assigned a speed of "unknown." - + Speed @@ -1439,49 +1469,49 @@ This option computes a value for the GPS speed at each trackpoint. This is most UpgradeCheck - - - + + + HTTP - + Unexpected reply. - + Download failed: %1. - + Download failed: %1: %2. - + Error - + Invalid return data at line %1: %2. - + A new version of GPSBabel is available.<br />Your version is %1 <br />The latest version is %2 - + Do you wish to download an upgrade? - + Upgrade diff --git a/gui/gpsbabelfe_it.qm b/gui/gpsbabelfe_it.qm index ae4a8063d6197600cf930317bc8d5e851841614f..ea6b259f6079d0a61616032cd4d74bb4c54b2295 100644 GIT binary patch delta 947 zcmXAoe@vBC7{@=n?|a_syHKlgIc$IfawY+FGfPaO z6tLxl9WE{|B24pF4XkUcV1&U1MGPp!?BiP*5V&rhw;~E&)GTW`F_98Iae>~ z7drIVjPHt`x%RNxcOz~|PeEJv_*p;{m*#KvWWl_p^-pc9^!I^&2)r)E2E`mOZ-ajs zSfUkA%yA@LakZ)^piC;h1N*$tT#8nG4?=HXoOvH2qA{)qp>r5xG#;WJVca6_=6 zS2D-W8H}Im&}j|S{}q$l)rrXNhmQne+d43wM(pydIu-G$0ZBo`7X?r|gn3?vrYo53 zs(sUcn6vE`)MHueQF829X3sZgVDX<)JT8kv5?*bs!c)`&-K}`8jzQHLabUJKa`#+hZA$p?|F$*W4)$UVY$#P@2~3SK56_W1Iea=O|qB>VMoURNE)? z>7giCbj&EduBO=bwcMb)wU#h>R8PnXR*SUAi%=dZGQLy}dh5i7EX4zt#YTNf1-wUi zSO_UMMaj1+iNpc%t_VPWg{Zlx66$lwfAv!52f7%Uyain@@#Nk^Son#VxF8aqbC^j! z4+OL2VZ#;C``G+*(PnTiH=m@hg3mf+zmX8pl4+?5EQ6hemP5%OLu00#G2GgRGcr>o zXgzmiv1qq-Xx1G^PQmbyj5cGm=0TZh#-wx?S$&`1hG+L%8@<0mY`687b;{4`*K8}R zE8*lpTk_k(;5ut_Z=FyIhaE#{FM$1d$K&?9%6Z*x Z7|GYwM_eV77smz4=lymdFj)$J_V-RH0Z)KX3B<>7N!BVID#fRqBG)R;-)b{6Wu(wWEuM7?Q_pL?>Xmr zp1!Bw=cmr{tFu0KKKRAW9{+U0!xu{58vAY=5VoN+es^(S3BWf4s+I6{!a_j23iN&g zNNa$;CzkQbWx`B~8vqX@3Yq zvp}mJ#V1K>+hZs(B>~5?P}+YBI6MeXB}wc3o-OEh#tt38sl|HWKp95&7=XCFn0RF` zu?=IJx#ZZk4qc1o46x3s`w)3RR~47^=lwMGch<<+)^(oa{@FN6KCI=1Af-QB;v=(2 zThBai`Ryy<+0pqlwI#W0GLwn*1zVNailOnMW8go_W(ya+LmvD^8Xonz?>E%NET~UHIGJKS56^ z<)Go1dJTvlGtA9z0UA0C-|is#nJ*aATN;7E7-NQa2C%+kv=!YTLiwyqw8l;~7=J3y z1CF+s((35FX8d7FcaZ<%6>LGYa)T$?D#>OUjtsANQMR=;{8%u7-eG)rm-AO3(GY$q ziST?Q^GF#|d)jNj%RK9stlaS`HcJrri`|jT+{Hx}A7+-`NOckaB~}xcKk5(r=#Wli zGl>Zi<*0-UGCc6YPRGTz4n(Ed;R|JJP#Z#(>TWtR_R%es&T?HvEt_eIYn0)HLX%`T z=vEb~sn16lFRYZ4v6X5*Z93Hynsm2Y+i0hFdA5sCMiC0JoiG(;G)3F2P1iVP(`_Zx zUq`V66<7;v7(hcs`YnIDOmkesIpqEI9z2e#VJ=PUPZRk*=JWN z^teN}Dm@N+rR?xjRoD6yZ;BdflMi~_idB|#X^ywfr7E(^C%aU+sBpWL+3Q#9ddR(` zCzoB5iH$qN(GhaSPF(Lg_cMLp^GvJU^GtK2n)IpUhvulJ)J^&{AM?lq@=jA15|{fQ jaU|^jx`^BgSrn~M + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> @@ -698,17 +721,17 @@ Un numero più alto fornisce un livello di diagnosi più dettagliato.predefinite - + Select one or more input files Selezionare uno o più file in ingresso - + Output File Name Nome del file in uscita - + Error reading format configuration. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. @@ -717,7 +740,7 @@ This program cannot continue. Questo programma non può proseguire. - + Some file/device formats were not found during initialization. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. @@ -726,7 +749,7 @@ This program cannot continue. Questo programma non può proseguire. - + Input and output formats do not support %1 I formati di ingresso e di uscita non supportano %1 @@ -739,68 +762,68 @@ Questo programma non può proseguire. Il formato in ingresso supporta %1, il formato di destinazione non supporta %2 - + Input does not support %1; output format supports %1 L'ingresso non supporta %1, il formato di destinazione supporta %1 {1;?} - + Input format supports %1; output format does not support %1 Il formato in ingresso supporta %1, il formato di destinazione non supporta %1 {1;?} - + Both input and output formats support %1 I formati di origine e di destinazione supportano %1 - + waypoints punti di interesse - + tracks tracce - + routes rotte - + There are no input options for format "%1" Non ci sono opzioni in ingresso per il formato "%1" - - + + Options for %1 Opzioni per %1 - + There are no output options for format "%1" Non ci sono opzioni in uscita per il formato "%1" - + No valid waypoints/routes/tracks translation specified Non è stato specificato alcun punto di interesse/rotta/traccia - + No input file specified Il file di origine non è stato specificato - + No valid output specified Non è stata specificata una destinazione valida - + No output file specified Il file di destinazione non è stato specificato @@ -813,34 +836,34 @@ Questo programma non può proseguire. Il processo è terminato con il codice di errorre %1 - + Translation successful Traduzione terminata con successo - + Error running gpsbabel: %1 Errore durante l'esecuzione di gpsbabel: %1 - + Are you sure you want to reset all format options to default values? Si è certi di voler reimpostare tutte le opzioni dei formati ai valori predefiniti? - + About %1 Informazioni su %1 - + One or more data filters are active È attivo uno o più filtri di dati - + No data filters are active Nessun filtro di dati è attivo @@ -848,17 +871,17 @@ Questo programma non può proseguire. Map - + Error opening "gmapbase.html" file. Check installation - + Missing "gmapbase.html" file. Check installation Il file "gmapbase.html" manca. Verifica l'installazione - + Failed to load Google maps base page Non è stato possibile caricare la pagina di base delle mappe di Google @@ -882,28 +905,28 @@ Questo programma non può proseguire. - - - - + + + + Routes Rotte - - - - + + + + Tracks Tracce - - - - + + + + Waypoints Punti di interesse @@ -1114,7 +1137,7 @@ Qualche formato di dati del GPS supporta solo un sottoinsieme di punti di intere QObject - + Error processing formats from running process "gpsbabel -^3" at line %1 Si è verificato un errore durante l'elaborazione dei formati da parte del processo di lavoro "gpsbabel -^3" alla linea %1 @@ -1325,7 +1348,7 @@ Questa opzione modifica la data/l'ora di tutti i punti traccia. Può essere - + days giorni @@ -1336,7 +1359,7 @@ Questa opzione modifica la data/l'ora di tutti i punti traccia. Può essere - + mins minuti @@ -1366,28 +1389,26 @@ Questa opzione viene usata congiuntamente con lo stop per scartare i punti tracc Inizio - If checked, time specified here is based on this computer's current time zone. - Se selezionato, l'ora indicata qui è basata sul fuso orario impostato nel PC. + Se selezionato, l'ora indicata qui è basata sul fuso orario impostato nel PC. - If checked, the times specified here are based on the local computer's time zone. Otherwise it is UTC. - Se selezionato, gli orari specificati qui sono basati sul fuso orario del computer. Altrimenti saranno in UTC (fuso di Greenwich). + Se selezionato, gli orari specificati qui sono basati sul fuso orario del computer. Altrimenti saranno in UTC (fuso di Greenwich). - + Local Time Tempo locale - - + + Use track pts before this time. Usa i punti traccia prima di quest'ora. - + Use only track points before this timestamp. This option is used in conjunction with the start option to discard all trackpoints outside of a given period of time. This option defines the end of the time period. @@ -1396,17 +1417,17 @@ This option is used in conjunction with the start option to discard all trackpoi Questa opzione viene usata congiuntamente con l'inizio per scartare i punti traccia che sono stati salvati al di fuori di uno specifico intervallo temporale. Questa opzione specifica la fine dell'intervallo temporale. - + Stop Fine - + Pack all tracks into one. Concatena tutte le tracce in una. - + Pack all tracks into one. This option causes all tracks to be appended to one another to form a single track. This option does not work if any two tracks overlap in time; in that case, consider using the merge option. @@ -1419,17 +1440,17 @@ Questa opzione fa in modo che tutte le tracce vengano unite per formarne una sol Questa opzione è utile soprattutto per unire tracce che si sono interrotte per un malfunzionamento del dispositivo o per un arresto notturno. - + Pack Concatena - + Merge multiple tracks for the same way. Unisci più tracce per la stessa strada. - + Merge multiple tracks for the same way. This option puts all track points from all tracks into a single track and sorts them by time stamp. Points with identical time stamps will be dropped. @@ -1438,97 +1459,97 @@ This option puts all track points from all tracks into a single track and sorts Questa opzione inserisce tutti i punti di ogni traccia in una singola traccia e li ordina in base all'orario. I punti con lo stesso orario saranno tralasciati. - + Merge Unisci - + Split by Date Suddividi per data - + Split by Time Suddividi per ora - + If nonzero, the track will be split if the time between two points is greater than this parameter. If zero, the track will be split by date. Se diverso da zero, la traccia verrà suddivisa se il tempo tra due punti è maggiore di questo parametro. Se zero, la traccia verrà suddivisa in base al giorno. - + hrs ore - + Split by Dist. Suddividi per distanza - + If nonzero, the input track will be split into several tracks if the distance between successive track points is greater than the distance given as a parameter. Se non zero, la traccia in ingresso verrà suddivisa in più tracce se la distanza tra punti traccia successivi è maggiore della distanza specificata nel parametro. - + ft ft - + m m - + km km - + mi mi - + GPS Fixes Stato del GPS - + none nessuno - + pps pps - + dgps dgps - + 3d 3d - + 2d 2d - + Synthesize speed. Sintetizza la velocità. - + Synthesize speed. This option computes a value for the GPS speed at each trackpoint. This is most useful with trackpoints from formats that don't support speed information or for trackpoints synthesized by the interpolate filter. The speed at each trackpoint is the average speed from the previous trackpoint (distance divided by time). The first trackpoint in each track is assigned a speed of "unknown." @@ -1537,17 +1558,17 @@ This option computes a value for the GPS speed at each trackpoint. This is most Questa opzione calcola il valore della velocità GPS in ogni punto traccia. Risulta utile soprattutto con punti traccia tratti da un formato che non specifica informazioni sulla velocità o da punti traccia sintetizzati dal filtro di interpolazione. La velocità in ogni punto traccia è la velocità media calcolata dal punto precedente (distanza diviso il tempo). Al primo punto di ogni traccia viene assegnata una velocità "sconosciuta." - + Speed Velocità - + Synthesize course. Sintetizza la direzione. - + Synthesize course. This option computes (or recomputes) a value for the GPS heading at each trackpoint. This is most useful with trackpoints from formats that don't support heading information or for trackpoints synthesized by the interpolate filter. The heading at each trackpoint is simply the course from the previous trackpoint in the track. The first trackpoint in each track is arbitrarily assigned a heading of 0 degrees. @@ -1556,10 +1577,27 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo Questa opzione calcola (o ricalcola) un valore per la direzione del GPS in ogni punto traccia. Risulta utile soprattutto con punti traccia tratti da un formato che non specifica informazioni sulla direzione o da punti traccia sintetizzati dal filtro di interpolazione. La direzione in ogni punto traccia è tratta semplicemente dalla posizione del punto traccia precedente nella traccia stessa. Al primo punto di ogni traccia viene arbitrariamente assegnato un valore pari a 0 gradi. - + Course Direzione + + + + If checked, times specified here are based on this computer's current time zone. + + + + + + If checked, times specified here are UTC. + + + + + UTC + + Upgrade @@ -1572,49 +1610,49 @@ Questa opzione calcola (o ricalcola) un valore per la direzione del GPS in ogni UpgradeCheck - - - + + + HTTP HTTP - + Unexpected reply. - + Download failed: %1. Scaricamento non riuscito: %1. - + Download failed: %1: %2. - + Error Errore - + Invalid return data at line %1: %2. Dati ricevuti non validi alla linea %1: %2. - + A new version of GPSBabel is available.<br />Your version is %1 <br />The latest version is %2 È disponibile una nuova versione di GPSBabel.<br />Versione corrente: %1 <br />Nuova versione: %2 - + Upgrade Aggiorna - + Do you wish to download an upgrade? Si desidera scaricare un aggiornamento? diff --git a/gui/gpsbabelfe_ru.qm b/gui/gpsbabelfe_ru.qm index 8ce1120c1c7098fd399c6baf63d67e3e17c6004f..8e1046945faa6b397862bad83f1bc305fcac74cb 100644 GIT binary patch delta 2371 zcmX9=X;c(v7QNk7)!o%=R1!@xF$R~TBO(MvT!IKHNK_!GASkk^AhwVLC?aY{aS1LN z3<5G7gNh3d%d|F%qb4U&1Q$ebJuw>Bgg9XY1QpE@=QjQ8c764I@4N55`(AZUkyuzD z=6qz)bOCS!TvbGO;wQvUi4%w(#4zG0VhV9IaXZnISV|m2JWKQ<{z@E6d_`Oa)E5K7 z2B0*7xRbaA5DS5&fq?2d-zxz1N3ftiqvwZ0Ihn`+^=E+OT;ePsJr%g@1LdYiz@+C8 z4{~q7Fo@L*u&f*6r5fPrAc&2FfuNTVZ<5@y1_$P?bl}rah(G55O;;ecFj1e`4h+e* zqXk$s71Gcop!IK%rk(?iRX_@0rb+3L=1id|@sQ$+xc&grHW7$5Kq`v{PThfI<-V2A zpgJr7mySSHNy3-zLS-lBUktTRC=+Rc+8*cfdr%jZ5aaNE+I=AJHhiKjlqv5ZCOK2) zJrCgjcV<{{6w?c1$#^$H7k&q{Jx1vH8$i`P%u-VB=gkPezzck`5V5ohIJq7Xr8`Ne z43Ro2QF|NF#cjaR7f3eelE4V0+0XgE!SY=LfrN4_KSA`a!E%fJhkux3fu-tsk?|MS zoaTB%9{y4I5ZKp>9W_qCJa?21eoA7UINY2GRP=`}Tn2*Yq2}u-D%2Zyga+V?UFeP> zaX_I@N&~{iDgrc%fX|;PKF_HHW`rx|*K`A?wF*n(PFLV+zG9Q}5g@8naSXxCKvFtc z^}vLo%E4XlaAT};lw$Z#-?l|C%j=RLcvVtr2=ph-U5j3eN4sw*4Gnp^>S#a_5;CiXxzM`DccM9&sNpy3HFd<6-=9US5{>RSOSKHUe)fuY|`ud5&0qh0oJ(ivP}{hXN`c*ib80 zeayJN1>((I#tFV5zHDdQv0;+5nu*R?B02AQ#CYy~CAZ#W^76Rk>0|{C9G51P=h9?9 zNHcti))!Kc&;}guD}|yDu((B<=VfnElVq-@38N#W6_O3e&z4rMUJZn(q|Mf|z>8oh z{~~enhYpM#=fGq?smO&yM&6ZnH{`PaN3NGjJQ--8lXTFjgzj&V$~<{+{GXDoY8|D# zFP%tW38J@1CsqxlYjYjwKh%MXzjt895b0z%GdnUyy7J^2=fZmFVJ|-*#VWOwFm6hu z)cvRxm^NKCyqDd~U8)gzq3r*cNvgToztL>zs;CFdG-je|LDW0If>EkWl|WNgtG170 zAa7Z)EnF_JXn{i-s;K=+?&-q(+9DJ^VL1lB?PE<_hXyEei6M;Riy6RHHu2E*EnxY148{ZLoSj~TAjxA zvInR9DUFv8P2B;FZ}xOfRI6sLrNRJYgliH-x;j2Uv(!ZCCK@$nx93#kh9=_|0Vpog ztm-oWsEpTasdyKNtko3k;&)=IO;b4R7!?|(Ik`87X56MZJBrGLCu%OPI}4=7Yw9nY zqc{Ged2{#?;|!DK^Rswvw5+Yq;)HdPEl#Q2=U_qQbaKk(x^PW6p;y1v?v+|61 zw$-v7@|=C%oLrr9WCWid{w_ymmq4L-EHAdj0DCR6ImmwQpR##zI~BYmr^S8;tnrk; zN@(QB&6YQrrvOtH$(uHFa7}5Hzjo~pB&J*BE!6@?Y^j`g;5to_E9a;F3d|0a?@Y1M z<(XQSP4q~kyVgCWf&JX3^`8BN9=N6TKl2mkfK?l?cP95=*2ct9p;-g8iQBxX1%Wkp^)Vah(0qy;Cadmb{TXkj?8IN?* zt(i|EvwqTT9mi6P_s|tLRWd_Cclg>xe(g5vp2zcjW3gV`&jdbg&^z_x#2iuQz-c=D zfJ(lPIjZ-RRn9wUwhxWlrrqZsh;rkZ4ia$RYP|J~_#(^r%k4jSF5Y@9DwGIL&k`Kd~2Qc8#f{k{8sS zTmpr1sm(<$?yofU%iZ&2hb?NTRjKf>nT9_SgoQC_-;UgFYj^!^i*4p<-;n zl@c6sNUzd{u47)ryY_T6K2FT3ybp`2)jRH~Zdm&-u>& z_SxTeSyv_&uNRAZ+hq*^AK=YAqA#(S=ttZ^97=2?4kKP64k!Lb^as3OCI%2W7lFjL ziEk0piJ3ri5g;rFwp}2uA$9`dIv`^opgISfz6Gdz!;a?JT{jAGFp&Y8tAVT%;s{_t z4)FCGP!?SSMx{X9nh!*lL#$_j%uI+U8-P1Hh%Ezvm{f>uA8|ayg==oQ@JNYGJyiPMyM zIvz#LC(0Fv&j8_>%Cd(`fuM^nyf9ID=2m1xDq!wWvF2+& zM~xBxT1XF#>+Qmpo#L*(j2o^J+e#QGcC`4gopA#jC8>Z3Px*)Bx#=2U_bHNmULupu z4U)e{9Z)qu3a%-k$*QEc!-;ifDMq+M_dk{5&<#jUkY)xR25d_uYduYvbV8ahIcVYz zX<QTCDX0NBa85R`vyp zboIpuAiJ-0yOMGLbV7Q1?H4NarE2htH1o_f)thVMSpS_S>@4y_2C94is`Dn_3h|AZfVT zXZ|j_exJHa$;c7vNvi8S!mH|Of!VC8i|S>L{!H|idbzKi3y;UEKlJ7XzEjm}7W{#A zdP?0TU0S_*Lr(^(Sgfu(m;)5_P;a|L0%xD89hoE=Tchq$B<;5P@_Kq<&!5%z%ZE|P zc8%wUxh%syn%7T|P_Dnm`}9yYvO$`_Fq-@RO-=X*QS7LFH8box-PpmJG#Mh@om#J% z>rUxHmuRd$4}jp&n*56b31~Hox*36;ZJL!kyR#1r*OZm_W8d)9to!3`U{<+i|K?(v z@v-K}FsCx#Xih9ULPgp%r;Z;5N(XA5R9^!&mdo<7$-tP;WbLU!cG&f@-6Mw+L%xu^ zu=K3lfB8&cakTvU$d7^d{N%UOSYDZsr)~*l=Q7C&@qE61T2A<&5(?p@oa#ts=lof= z#yHo>vNg4xXFO5PowJdORmtzBx3J~TlZ&ilSY_wrq7`ghV@AsFd-q{^->}Oo>jk#h z)$-b^b2NogF3tHKn7mIue<2L`{IUGqm^!-sC#_czy>hmv);GHun3JRpo$@1Heoz~E z_z?R-U+uWf(JZTAZL*0<#jVz6tO^CvdT1BC%LGeJ+8rX}JRYw-JAv!{sZ~d<_b${endKzpqx&$3M-sF}S8=8mSd^`+Zao1+ z|EhbC#`kB7^x|hs#4kke(NoXQw7(0-Ez%on`93*7Kd_7F5Bk80LMHT@KB$)u>)&qG z+g32}xmNvR3kiJnqrS9}1j4rJ%Tj&@rti}qclP}DVfx319hA7(O{k$qVqb96-wb87 zM7vo6?{WN!o0Wj_61Ut=Dv+;tTRr$=_K&S@_49&(B?sO1hSHonMYo1yd@iuL-FxNl ztp6>?42ITbAScxDR(m&oy?!;s-uww@Yciy?@Z*#6*f7t=_xaZii#*o=@hc6h#$N`u zziK#qk3@VP87|xC&E3N~nkK&G9?)?IcwlwU zLKe+k<-TF~WM(?)4fj+2Ls<@c-7l18u$S*}zgNo*j&HU=A->~yO|IypG^{A`S@($} zdSIPW;pccZ=$hcj8FGE4y;QbNq<;g?Fhc - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2009-2022 Robert Lipe</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GUI designed and contributed by S. Khai Mong</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">LGPL Crystal Icons by Elvarado Coehlo</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> +<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> @@ -712,17 +735,17 @@ Higher number provides more detailed diagnostics. по умолчанию - + Select one or more input files Выберите один или несколько файлов - + Output File Name Имя выходного файла - + Error reading format configuration. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. @@ -731,7 +754,7 @@ This program cannot continue. Выполнение программы не может быть продолжено. - + Some file/device formats were not found during initialization. Check that the backend program "gpsbabel" is properly installed and is in the current PATH This program cannot continue. @@ -740,7 +763,7 @@ This program cannot continue. Выполнение программы не может быть продолжено. - + Input and output formats do not support %1 Входной и выходной форматы не поддерживают %1 @@ -753,68 +776,68 @@ This program cannot continue. Входной формат поддерживает %1; выходной формат не поддерживаетt %2 - + Input does not support %1; output format supports %1 Входной формат не поддерживает %1; выходной формат поддерживает %1 - + Input format supports %1; output format does not support %1 Входной формат поддерживает %1; выходной формат не поддерживаетt %1 - + Both input and output formats support %1 Входной и выходной формат поддерживают %1 - + waypoints маршрутные точки - + tracks треки - + routes маршруты - + There are no input options for format "%1" Нет входных параметров для формата "%1" - - + + Options for %1 Параметры %1 - + There are no output options for format "%1" Нет выходных параметров для формата "%1" - + No valid waypoints/routes/tracks translation specified Не выбрано преобразование маршрутных точек/маршрутов/треков - + No input file specified Не выбран входной файл - + No valid output specified Не выбран выходной файл - + No output file specified Не выбран выходной файл @@ -827,33 +850,33 @@ This program cannot continue. Процесс завершился неудачей с кодом %1 - + Translation successful Конвертация выполнена - + Error running gpsbabel: %1 Ошибка запуска gpsbabel: %1 - + Are you sure you want to reset all format options to default values? Вы действительно желаете сбросить все параметры формата в значения по умолчанию? - + About %1 О %1 - + One or more data filters are active Один или более фильтров данных активны - + No data filters are active Фильтры данных не активны @@ -861,17 +884,17 @@ This program cannot continue. Map - + Error opening "gmapbase.html" file. Check installation Ошибка открытия файла "gmapbase.html". Попробуйте переустановить программу - + Missing "gmapbase.html" file. Check installation Отсутствует файл "gmapbase.html". Попробуйте переустановить программу - + Failed to load Google maps base page Не удалось загрузить базовую страницу Google Maps @@ -895,28 +918,28 @@ This program cannot continue. - - - - + + + + Routes Маршруты - - - - + + + + Tracks Треки - - - - + + + + Waypoints Маршрутные точки @@ -1127,7 +1150,7 @@ Some GPS data formats support only some subset of waypoints, tracks, and routes. QObject - + Error processing formats from running process "gpsbabel -^3" at line %1 Ошибка обработки форматов при запуске процесса "gpsbabel -^3" в строке %1 @@ -1338,7 +1361,7 @@ This option changes the time of all trackpoints. This might be useful if your tr - + days дней @@ -1349,7 +1372,7 @@ This option changes the time of all trackpoints. This might be useful if your tr - + mins мин @@ -1379,28 +1402,26 @@ This option is used along with the stop to discard trackpoints that were recorde Начало - If checked, time specified here is based on this computer's current time zone. - Если включено, то время, указанное здесь, соответствует времени, указанному на компьютере. + Если включено, то время, указанное здесь, соответствует времени, указанному на компьютере. - If checked, the times specified here are based on the local computer's time zone. Otherwise it is UTC. - Если включено, то время, указанное здесь, соответствует времени, указанному на компьютере. Иначе - UTC. + Если включено, то время, указанное здесь, соответствует времени, указанному на компьютере. Иначе - UTC. - + Local Time Местное время - - + + Use track pts before this time. Использовать точки трека до этого времени. - + Use only track points before this timestamp. This option is used in conjunction with the start option to discard all trackpoints outside of a given period of time. This option defines the end of the time period. @@ -1409,17 +1430,17 @@ This option is used in conjunction with the start option to discard all trackpoi Этот параметр используется вместе со временем начала, чтобы удалить точки трека полученные вне заданного временного диапазона. Этот параметр задает конец диапазона. - + Stop Конец - + Pack all tracks into one. Упаковать все треки в один. - + Pack all tracks into one. This option causes all tracks to be appended to one another to form a single track. This option does not work if any two tracks overlap in time; in that case, consider using the merge option. @@ -1432,17 +1453,17 @@ This option is most useful for rejoining tracks that might have been interrupted Полезен для объединения треков, которые могли быть разорваны из-за перебоев в работе прибора или остановки на ночь. - + Pack Упаковать - + Merge multiple tracks for the same way. Склеить несколько треков для того же пути. - + Merge multiple tracks for the same way. This option puts all track points from all tracks into a single track and sorts them by time stamp. Points with identical time stamps will be dropped. @@ -1451,97 +1472,97 @@ This option puts all track points from all tracks into a single track and sorts Этот параметр складывает все точки трека из всех треков в единый трек и сортирует их по временным меткам. Точки с одинаковыми метками - удаляются. - + Merge Склеить - + Split by Date Разбить по дате - + Split by Time Разбить по времени - + If nonzero, the track will be split if the time between two points is greater than this parameter. If zero, the track will be split by date. Если не 0, трек будет разбит если время между двумя точками больше, чем это значение. Если ноль, трек будет разбит по дате. - + hrs ч - + Split by Dist. Разбить по расстоянию - + If nonzero, the input track will be split into several tracks if the distance between successive track points is greater than the distance given as a parameter. Если не 0, исходный трек будет разбит на несколько треков если расстояние между последовательными точками больше, чем заданное. - + ft футов - + m м - + km км - + mi миль - + GPS Fixes GPS поправки - + none нет - + pps - + dgps - + 3d - + 2d - + Synthesize speed. Синтезировать скорость. - + Synthesize speed. This option computes a value for the GPS speed at each trackpoint. This is most useful with trackpoints from formats that don't support speed information or for trackpoints synthesized by the interpolate filter. The speed at each trackpoint is the average speed from the previous trackpoint (distance divided by time). The first trackpoint in each track is assigned a speed of "unknown." @@ -1550,17 +1571,17 @@ This option computes a value for the GPS speed at each trackpoint. This is most Эта опция позволяет вычислить значение скорости в каждой точке трека. Это может понадобится для форматов, не поддерживающих скорость, или для точек, синтезированных фильтром интерполяции. Скорость в каждой точке является средней скоростью от предыдущей точки трека (расстояние, деленное на время). Первая точка каждого трека получает значение "unknown." - + Speed Скорость - + Synthesize course. Синтезировать курс. - + Synthesize course. This option computes (or recomputes) a value for the GPS heading at each trackpoint. This is most useful with trackpoints from formats that don't support heading information or for trackpoints synthesized by the interpolate filter. The heading at each trackpoint is simply the course from the previous trackpoint in the track. The first trackpoint in each track is arbitrarily assigned a heading of 0 degrees. @@ -1569,10 +1590,27 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo Эта опция позволяет вычислить (или пересчитать) значение для курса GPS в каждой точке трека. Это может понадобится для форматов, не поддерживающих азимут или для точек, синтезированных фильтром интерполяции. Азимут в каждой точке является простым углом от предыдущей точки трека. Первая точка каждого трека получает значение 0 градусов. - + Course Курс + + + + If checked, times specified here are based on this computer's current time zone. + + + + + + If checked, times specified here are UTC. + + + + + UTC + + Upgrade @@ -1585,49 +1623,49 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo UpgradeCheck - - - + + + HTTP - + Unexpected reply. Неожиданный ответ. - + Download failed: %1. Загрузка завершилась неудачей: %1. - + Download failed: %1: %2. Загрузка завершилась неудачей: %1: %2. - + Error Ошибка - + Invalid return data at line %1: %2. Некорректные данные возвращены в строке %1: %2. - + A new version of GPSBabel is available.<br />Your version is %1 <br />The latest version is %2 Доступна новая версия GPSBabel.<br />Используемая версия %1 <br />Последняя доступная версия %2 - + Upgrade Обновить - + Do you wish to download an upgrade? Загрузить обновление? diff --git a/reference/help.txt b/reference/help.txt index 4aeb2c4e6..62f9fcc43 100644 --- a/reference/help.txt +++ b/reference/help.txt @@ -1,4 +1,4 @@ -GPSBabel Version 1.8.0. https://www.gpsbabel.org +GPSBabel Version 1.9.0. https://www.gpsbabel.org Usage: ./gpsbabel [options] -i INTYPE -f INFILE [filter] -o OUTTYPE -F OUTFILE diff --git a/reference/usage.txt b/reference/usage.txt index c009447fb..86feadd62 100644 --- a/reference/usage.txt +++ b/reference/usage.txt @@ -1,4 +1,4 @@ -GPSBabel Version 1.8.0. https://www.gpsbabel.org +GPSBabel Version 1.9.0. https://www.gpsbabel.org Usage: ./gpsbabel [options] -i INTYPE -f INFILE [filter] -o OUTTYPE -F OUTFILE From 1aa1554c03158d42346ae7adf600ede41a382a4f Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:57:37 -0600 Subject: [PATCH 021/132] enhance gpx test to validate gpx writer. (#1191) * enhance gpx test to validate gpx writer. this reveals our writer producing a schema violation, an exception is made to avoid testing with this input. The exception should be removed when we fix the gpx writer. * fix write order of gpx elements we just pass through. * collapse writing of waypoint elements common to wpts, rtepts, trkpts. * fiddle * more fiddling --- formspec.h | 1 + gpx.cc | 119 ++- gpx.h | 42 +- reference/basecamp~gpx.gpx | 2 + reference/wptsequence.gpx | 76 ++ testo.d/gpx.test | 42 + testo.d/kml.test | 2 +- tools/schema/gpx/fetch | 14 + tools/schema/gpx/garmin/GpxExtensionsv3.xsd | 215 +++++ tools/schema/gpx/garmin/GpxExtensionsv3.xsd.1 | 215 +++++ .../gpx/garmin/TrackPointExtensionv1.xsd | 74 ++ .../gpx/garmin/TrackPointExtensionv1.xsd.1 | 74 ++ .../gpx/garmin/TrackPointExtensionv2.xsd | 94 +++ .../gpx/garmin/TrackPointExtensionv2.xsd.1 | 94 +++ tools/schema/gpx/garmin/TripExtensionsv1.xsd | 136 +++ .../schema/gpx/garmin/TripExtensionsv1.xsd.1 | 136 +++ tools/schema/gpx/groundspeak/cache10.xsd | 127 +++ tools/schema/gpx/groundspeak/cache101.xsd | 128 +++ tools/schema/gpx/groundspeak/cache11.xsd | 152 ++++ tools/schema/gpx/groundspeak/cache12.xsd | 94 +++ tools/schema/gpx/master.xsd | 15 + tools/schema/gpx/topografix/gpx10.xsd | 231 +++++ tools/schema/gpx/topografix/gpx11.xsd | 788 ++++++++++++++++++ .../kml}/atom-author-link.xsd | 0 .../{kml22-schema => schema/kml}/kml22gx.xsd | 0 .../{kml22-schema => schema/kml}/ogckml22.xsd | 0 tools/{kml22-schema => schema/kml}/xAL.xsd | 0 27 files changed, 2829 insertions(+), 42 deletions(-) create mode 100644 reference/wptsequence.gpx create mode 100755 tools/schema/gpx/fetch create mode 100644 tools/schema/gpx/garmin/GpxExtensionsv3.xsd create mode 100644 tools/schema/gpx/garmin/GpxExtensionsv3.xsd.1 create mode 100644 tools/schema/gpx/garmin/TrackPointExtensionv1.xsd create mode 100644 tools/schema/gpx/garmin/TrackPointExtensionv1.xsd.1 create mode 100644 tools/schema/gpx/garmin/TrackPointExtensionv2.xsd create mode 100644 tools/schema/gpx/garmin/TrackPointExtensionv2.xsd.1 create mode 100644 tools/schema/gpx/garmin/TripExtensionsv1.xsd create mode 100644 tools/schema/gpx/garmin/TripExtensionsv1.xsd.1 create mode 100644 tools/schema/gpx/groundspeak/cache10.xsd create mode 100644 tools/schema/gpx/groundspeak/cache101.xsd create mode 100644 tools/schema/gpx/groundspeak/cache11.xsd create mode 100644 tools/schema/gpx/groundspeak/cache12.xsd create mode 100644 tools/schema/gpx/master.xsd create mode 100644 tools/schema/gpx/topografix/gpx10.xsd create mode 100644 tools/schema/gpx/topografix/gpx11.xsd rename tools/{kml22-schema => schema/kml}/atom-author-link.xsd (100%) rename tools/{kml22-schema => schema/kml}/kml22gx.xsd (100%) rename tools/{kml22-schema => schema/kml}/ogckml22.xsd (100%) rename tools/{kml22-schema => schema/kml}/xAL.xsd (100%) diff --git a/formspec.h b/formspec.h index 942e596aa..44261561c 100644 --- a/formspec.h +++ b/formspec.h @@ -26,6 +26,7 @@ enum FsType { kFsUnknown = 0L, kFsGpx = 0x67707800L, + kFsGpxWpt = 0x67707877L, kFsOzi = 0x6f7a6900L, kFsGmsd = 0x474d5344L, /* GMSD = Garmin specific data */ kFsQstarzBl1000 = 0x5173747aL, diff --git a/gpx.cc b/gpx.cc index 9b8c8738f..1439a5f0c 100644 --- a/gpx.cc +++ b/gpx.cc @@ -514,6 +514,10 @@ GpxFormat::gpx_end(QStringView /*unused*/) delete link_; link_ = nullptr; } + if (wpt_fsdata != nullptr) { + wpt_tmp->fs.FsChainAdd(wpt_fsdata); + wpt_fsdata = nullptr; + } waypt_add(wpt_tmp); logpoint_ct = 0; cur_tag = nullptr; @@ -621,6 +625,10 @@ GpxFormat::gpx_end(QStringView /*unused*/) delete link_; link_ = nullptr; } + if (wpt_fsdata != nullptr) { + wpt_tmp->fs.FsChainAdd(wpt_fsdata); + wpt_fsdata = nullptr; + } route_add_wpt(rte_head, wpt_tmp); wpt_tmp = nullptr; break; @@ -665,6 +673,10 @@ GpxFormat::gpx_end(QStringView /*unused*/) delete link_; link_ = nullptr; } + if (wpt_fsdata != nullptr) { + wpt_tmp->fs.FsChainAdd(wpt_fsdata); + wpt_fsdata = nullptr; + } track_add_wpt(trk_head, wpt_tmp); wpt_tmp = nullptr; break; @@ -727,6 +739,12 @@ GpxFormat::gpx_end(QStringView /*unused*/) case tt_wpttype_time: wpt_tmp->SetCreationTime(xml_parse_time(cdatastr)); break; + case tt_wpttype_magvar: + if (wpt_fsdata == nullptr) { + wpt_fsdata = new gpx_wpt_fsdata; + } + wpt_fsdata->magvar = cdatastr; + break; case tt_wpttype_geoidheight: wpt_tmp->set_geoidheight(cdatastr.toDouble()); break; @@ -736,6 +754,18 @@ GpxFormat::gpx_end(QStringView /*unused*/) case tt_wpttype_desc: wpt_tmp->notes = cdatastr; break; + case tt_wpttype_src: + if (wpt_fsdata == nullptr) { + wpt_fsdata = new gpx_wpt_fsdata; + } + wpt_fsdata->src = cdatastr; + break; + case tt_wpttype_type: + if (wpt_fsdata == nullptr) { + wpt_fsdata = new gpx_wpt_fsdata; + } + wpt_fsdata->type = cdatastr; + break; case tt_wpttype_pdop: wpt_tmp->pdop = cdatastr.toFloat(); break; @@ -745,6 +775,18 @@ GpxFormat::gpx_end(QStringView /*unused*/) case tt_wpttype_vdop: wpt_tmp->vdop = cdatastr.toFloat(); break; + case tt_wpttype_ageofdgpsdata: + if (wpt_fsdata == nullptr) { + wpt_fsdata = new gpx_wpt_fsdata; + } + wpt_fsdata->ageofdgpsdata = cdatastr; + break; + case tt_wpttype_dgpsid: + if (wpt_fsdata == nullptr) { + wpt_fsdata = new gpx_wpt_fsdata; + } + wpt_fsdata->dgpsid = cdatastr; + break; case tt_wpttype_sat: wpt_tmp->sat = cdatastr.toInt(); break; @@ -1065,7 +1107,7 @@ GpxFormat::write_attributes(const QXmlStreamAttributes& attributes) const } void -GpxFormat::fprint_xml_chain(XmlTag* tag, const Waypoint* wpt) const +GpxFormat::fprint_xml_chain(XmlTag* tag) const { while (tag) { writer->writeStartElement(tag->tagname); @@ -1078,7 +1120,7 @@ GpxFormat::fprint_xml_chain(XmlTag* tag, const Waypoint* wpt) const writer->writeCharacters(tag->cdata); } if (tag->child) { - fprint_xml_chain(tag->child, wpt); + fprint_xml_chain(tag->child); } writer->writeEndElement(); } @@ -1138,7 +1180,7 @@ GpxFormat::write_gpx_url(const route_head* rh) const * Order counts. */ void -GpxFormat::gpx_write_common_acc(const Waypoint* waypointp) const +GpxFormat::gpx_write_common_acc(const Waypoint* waypointp, const gpx_wpt_fsdata* fs_gpxwpt) const { const char* fix = nullptr; @@ -1179,13 +1221,15 @@ GpxFormat::gpx_write_common_acc(const Waypoint* waypointp) const if (waypointp->pdop) { writer->writeTextElement(QStringLiteral("pdop"), toString(waypointp->pdop)); } - /* TODO: ageofdgpsdata should go here */ - /* TODO: dgpsid should go here */ + if (fs_gpxwpt) { + writer->writeOptionalTextElement(QStringLiteral("ageofdgpsdata"), fs_gpxwpt->ageofdgpsdata); + writer->writeOptionalTextElement(QStringLiteral("dgpsid"), fs_gpxwpt->dgpsid); + } } void -GpxFormat::gpx_write_common_position(const Waypoint* waypointp, const gpx_point_type point_type) const +GpxFormat::gpx_write_common_position(const Waypoint* waypointp, const gpx_point_type point_type, const gpx_wpt_fsdata* fs_gpxwpt) const { if (waypointp->altitude != unknown_alt) { writer->writeTextElement(QStringLiteral("ele"), QString::number(waypointp->altitude, 'f', elevation_precision)); @@ -1201,7 +1245,9 @@ GpxFormat::gpx_write_common_position(const Waypoint* waypointp, const gpx_point_ writer->writeTextElement(QStringLiteral("speed"), toString(waypointp->speed_value())); } } - /* TODO: magvar should go here */ + if (fs_gpxwpt) { + writer->writeOptionalTextElement(QStringLiteral("magvar"), fs_gpxwpt->magvar); + } if (waypointp->geoidheight_has_value()) { writer->writeOptionalTextElement(QStringLiteral("geoidheight"),QString::number(waypointp->geoidheight_value(), 'f', 1)); } @@ -1294,8 +1340,13 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin } void -GpxFormat::gpx_write_common_description(const Waypoint* waypointp, const QString& oname) const +GpxFormat::gpx_write_common_description(const Waypoint* waypointp, const gpx_point_type point_type, const gpx_wpt_fsdata* fs_gpxwpt) const { + QString oname; + if (!((point_type == gpxpt_track) && waypointp->wpt_flags.shortname_is_synthetic)) { + oname = global_opts.synthesize_shortnames ? + mkshort_handle->mkshort_from_wpt(waypointp) : waypointp->shortname; + } writer->writeOptionalTextElement(QStringLiteral("name"), oname); writer->writeOptionalTextElement(QStringLiteral("cmt"), waypointp->description); @@ -1304,10 +1355,24 @@ GpxFormat::gpx_write_common_description(const Waypoint* waypointp, const QString } else { writer->writeOptionalTextElement(QStringLiteral("desc"), waypointp->description); } - /* TODO: src should go here */ + if (fs_gpxwpt) { + writer->writeOptionalTextElement(QStringLiteral("src"), fs_gpxwpt->src); + } write_gpx_url(waypointp); writer->writeOptionalTextElement(QStringLiteral("sym"), waypointp->icon_descr); - /* TODO: type should go here */ + if (fs_gpxwpt) { + writer->writeOptionalTextElement(QStringLiteral("type"), fs_gpxwpt->type); + } +} + +void GpxFormat::gpx_write_common_core(const Waypoint* waypointp, + const gpx_point_type point_type) const +{ + const auto* fs_gpxwpt = reinterpret_cast(waypointp->fs.FsChainFind(kFsGpxWpt)); + + gpx_write_common_position(waypointp, point_type, fs_gpxwpt); + gpx_write_common_description(waypointp, point_type, fs_gpxwpt); + gpx_write_common_acc(waypointp, fs_gpxwpt); } void @@ -1317,19 +1382,14 @@ GpxFormat::gpx_waypt_pr(const Waypoint* waypointp) const writer->writeAttribute(QStringLiteral("lat"), toString(waypointp->latitude)); writer->writeAttribute(QStringLiteral("lon"), toString(waypointp->longitude)); - QString oname = global_opts.synthesize_shortnames ? - mkshort_handle->mkshort_from_wpt(waypointp) : - waypointp->shortname; - gpx_write_common_position(waypointp, gpxpt_waypoint); - gpx_write_common_description(waypointp, oname); - gpx_write_common_acc(waypointp); + gpx_write_common_core(waypointp, gpxpt_waypoint); if (!(opt_humminbirdext || opt_garminext)) { const auto* fs_gpx = reinterpret_cast(waypointp->fs.FsChainFind(kFsGpx)); auto* gmsd = garmin_fs_t::find(waypointp); /* gARmIN sPECIAL dATA */ if (fs_gpx) { if (! gmsd) { - fprint_xml_chain(fs_gpx->tag, waypointp); + fprint_xml_chain(fs_gpx->tag); } } if (gmsd && (gpx_write_version > gpx_1_0)) { @@ -1360,7 +1420,7 @@ GpxFormat::gpx_track_hdr(const route_head* rte) if (!(opt_humminbirdext || opt_garminext)) { const auto* fs_gpx = reinterpret_cast(rte->fs.FsChainFind(kFsGpx)); if (fs_gpx) { - fprint_xml_chain(fs_gpx->tag, nullptr); + fprint_xml_chain(fs_gpx->tag); } } else if (opt_garminext) { if (rte->line_color.bbggrr > unknown_color) { @@ -1394,20 +1454,12 @@ GpxFormat::gpx_track_disp(const Waypoint* waypointp) const writer->writeAttribute(QStringLiteral("lat"), toString(waypointp->latitude)); writer->writeAttribute(QStringLiteral("lon"), toString(waypointp->longitude)); - gpx_write_common_position(waypointp, gpxpt_track); - - QString oname = global_opts.synthesize_shortnames ? - mkshort_handle->mkshort_from_wpt(waypointp) : - waypointp->shortname; - gpx_write_common_description(waypointp, - waypointp->wpt_flags.shortname_is_synthetic ? - nullptr : oname); - gpx_write_common_acc(waypointp); + gpx_write_common_core(waypointp, gpxpt_track); if (!(opt_humminbirdext || opt_garminext)) { const auto* fs_gpx = reinterpret_cast(waypointp->fs.FsChainFind(kFsGpx)); if (fs_gpx) { - fprint_xml_chain(fs_gpx->tag, waypointp); + fprint_xml_chain(fs_gpx->tag); } } else { gpx_write_common_extensions(waypointp, gpxpt_track); @@ -1458,7 +1510,7 @@ GpxFormat::gpx_route_hdr(const route_head* rte) const if (!(opt_humminbirdext || opt_garminext)) { const auto* fs_gpx = reinterpret_cast(rte->fs.FsChainFind(kFsGpx)); if (fs_gpx) { - fprint_xml_chain(fs_gpx->tag, nullptr); + fprint_xml_chain(fs_gpx->tag); } } else if (opt_garminext) { if (rte->line_color.bbggrr > unknown_color) { @@ -1485,17 +1537,12 @@ GpxFormat::gpx_route_disp(const Waypoint* waypointp) const writer->writeAttribute(QStringLiteral("lat"), toString(waypointp->latitude)); writer->writeAttribute(QStringLiteral("lon"), toString(waypointp->longitude)); - QString oname = global_opts.synthesize_shortnames ? - mkshort_handle->mkshort_from_wpt(waypointp) : - waypointp->shortname; - gpx_write_common_position(waypointp, gpxpt_route); - gpx_write_common_description(waypointp, oname); - gpx_write_common_acc(waypointp); + gpx_write_common_core(waypointp, gpxpt_route); if (!(opt_humminbirdext || opt_garminext)) { const auto* fs_gpx = reinterpret_cast(waypointp->fs.FsChainFind(kFsGpx)); if (fs_gpx) { - fprint_xml_chain(fs_gpx->tag, waypointp); + fprint_xml_chain(fs_gpx->tag); } } else { gpx_write_common_extensions(waypointp, gpxpt_route); diff --git a/gpx.h b/gpx.h index 1fd5b9692..0d56a9f87 100644 --- a/gpx.h +++ b/gpx.h @@ -67,6 +67,28 @@ class GpxFormat : public Format void exit() override; private: + /* + * This structure holds the element contents of elements in the + * the gpx namespace that are only passed from the gpx reader to + * the gpx writer. + * We explcitly write these instead of passing them through so they + * are written in the correct sequence. + */ + struct gpx_wpt_fsdata : FormatSpecificData { + gpx_wpt_fsdata() : FormatSpecificData(kFsGpxWpt) {} + + gpx_wpt_fsdata* clone() const override + { + return new gpx_wpt_fsdata(*this); + } + + QString magvar; + QString src; + QString type; + QString ageofdgpsdata; + QString dgpsid; + }; + enum gpx_point_type { gpxpt_waypoint, gpxpt_track, @@ -91,10 +113,12 @@ class GpxFormat : public Format tt_wpt, tt_wpttype_ele, tt_wpttype_time, + tt_wpttype_magvar, tt_wpttype_geoidheight, tt_wpttype_name, tt_wpttype_cmt, tt_wpttype_desc, + tt_wpttype_src, tt_wpttype_url, /* Not in GPX 1.1 */ tt_wpttype_urlname, /* Not in GPX 1.1 */ tt_wpttype_link, /* New in GPX 1.1 */ @@ -107,6 +131,8 @@ class GpxFormat : public Format tt_wpttype_hdop, /* HDOPS are common for all three */ tt_wpttype_vdop, /* VDOPS are common for all three */ tt_wpttype_pdop, /* PDOPS are common for all three */ + tt_wpttype_ageofdgpsdata, + tt_wpttype_dgpsid, tt_cache, tt_cache_name, tt_cache_container, @@ -197,15 +223,16 @@ class GpxFormat : public Format void gpx_cdata(QStringView s); QString qualifiedName() const; void write_attributes(const QXmlStreamAttributes& attributes) const; - void fprint_xml_chain(XmlTag* tag, const Waypoint* wpt) const; + void fprint_xml_chain(XmlTag* tag) const; void write_gpx_url(const UrlList& urls) const; void write_gpx_url(const Waypoint* waypointp) const; void write_gpx_url(const route_head* rh) const; - void gpx_write_common_acc(const Waypoint* waypointp) const; - void gpx_write_common_position(const Waypoint* waypointp, gpx_point_type point_type) const; + void gpx_write_common_acc(const Waypoint* waypointp, const gpx_wpt_fsdata* fs_gpxwpt) const; + void gpx_write_common_position(const Waypoint* waypointp, gpx_point_type point_type, const gpx_wpt_fsdata* fs_gpxwpt) const; void gpx_write_common_extensions(const Waypoint* waypointp, gpx_point_type point_type) const; - void gpx_write_common_description(const Waypoint* waypointp, const QString& oname) const; + void gpx_write_common_description(const Waypoint* waypointp, gpx_point_type point_type, const gpx_wpt_fsdata* fs_gpxwpt) const; void gpx_waypt_pr(const Waypoint* waypointp) const; + void gpx_write_common_core(const Waypoint* waypointp, gpx_point_type point_type) const; void gpx_track_hdr(const route_head* rte); void gpx_track_disp(const Waypoint* waypointp) const; void gpx_track_tlr(const route_head* unused); @@ -261,6 +288,7 @@ class GpxFormat : public Format int next_trkpt_is_new_seg{}; FormatSpecificDataList* fs_ptr{}; + gpx_wpt_fsdata* wpt_fsdata{nullptr}; /* * The file-level information. @@ -409,22 +437,26 @@ class GpxFormat : public Format /* Common to tracks, routes, and waypts */ GPXWPTTYPETAG("ele", tt_wpttype_ele, false), GPXWPTTYPETAG("time", tt_wpttype_time, false), + GPXWPTTYPETAG("magvar", tt_wpttype_magvar, false), GPXWPTTYPETAG("geoidheight", tt_wpttype_geoidheight, false), GPXWPTTYPETAG("name", tt_wpttype_name, false), GPXWPTTYPETAG("cmt", tt_wpttype_cmt, false), GPXWPTTYPETAG("desc", tt_wpttype_desc, false), + GPXWPTTYPETAG("src", tt_wpttype_src, false), GPXWPTTYPETAG("url", tt_wpttype_url, false), /* GPX 1.0 */ GPXWPTTYPETAG("urlname", tt_wpttype_urlname, false), /* GPX 1.0 */ GPXWPTTYPETAG("link", tt_wpttype_link, false), /* GPX 1.1 */ GPXWPTTYPETAG("link/text", tt_wpttype_link_text, false), /* GPX 1.1 */ GPXWPTTYPETAG("link/type", tt_wpttype_link_type, false), /* GPX 1.1 */ GPXWPTTYPETAG("sym", tt_wpttype_sym, false), - GPXWPTTYPETAG("type", tt_wpttype_type, true), + GPXWPTTYPETAG("type", tt_wpttype_type, false), GPXWPTTYPETAG("fix", tt_wpttype_fix, false), GPXWPTTYPETAG("sat", tt_wpttype_sat, false), GPXWPTTYPETAG("hdop", tt_wpttype_hdop, false), GPXWPTTYPETAG("vdop", tt_wpttype_vdop, false), GPXWPTTYPETAG("pdop", tt_wpttype_pdop, false), + GPXWPTTYPETAG("ageofdgpsdata", tt_wpttype_ageofdgpsdata, false), + GPXWPTTYPETAG("dgpsid", tt_wpttype_dgpsid, false), }; QVector gpx_args = { diff --git a/reference/basecamp~gpx.gpx b/reference/basecamp~gpx.gpx index 77234b87f..fe07c4a21 100644 --- a/reference/basecamp~gpx.gpx +++ b/reference/basecamp~gpx.gpx @@ -13,6 +13,7 @@ Hwy 119 Hwy 119 Flag, Blue + user SymbolAndName @@ -25,6 +26,7 @@ Hwy 72 Hwy 72 Flag, Blue + user SymbolAndName diff --git a/reference/wptsequence.gpx b/reference/wptsequence.gpx new file mode 100644 index 000000000..881f958e7 --- /dev/null +++ b/reference/wptsequence.gpx @@ -0,0 +1,76 @@ + + + + + + 289.200 + + 33.333 + 111.1 + trkpt-2011-07-02T17:47:25.000Z + this is the wpt cmt + this is the wpt desc + this is the wpt src + http://www.gpsbabel.org + gpsbabel.org + Campground + T + 3d + 4 + 1.100000 + 2.200000 + 3.300000 + 4.4 + 55 + + + + 289.200 + + 33.333 + 111.1 + trkpt-2011-07-02T17:47:25.000Z + this is the rte cmt + this is the rte desc + this is the rte src + http://www.gpsbabel.org + gpsbabel.org + Campground + T + 3d + 4 + 1.100000 + 2.200000 + 3.300000 + 4.4 + 55 + + + + + + 289.200 + + 12.120000 + 13.818100 + 33.333 + 111.1 + trkpt-2011-07-02T17:47:25.000Z + this is the trk cmt + this is the trk desc + this is the trk src + http://www.gpsbabel.org + gpsbabel.org + Campground + T + 3d + 4 + 1.100000 + 2.200000 + 3.300000 + 4.4 + 55 + + + + diff --git a/testo.d/gpx.test b/testo.d/gpx.test index 80a356086..f37fcf267 100644 --- a/testo.d/gpx.test +++ b/testo.d/gpx.test @@ -61,3 +61,45 @@ compare ${REFERENCE}/gdb-sample-v3-ilinks.gpx ${TMPDIR}/gdb-sample-v3-ilinks.gpx # use declared namespace prefixes in gpx reader gpsbabel -t -i gpx -f ${REFERENCE}/track/garminconnect.gpx -o unicsv,utc=0 -F ${TMPDIR}/garminconnect.csv compare ${REFERENCE}/track/garminconnect.csv ${TMPDIR}/garminconnect.csv + +# order of wpt type elements +gpsbabel -i gpx -f ${REFERENCE}/wptsequence.gpx -o gpx -F ${TMPDIR}/wptsequence.gpx +compare ${REFERENCE}/wptsequence.gpx ${TMPDIR}/wptsequence.gpx + +if [ -z "${VALGRIND}" ]; then + set -e + if command -v xmllint > /dev/null; + then + GPXS=$(find ${REFERENCE} -name \*.gpx) + mkdir -p ${TMPDIR}/validcheck + for f in $GPXS + do + case $f in + # this isn't a gpx file + ${REFERENCE}/track/trackfilter_discard_err.gpx) + ;; + + *) + tmpf=${TMPDIR}/validcheck/$(basename $f) + gpsbabel -i gpx -f $f -o gpx -F $tmpf + xmllint --schema ${BASEPATH}/tools/schema/gpx/master.xsd --noout $tmpf + ;; + esac; + + case $f in + # this isn't a gpx file + ${REFERENCE}/track/trackfilter_discard_err.gpx) + ;; + + *) + tmpf=${TMPDIR}/validcheck/$(basename $f) + gpsbabel -i gpx -f $f -o gpx,garminextensions -F $tmpf + xmllint --schema ${BASEPATH}/tools/schema/gpx/master.xsd --noout $tmpf + ;; + esac; + done + else + echo "Skipping GPX validation phase." + fi + set +e +fi diff --git a/testo.d/kml.test b/testo.d/kml.test index 212e3cbea..f92f3c4d7 100644 --- a/testo.d/kml.test +++ b/testo.d/kml.test @@ -84,7 +84,7 @@ if [ -z "${VALGRIND}" ]; then *) tmpf=${TMPDIR}/validcheck/$(basename $f) gpsbabel -i kml -f $f -o kml -F $tmpf - xmllint --schema ${BASEPATH}/tools/kml22-schema/kml22gx.xsd --noout $tmpf + xmllint --schema ${BASEPATH}/tools/schema/kml/kml22gx.xsd --noout $tmpf esac; done else diff --git a/tools/schema/gpx/fetch b/tools/schema/gpx/fetch new file mode 100755 index 000000000..6c6703d7c --- /dev/null +++ b/tools/schema/gpx/fetch @@ -0,0 +1,14 @@ +#!/bin/bash + +wget -O topografix/gpx10.xsd "http://www.topografix.com/GPX/1/0/gpx.xsd" +wget -O topografix/gpx11.xsd "http://www.topografix.com/GPX/1/1/gpx.xsd" + +wget -P garmin "https://www8.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd" +wget -P garmin "https://www8.garmin.com/xmlschemas/TrackPointExtensionv1.xsd" +wget -P garmin "https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd" +wget -P garmin "https://www8.garmin.com/xmlschemas/TripExtensionsv1.xsd" + +wget -O groundspeak/cache10.xsd "http://www.groundspeak.com/cache/1/0/cache.xsd" +wget -O groundspeak/cache101.xsd "http://www.groundspeak.com/cache/1/0/1/cache.xsd" +wget -O groundspeak/cache11.xsd "http://www.groundspeak.com/cache/1/1/cache.xsd" +wget -O groundspeak/cache12.xsd "http://www.groundspeak.com/cache/1/2/cache.xsd" diff --git a/tools/schema/gpx/garmin/GpxExtensionsv3.xsd b/tools/schema/gpx/garmin/GpxExtensionsv3.xsd new file mode 100644 index 000000000..04d396491 --- /dev/null +++ b/tools/schema/gpx/garmin/GpxExtensionsv3.xsd @@ -0,0 +1,215 @@ + + + + + This schema defines the Garmin extensions to be used with the GPX 1.1 schema. + The root elements defined by this schema are intended to be used as child + elements of the "extensions" elements in the GPX 1.1 schema. The GPX 1.1 + schema is available at http://www.topografix.com/GPX/1/1/gpx.xsd. + + + + + + + + + + + + + + + This type contains data fields available in Garmin GDB waypoints that cannot + be represented in waypoints in GPX 1.1 instances. + + + + + + + + + + + + + + + + This type contains a list of categories to which a waypoint has been assigned. + Note that this list may contain categories which do not exist for a particular + application installation. + + + + + + + + + + + + + + + + + + + + + + + Category provides the ability to specify the type of a + phone number. For example, a phone number can be categorized as + "Home", "Work", "Mobile" e.t.c + + + + + + + + + This type contains data fields available in Garmin GDB routes that cannot + be represented in routes in GPX 1.1 instances. + + + + + + + + + + + This type contains data fields available in Garmin GDB routes that cannot + be represented in routes in GPX 1.1 instances. + + + + + + + + + + + This type contains data fields available in Garmin GDB tracks that cannot + be represented in routes in GPX 1.1 instances. + + + + + + + + + + This type contains data fields available in Garmin GDB track points that cannot + be represented in track points in GPX 1.1 instances. + + + + + + + + + + + This type contains a temperature value measured in degrees Celsius. + + + + + + + This type contains a distance value measured in meters. + + + + + + + This type contains a string that specifies how a waypoint should be + displayed on a map. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The latitude of the point. Decimal degrees, WGS84 datum. + + + + + + + + + + The longitude of the point. Decimal degrees, WGS84 datum. + + + + + + + + + + This type provides the ability to extend any data type that includes it. + + + + + + + diff --git a/tools/schema/gpx/garmin/GpxExtensionsv3.xsd.1 b/tools/schema/gpx/garmin/GpxExtensionsv3.xsd.1 new file mode 100644 index 000000000..04d396491 --- /dev/null +++ b/tools/schema/gpx/garmin/GpxExtensionsv3.xsd.1 @@ -0,0 +1,215 @@ + + + + + This schema defines the Garmin extensions to be used with the GPX 1.1 schema. + The root elements defined by this schema are intended to be used as child + elements of the "extensions" elements in the GPX 1.1 schema. The GPX 1.1 + schema is available at http://www.topografix.com/GPX/1/1/gpx.xsd. + + + + + + + + + + + + + + + This type contains data fields available in Garmin GDB waypoints that cannot + be represented in waypoints in GPX 1.1 instances. + + + + + + + + + + + + + + + + This type contains a list of categories to which a waypoint has been assigned. + Note that this list may contain categories which do not exist for a particular + application installation. + + + + + + + + + + + + + + + + + + + + + + + Category provides the ability to specify the type of a + phone number. For example, a phone number can be categorized as + "Home", "Work", "Mobile" e.t.c + + + + + + + + + This type contains data fields available in Garmin GDB routes that cannot + be represented in routes in GPX 1.1 instances. + + + + + + + + + + + This type contains data fields available in Garmin GDB routes that cannot + be represented in routes in GPX 1.1 instances. + + + + + + + + + + + This type contains data fields available in Garmin GDB tracks that cannot + be represented in routes in GPX 1.1 instances. + + + + + + + + + + This type contains data fields available in Garmin GDB track points that cannot + be represented in track points in GPX 1.1 instances. + + + + + + + + + + + This type contains a temperature value measured in degrees Celsius. + + + + + + + This type contains a distance value measured in meters. + + + + + + + This type contains a string that specifies how a waypoint should be + displayed on a map. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The latitude of the point. Decimal degrees, WGS84 datum. + + + + + + + + + + The longitude of the point. Decimal degrees, WGS84 datum. + + + + + + + + + + This type provides the ability to extend any data type that includes it. + + + + + + + diff --git a/tools/schema/gpx/garmin/TrackPointExtensionv1.xsd b/tools/schema/gpx/garmin/TrackPointExtensionv1.xsd new file mode 100644 index 000000000..78b8649a6 --- /dev/null +++ b/tools/schema/gpx/garmin/TrackPointExtensionv1.xsd @@ -0,0 +1,74 @@ + + + + + This schema defines Garmin extensions to be used with the GPX 1.1 schema. + The root element defined by this schema is intended to be used as a child + element of the "extensions" elements in the trkpt element in the GPX 1.1 schema. + The GPX 1.1 schema is available at http://www.topografix.com/GPX/1/1/gpx.xsd. + This is a replacement for TrackPointExtension in + http://www.garmin.com/xmlschemas/GpxExtensions/v3 + + + + + + + This type contains data fields that cannot + be represented in track points in GPX 1.1 instances. + + + + + + + + + + + + + + This type contains a temperature value measured in degrees Celsius. + + + + + + + This type contains a distance value measured in meters. + + + + + + + This type contains a heart rate measured in beats per minute. + + + + + + + + + This type contains a cadence measured in revolutions per minute. + + + + + + + + + This type provides the ability to extend any data type that includes it. + + + + + + + diff --git a/tools/schema/gpx/garmin/TrackPointExtensionv1.xsd.1 b/tools/schema/gpx/garmin/TrackPointExtensionv1.xsd.1 new file mode 100644 index 000000000..78b8649a6 --- /dev/null +++ b/tools/schema/gpx/garmin/TrackPointExtensionv1.xsd.1 @@ -0,0 +1,74 @@ + + + + + This schema defines Garmin extensions to be used with the GPX 1.1 schema. + The root element defined by this schema is intended to be used as a child + element of the "extensions" elements in the trkpt element in the GPX 1.1 schema. + The GPX 1.1 schema is available at http://www.topografix.com/GPX/1/1/gpx.xsd. + This is a replacement for TrackPointExtension in + http://www.garmin.com/xmlschemas/GpxExtensions/v3 + + + + + + + This type contains data fields that cannot + be represented in track points in GPX 1.1 instances. + + + + + + + + + + + + + + This type contains a temperature value measured in degrees Celsius. + + + + + + + This type contains a distance value measured in meters. + + + + + + + This type contains a heart rate measured in beats per minute. + + + + + + + + + This type contains a cadence measured in revolutions per minute. + + + + + + + + + This type provides the ability to extend any data type that includes it. + + + + + + + diff --git a/tools/schema/gpx/garmin/TrackPointExtensionv2.xsd b/tools/schema/gpx/garmin/TrackPointExtensionv2.xsd new file mode 100644 index 000000000..3417edd3a --- /dev/null +++ b/tools/schema/gpx/garmin/TrackPointExtensionv2.xsd @@ -0,0 +1,94 @@ + + + + + This schema defines Garmin extensions to be used with the GPX 1.1 schema. + The root element defined by this schema is intended to be used as a child + element of the "extensions" elements in the trkpt element in the GPX 1.1 schema. + The GPX 1.1 schema is available at http://www.topografix.com/GPX/1/1/gpx.xsd. + This is a replacement for TrackPointExtension in + http://www.garmin.com/xmlschemas/GpxExtensions/v3 + + + + + + + This type contains data fields that cannot + be represented in track points in GPX 1.1 instances. + + + + + + + + + + + + + + + + + This type contains a temperature value measured in degrees Celsius. + + + + + + + This type contains a distance value measured in meters. + + + + + + + This type contains a heart rate measured in beats per minute. + + + + + + + + + This type contains a cadence measured in revolutions per minute. + + + + + + + + + This type contains a speed measured in meters per second. + + + + + + + This type contains an angle measured in degrees in a clockwise direction from the true north line. + + + + + + + + + + This type provides the ability to extend any data type that includes it. + + + + + + + diff --git a/tools/schema/gpx/garmin/TrackPointExtensionv2.xsd.1 b/tools/schema/gpx/garmin/TrackPointExtensionv2.xsd.1 new file mode 100644 index 000000000..3417edd3a --- /dev/null +++ b/tools/schema/gpx/garmin/TrackPointExtensionv2.xsd.1 @@ -0,0 +1,94 @@ + + + + + This schema defines Garmin extensions to be used with the GPX 1.1 schema. + The root element defined by this schema is intended to be used as a child + element of the "extensions" elements in the trkpt element in the GPX 1.1 schema. + The GPX 1.1 schema is available at http://www.topografix.com/GPX/1/1/gpx.xsd. + This is a replacement for TrackPointExtension in + http://www.garmin.com/xmlschemas/GpxExtensions/v3 + + + + + + + This type contains data fields that cannot + be represented in track points in GPX 1.1 instances. + + + + + + + + + + + + + + + + + This type contains a temperature value measured in degrees Celsius. + + + + + + + This type contains a distance value measured in meters. + + + + + + + This type contains a heart rate measured in beats per minute. + + + + + + + + + This type contains a cadence measured in revolutions per minute. + + + + + + + + + This type contains a speed measured in meters per second. + + + + + + + This type contains an angle measured in degrees in a clockwise direction from the true north line. + + + + + + + + + + This type provides the ability to extend any data type that includes it. + + + + + + + diff --git a/tools/schema/gpx/garmin/TripExtensionsv1.xsd b/tools/schema/gpx/garmin/TripExtensionsv1.xsd new file mode 100644 index 000000000..588d55de3 --- /dev/null +++ b/tools/schema/gpx/garmin/TripExtensionsv1.xsd @@ -0,0 +1,136 @@ + + + + + This schema defines the Garmin route extensions specific to trips to be used + with the GPX 1.1 schema. The root elements defined by this schema are intended to be used as + child elements of the rte element in the GPX 1.1 schema. The GPX 1.1 schema is available at + http://www.topografix.com/GPX/1/1/gpx.xsd. + + + + + + + This type contains data fields intended to be used as child elements of + the rte element in the GPX 1.1 schema + + + + + Suggested transportation mode for this route. If the processor does + not know about the suggested transportation mode, a default will be chosen. Examples + include; Automotive, Motorcycling, Walking, Hiking, Mountaineering, Bicyling, + TourCycling, MountainBiking, ATV, DirtBiking, Truck, RV + + + + + + + + + + + Route via points are announced stops during a route. This type contains + data fields intended to be used as child elements of the rtept element in the GPX 1.1 schema + + + + + + Planned time to leave this route via, not valid for the last via in a + route. Date and time are in Univeral Coordinated Time (UTC), not local time. Conforms to + ISO 8601 specification for date/time representation. + + + + + Time spent at this route via. + + + + + Planned time to arrive at this route via, not valid for the first via + in a route. Date and time are in Univeral Coordinated Time (UTC), not local time. + Conforms to ISO 8601 specification for date/time representation. + + + + + Suggested calculation mode between this route via and the next route + via. If the CalculationMode element is not present or if the processor does not + recognize the suggested calculation mode, the processor may use a calculation mode + specified on a previous via. If none have been previously specified, the processor may + chose a default. Examples include; FasterTime, ShorterDistance, Direct (Off Road), + LessFuel, ScenicRoads + + + + + Suggested elevation mode between this route via and the next route + via. If the ElevationMode element is not present or if the processor does not recognize + the suggested elevation mode, the processor may use an elevation mode specified on a + previous via. If none have been previously specified, the processor may chose a default. + Examples include; Standard, MinimizeAscent + + + + + + + + + + A specific road or trail that the user selected to follow + between this route via and the next route via. If the NamedRoad element is not present + or if the processor does not recognize the suggested named road, the processor may use a + named road specified on a previous via. If none have been previously specified, the + processor may ignore this. + + + + + User friendly name of the road or trail + + + + + ID of the road or trail + + + + + Product and family ID of map product that contains the road or trail + + + + + + + + + + + Route shaping points influence the route path that is calculated, but are + not announced or listed in driving directions. This type contains data fields intended to be + used as child elements of the rtept element in the GPX 1.1 schema + + + + + + + + + This type provides the ability to extend any data type that includes + it. + + + + + + + diff --git a/tools/schema/gpx/garmin/TripExtensionsv1.xsd.1 b/tools/schema/gpx/garmin/TripExtensionsv1.xsd.1 new file mode 100644 index 000000000..588d55de3 --- /dev/null +++ b/tools/schema/gpx/garmin/TripExtensionsv1.xsd.1 @@ -0,0 +1,136 @@ + + + + + This schema defines the Garmin route extensions specific to trips to be used + with the GPX 1.1 schema. The root elements defined by this schema are intended to be used as + child elements of the rte element in the GPX 1.1 schema. The GPX 1.1 schema is available at + http://www.topografix.com/GPX/1/1/gpx.xsd. + + + + + + + This type contains data fields intended to be used as child elements of + the rte element in the GPX 1.1 schema + + + + + Suggested transportation mode for this route. If the processor does + not know about the suggested transportation mode, a default will be chosen. Examples + include; Automotive, Motorcycling, Walking, Hiking, Mountaineering, Bicyling, + TourCycling, MountainBiking, ATV, DirtBiking, Truck, RV + + + + + + + + + + + Route via points are announced stops during a route. This type contains + data fields intended to be used as child elements of the rtept element in the GPX 1.1 schema + + + + + + Planned time to leave this route via, not valid for the last via in a + route. Date and time are in Univeral Coordinated Time (UTC), not local time. Conforms to + ISO 8601 specification for date/time representation. + + + + + Time spent at this route via. + + + + + Planned time to arrive at this route via, not valid for the first via + in a route. Date and time are in Univeral Coordinated Time (UTC), not local time. + Conforms to ISO 8601 specification for date/time representation. + + + + + Suggested calculation mode between this route via and the next route + via. If the CalculationMode element is not present or if the processor does not + recognize the suggested calculation mode, the processor may use a calculation mode + specified on a previous via. If none have been previously specified, the processor may + chose a default. Examples include; FasterTime, ShorterDistance, Direct (Off Road), + LessFuel, ScenicRoads + + + + + Suggested elevation mode between this route via and the next route + via. If the ElevationMode element is not present or if the processor does not recognize + the suggested elevation mode, the processor may use an elevation mode specified on a + previous via. If none have been previously specified, the processor may chose a default. + Examples include; Standard, MinimizeAscent + + + + + + + + + + A specific road or trail that the user selected to follow + between this route via and the next route via. If the NamedRoad element is not present + or if the processor does not recognize the suggested named road, the processor may use a + named road specified on a previous via. If none have been previously specified, the + processor may ignore this. + + + + + User friendly name of the road or trail + + + + + ID of the road or trail + + + + + Product and family ID of map product that contains the road or trail + + + + + + + + + + + Route shaping points influence the route path that is calculated, but are + not announced or listed in driving directions. This type contains data fields intended to be + used as child elements of the rtept element in the GPX 1.1 schema + + + + + + + + + This type provides the ability to extend any data type that includes + it. + + + + + + + diff --git a/tools/schema/gpx/groundspeak/cache10.xsd b/tools/schema/gpx/groundspeak/cache10.xsd new file mode 100644 index 000000000..425dfb9ad --- /dev/null +++ b/tools/schema/gpx/groundspeak/cache10.xsd @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/schema/gpx/groundspeak/cache101.xsd b/tools/schema/gpx/groundspeak/cache101.xsd new file mode 100644 index 000000000..d0873b4a6 --- /dev/null +++ b/tools/schema/gpx/groundspeak/cache101.xsd @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/schema/gpx/groundspeak/cache11.xsd b/tools/schema/gpx/groundspeak/cache11.xsd new file mode 100644 index 000000000..fd83a6d5d --- /dev/null +++ b/tools/schema/gpx/groundspeak/cache11.xsd @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/schema/gpx/groundspeak/cache12.xsd b/tools/schema/gpx/groundspeak/cache12.xsd new file mode 100644 index 000000000..5324fabbd --- /dev/null +++ b/tools/schema/gpx/groundspeak/cache12.xsd @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/schema/gpx/master.xsd b/tools/schema/gpx/master.xsd new file mode 100644 index 000000000..7c767b4a4 --- /dev/null +++ b/tools/schema/gpx/master.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/tools/schema/gpx/topografix/gpx10.xsd b/tools/schema/gpx/topografix/gpx10.xsd new file mode 100644 index 000000000..a49992ddd --- /dev/null +++ b/tools/schema/gpx/topografix/gpx10.xsd @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/schema/gpx/topografix/gpx11.xsd b/tools/schema/gpx/topografix/gpx11.xsd new file mode 100644 index 000000000..a113a41c3 --- /dev/null +++ b/tools/schema/gpx/topografix/gpx11.xsd @@ -0,0 +1,788 @@ + + + + + + GPX schema version 1.1 - For more information on GPX and this schema, visit http://www.topografix.com/gpx.asp + + GPX uses the following conventions: all coordinates are relative to the WGS84 datum. All measurements are in metric units. + + + + + + + GPX is the root element in the XML file. + + + + + + + + GPX documents contain a metadata header, followed by waypoints, routes, and tracks. You can add your own elements + to the extensions section of the GPX document. + + + + + + + Metadata about the file. + + + + + + + A list of waypoints. + + + + + + + A list of routes. + + + + + + + A list of tracks. + + + + + + + You can add extend GPX by adding your own elements from another schema here. + + + + + + + + + You must include the version number in your GPX document. + + + + + + + You must include the name or URL of the software that created your GPX document. This allows others to + inform the creator of a GPX instance document that fails to validate. + + + + + + + + + Information about the GPX file, author, and copyright restrictions goes in the metadata section. Providing rich, + meaningful information about your GPX files allows others to search for and use your GPS data. + + + + + + + The name of the GPX file. + + + + + + + A description of the contents of the GPX file. + + + + + + + The person or organization who created the GPX file. + + + + + + + Copyright and license information governing use of the file. + + + + + + + URLs associated with the location described in the file. + + + + + + + The creation date of the file. + + + + + + + Keywords associated with the file. Search engines or databases can use this information to classify the data. + + + + + + + Minimum and maximum coordinates which describe the extent of the coordinates in the file. + + + + + + + + You can add extend GPX by adding your own elements from another schema here. + + + + + + + + + + wpt represents a waypoint, point of interest, or named feature on a map. + + + + + + + + Elevation (in meters) of the point. + + + + + + + Creation/modification timestamp for element. Date and time in are in Univeral Coordinated Time (UTC), not local time! Conforms to ISO 8601 specification for date/time representation. Fractional seconds are allowed for millisecond timing in tracklogs. + + + + + + + Magnetic variation (in degrees) at the point + + + + + + + Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message. + + + + + + + + + The GPS name of the waypoint. This field will be transferred to and from the GPS. GPX does not place restrictions on the length of this field or the characters contained in it. It is up to the receiving application to validate the field before sending it to the GPS. + + + + + + + GPS waypoint comment. Sent to GPS as comment. + + + + + + + A text description of the element. Holds additional information about the element intended for the user, not the GPS. + + + + + + + Source of data. Included to give user some idea of reliability and accuracy of data. "Garmin eTrex", "USGS quad Boston North", e.g. + + + + + + + Link to additional information about the waypoint. + + + + + + + Text of GPS symbol name. For interchange with other programs, use the exact spelling of the symbol as displayed on the GPS. If the GPS abbreviates words, spell them out. + + + + + + + Type (classification) of the waypoint. + + + + + + + + + Type of GPX fix. + + + + + + + Number of satellites used to calculate the GPX fix. + + + + + + + Horizontal dilution of precision. + + + + + + + Vertical dilution of precision. + + + + + + + Position dilution of precision. + + + + + + + Number of seconds since last DGPS update. + + + + + + + ID of DGPS station used in differential correction. + + + + + + + + You can add extend GPX by adding your own elements from another schema here. + + + + + + + + + The latitude of the point. This is always in decimal degrees, and always in WGS84 datum. + + + + + + + The longitude of the point. This is always in decimal degrees, and always in WGS84 datum. + + + + + + + + + rte represents route - an ordered list of waypoints representing a series of turn points leading to a destination. + + + + + + + GPS name of route. + + + + + + + GPS comment for route. + + + + + + + Text description of route for user. Not sent to GPS. + + + + + + + Source of data. Included to give user some idea of reliability and accuracy of data. + + + + + + + Links to external information about the route. + + + + + + + GPS route number. + + + + + + + Type (classification) of route. + + + + + + + + You can add extend GPX by adding your own elements from another schema here. + + + + + + + + A list of route points. + + + + + + + + + + trk represents a track - an ordered list of points describing a path. + + + + + + + GPS name of track. + + + + + + + GPS comment for track. + + + + + + + User description of track. + + + + + + + Source of data. Included to give user some idea of reliability and accuracy of data. + + + + + + + Links to external information about track. + + + + + + + GPS track number. + + + + + + + Type (classification) of track. + + + + + + + + You can add extend GPX by adding your own elements from another schema here. + + + + + + + + A Track Segment holds a list of Track Points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data. + + + + + + + + + + You can add extend GPX by adding your own elements from another schema here. + + + + + + + You can add extend GPX by adding your own elements from another schema here. + + + + + + + + + + A Track Segment holds a list of Track Points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data. + + + + + + + A Track Point holds the coordinates, elevation, timestamp, and metadata for a single point in a track. + + + + + + + + You can add extend GPX by adding your own elements from another schema here. + + + + + + + + + + Information about the copyright holder and any license governing use of this file. By linking to an appropriate license, + you may place your data into the public domain or grant additional usage rights. + + + + + + + Year of copyright. + + + + + + + Link to external file containing license text. + + + + + + + + Copyright holder (TopoSoft, Inc.) + + + + + + + + + A link to an external resource (Web page, digital photo, video clip, etc) with additional information. + + + + + + + Text of hyperlink. + + + + + + + Mime type of content (image/jpeg) + + + + + + + + URL of hyperlink. + + + + + + + + + An email address. Broken into two parts (id and domain) to help prevent email harvesting. + + + + + + id half of email address (billgates2004) + + + + + + + domain half of email address (hotmail.com) + + + + + + + + + A person or organization. + + + + + + + Name of person or organization. + + + + + + + Email address. + + + + + + + Link to Web site or other external information about person. + + + + + + + + + + A geographic point with optional elevation and time. Available for use by other schemas. + + + + + + + The elevation (in meters) of the point. + + + + + + + The time that the point was recorded. + + + + + + + + The latitude of the point. Decimal degrees, WGS84 datum. + + + + + + + The latitude of the point. Decimal degrees, WGS84 datum. + + + + + + + + + An ordered sequence of points. (for polygons or polylines, e.g.) + + + + + + + Ordered list of geographic points. + + + + + + + + + + Two lat/lon pairs defining the extent of an element. + + + + + + The minimum latitude. + + + + + + + The minimum longitude. + + + + + + + The maximum latitude. + + + + + + + The maximum longitude. + + + + + + + + + + The latitude of the point. Decimal degrees, WGS84 datum. + + + + + + + + + + + + The longitude of the point. Decimal degrees, WGS84 datum. + + + + + + + + + + + + Used for bearing, heading, course. Units are decimal degrees, true (not magnetic). + + + + + + + + + + + + Type of GPS fix. none means GPS had no fix. To signify "the fix info is unknown, leave out fixType entirely. pps = military signal used + + + + + + + + + + + + + + + Represents a differential GPS station. + + + + + + + + + diff --git a/tools/kml22-schema/atom-author-link.xsd b/tools/schema/kml/atom-author-link.xsd similarity index 100% rename from tools/kml22-schema/atom-author-link.xsd rename to tools/schema/kml/atom-author-link.xsd diff --git a/tools/kml22-schema/kml22gx.xsd b/tools/schema/kml/kml22gx.xsd similarity index 100% rename from tools/kml22-schema/kml22gx.xsd rename to tools/schema/kml/kml22gx.xsd diff --git a/tools/kml22-schema/ogckml22.xsd b/tools/schema/kml/ogckml22.xsd similarity index 100% rename from tools/kml22-schema/ogckml22.xsd rename to tools/schema/kml/ogckml22.xsd diff --git a/tools/kml22-schema/xAL.xsd b/tools/schema/kml/xAL.xsd similarity index 100% rename from tools/kml22-schema/xAL.xsd rename to tools/schema/kml/xAL.xsd From c66891680b364341d590fe6ed1b718da0f8ed768 Mon Sep 17 00:00:00 2001 From: GPSBabel <12013583+GPSBabelDeveloper@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:19:55 -0500 Subject: [PATCH 022/132] Update (now archived) Oozy Rat from Geocaching.com in 2023 (#1196) * Update (now archived) Oozy Rat from Geocaching.com in 2023 * Replace GCGCA* (Ooozy Rat) with 2023 version from Groundspeak. * Regenerate all reference files. * Nail TZ in geocache logs in text, html to GMT. This has been a problem that's plagued geocaching apps forever --------- Co-authored-by: Robert Lipe --- html.cc | 2 +- reference/earth-gc.kml | 66 ++++++---- reference/gc/GCGCA8-encoded.txt | 6 +- reference/gc/GCGCA8.gpx | 220 +++++++++++++++++++++++++------- reference/gc/GCGCA8.html | 40 +++--- reference/gc/GCGCA8.txt | 6 +- reference/gc/GCGCA8_logs.html | 111 ++++++++++++---- reference/gc/GCGCA8~vcard.vcf | 4 +- text.cc | 2 +- 9 files changed, 332 insertions(+), 125 deletions(-) diff --git a/html.cc b/html.cc index 3273a1d96..0385c2687 100644 --- a/html.cc +++ b/html.cc @@ -168,7 +168,7 @@ HtmlFormat::html_disp(const Waypoint* wpt) const logpart = curlog->xml_findfirst(u"groundspeak:date"); if (logpart) { - gpsbabel::DateTime logtime = xml_parse_time(logpart->cdata).toLocalTime(); + gpsbabel::DateTime logtime = xml_parse_time(logpart->cdata).toUTC(); *file_out << "" << logtime.toString(u"yyyy-MM-dd") << "
\n"; } diff --git a/reference/earth-gc.kml b/reference/earth-gc.kml index 94d1bfde0..9fe1aa587 100644 --- a/reference/earth-gc.kml +++ b/reference/earth-gc.kml @@ -5,11 +5,11 @@ 2002-08-15T07:00:00Z - 2003-06-29T07:00:00Z + 2003-06-29T00:00:00Z - -79.930833 + -79.930834 41.027500 - 2109328.437865 + 2109328.427385 + + + + + normal + #route_n + + + highlight + #route_h + + + + + + + + + normal + #track_n + + + highlight + #track_h + + + + + + + + + normal + #multiTrack_n + + + highlight + #multiTrack_h + + + + + + + + + normal + #waypoint_n + + + highlight + #waypoint_h + + + + + + Ground Speed + + + G Force? + + + # Of Sats + + + + Tracks + + PRESALTTRK + #multiTrack + + absolute + 2022-07-16T19:41:31Z + 2022-07-16T19:41:46Z + 2022-07-16T19:42:01Z + 2022-07-16T19:42:16Z + 2022-07-16T19:42:22Z + 2022-07-16T19:42:27Z + 2022-07-16T19:42:32Z + 2022-07-16T19:42:37Z + 2022-07-16T19:42:42Z + 2022-07-16T19:42:47Z + 2022-07-16T19:42:52Z + 2022-07-16T19:42:57Z + 2022-07-16T19:43:02Z + 2022-07-16T19:43:07Z + 2022-07-16T19:43:13Z + 2022-07-16T19:43:17Z + 2022-07-16T19:43:22Z + 2022-07-16T19:43:27Z + 2022-07-16T19:43:32Z + 2022-07-16T19:43:38Z + 2022-07-16T19:43:42Z + 2022-07-16T19:43:47Z + 2022-07-16T19:43:52Z + 2022-07-16T19:43:58Z + 2022-07-16T19:44:03Z + 2022-07-16T19:44:08Z + 2022-07-16T19:44:13Z + 2022-07-16T19:44:18Z + 2022-07-16T19:44:23Z + 2022-07-16T19:44:28Z + 2022-07-16T19:44:33Z + 2022-07-16T19:44:38Z + 2022-07-16T19:44:43Z + 2022-07-16T19:44:48Z + 2022-07-16T19:44:53Z + 2022-07-16T19:44:58Z + 2022-07-16T19:45:03Z + 2022-07-16T19:45:08Z + 2022-07-16T19:45:13Z + 2022-07-16T19:45:18Z + 2022-07-16T19:45:23Z + 2022-07-16T19:45:28Z + 2022-07-16T19:45:33Z + 2022-07-16T19:45:38Z + 2022-07-16T19:45:43Z + 2022-07-16T19:45:48Z + 2022-07-16T19:45:53Z + 2022-07-16T19:45:58Z + 2022-07-16T19:46:03Z + 2022-07-16T19:46:08Z + 2022-07-16T19:46:13Z + 2022-07-16T19:46:18Z + 2022-07-16T19:46:23Z + 2022-07-16T19:46:28Z + 2022-07-16T19:46:33Z + 2022-07-16T19:46:38Z + 2022-07-16T19:46:43Z + 2022-07-16T19:46:48Z + 2022-07-16T19:46:53Z + 2022-07-16T19:46:58Z + 2022-07-16T19:47:03Z + 2022-07-16T19:47:08Z + 2022-07-16T19:47:13Z + 2022-07-16T19:47:18Z + 2022-07-16T19:47:23Z + 2022-07-16T19:47:28Z + 2022-07-16T19:47:33Z + 2022-07-16T19:47:39Z + 2022-07-16T19:47:44Z + 2022-07-16T19:47:49Z + 2022-07-16T19:47:53Z + 2022-07-16T19:47:59Z + 2022-07-16T19:48:03Z + 2022-07-16T19:48:09Z + 2022-07-16T19:48:14Z + 2022-07-16T19:48:19Z + 2022-07-16T19:48:24Z + 2022-07-16T19:48:29Z + 2022-07-16T19:48:34Z + 2022-07-16T19:48:39Z + 2022-07-16T19:48:44Z + 2022-07-16T19:48:49Z + 2022-07-16T19:48:54Z + 2022-07-16T19:48:59Z + 2022-07-16T19:49:04Z + 2022-07-16T19:49:09Z + 2022-07-16T19:49:14Z + 2022-07-16T19:49:19Z + 2022-07-16T19:49:24Z + 2022-07-16T19:49:29Z + 2022-07-16T19:49:34Z + 2022-07-16T19:49:39Z + 2022-07-16T19:49:44Z + 2022-07-16T19:49:49Z + 2022-07-16T19:49:54Z + 2022-07-16T19:49:59Z + 2022-07-16T19:50:04Z + 2022-07-16T19:50:09Z + 2022-07-16T19:50:14Z + 2022-07-16T19:50:19Z + 2022-07-16T19:50:24Z + 2022-07-16T19:50:29Z + 2022-07-16T19:50:34Z + 2022-07-16T19:50:40Z + 2022-07-16T19:50:45Z + 2022-07-16T19:50:50Z + 2022-07-16T19:50:55Z + 2022-07-16T19:51:00Z + 2022-07-16T19:51:05Z + 2022-07-16T19:51:10Z + 2022-07-16T19:51:15Z + 2022-07-16T19:51:20Z + 2022-07-16T19:51:25Z + 2022-07-16T19:51:30Z + 2022-07-16T19:51:35Z + 2022-07-16T19:51:40Z + 2022-07-16T19:51:45Z + 2022-07-16T19:51:50Z + 2022-07-16T19:51:55Z + 2022-07-16T19:52:00Z + 2022-07-16T19:52:05Z + 2022-07-16T19:52:10Z + 2022-07-16T19:52:15Z + 2022-07-16T19:52:20Z + 2022-07-16T19:52:25Z + 2022-07-16T19:52:30Z + 2022-07-16T19:52:35Z + 2022-07-16T19:52:40Z + 2022-07-16T19:52:45Z + 2022-07-16T19:52:50Z + 2022-07-16T19:52:55Z + 2022-07-16T19:53:00Z + 2022-07-16T19:53:05Z + 2022-07-16T19:53:10Z + 2022-07-16T19:53:15Z + 2022-07-16T19:53:20Z + 2022-07-16T19:53:25Z + 2022-07-16T19:53:30Z + 2022-07-16T19:53:35Z + 2022-07-16T19:53:40Z + 2022-07-16T19:53:45Z + 2022-07-16T19:53:50Z + 2022-07-16T19:53:55Z + 2022-07-16T19:54:00Z + 2022-07-16T19:54:05Z + 2022-07-16T19:54:11Z + 2022-07-16T19:54:16Z + 2022-07-16T19:54:21Z + 2022-07-16T19:54:26Z + 2022-07-16T19:54:31Z + 2022-07-16T19:54:36Z + 2022-07-16T19:54:41Z + 2022-07-16T19:54:46Z + 2022-07-16T19:54:51Z + 2022-07-16T19:54:56Z + 2022-07-16T19:55:01Z + 2022-07-16T19:55:06Z + 2022-07-16T19:55:11Z + 2022-07-16T19:55:16Z + 2022-07-16T19:55:21Z + 2022-07-16T19:55:26Z + 2022-07-16T19:55:31Z + 2022-07-16T19:55:36Z + 2022-07-16T19:55:41Z + 2022-07-16T19:55:46Z + 2022-07-16T19:55:51Z + 2022-07-16T19:55:56Z + 2022-07-16T19:56:01Z + 2022-07-16T19:56:06Z + 2022-07-16T19:56:11Z + 2022-07-16T19:56:16Z + 2022-07-16T19:56:21Z + 2022-07-16T19:56:26Z + 2022-07-16T19:56:31Z + 2022-07-16T19:56:36Z + 2022-07-16T19:56:41Z + 2022-07-16T19:56:46Z + 2022-07-16T19:56:51Z + 2022-07-16T19:56:56Z + 2022-07-16T19:57:01Z + 2022-07-16T19:57:06Z + 2022-07-16T19:57:11Z + 2022-07-16T19:57:16Z + 2022-07-16T19:57:21Z + 2022-07-16T19:57:26Z + 2022-07-16T19:57:31Z + 2022-07-16T19:57:36Z + 2022-07-16T19:57:41Z + 2022-07-16T19:57:46Z + 2022-07-16T19:57:51Z + 2022-07-16T19:57:56Z + 2022-07-16T19:58:01Z + 2022-07-16T19:58:06Z + 2022-07-16T19:58:11Z + 2022-07-16T19:58:16Z + 2022-07-16T19:58:21Z + 2022-07-16T19:58:26Z + 2022-07-16T19:58:31Z + 2022-07-16T19:58:36Z + 2022-07-16T19:58:41Z + 2022-07-16T19:58:46Z + 2022-07-16T19:58:51Z + 2022-07-16T19:58:56Z + 2022-07-16T19:59:01Z + 2022-07-16T19:59:06Z + 2022-07-16T19:59:11Z + 2022-07-16T19:59:16Z + 2022-07-16T19:59:21Z + 2022-07-16T19:59:26Z + 2022-07-16T19:59:31Z + 2022-07-16T19:59:36Z + 2022-07-16T19:59:41Z + 2022-07-16T19:59:46Z + 2022-07-16T19:59:51Z + 2022-07-16T19:59:56Z + 2022-07-16T20:00:01Z + 2022-07-16T20:00:06Z + 2022-07-16T20:00:11Z + 2022-07-16T20:00:16Z + 2022-07-16T20:00:21Z + 2022-07-16T20:00:26Z + 2022-07-16T20:00:31Z + 2022-07-16T20:00:36Z + 2022-07-16T20:00:41Z + 2022-07-16T20:00:46Z + 2022-07-16T20:00:51Z + 2022-07-16T20:00:56Z + 2022-07-16T20:01:01Z + 2022-07-16T20:01:06Z + 2022-07-16T20:01:11Z + 2022-07-16T20:01:16Z + 2022-07-16T20:01:21Z + 2022-07-16T20:01:26Z + 2022-07-16T20:01:31Z + 2022-07-16T20:01:36Z + 2022-07-16T20:01:41Z + 2022-07-16T20:01:46Z + 2022-07-16T20:01:51Z + 2022-07-16T20:01:56Z + 2022-07-16T20:02:01Z + 2022-07-16T20:02:06Z + 2022-07-16T20:02:11Z + 2022-07-16T20:02:16Z + 2022-07-16T20:02:21Z + 2022-07-16T20:02:26Z + 2022-07-16T20:02:31Z + 2022-07-16T20:02:36Z + 2022-07-16T20:02:41Z + 2022-07-16T20:02:46Z + 2022-07-16T20:02:51Z + 2022-07-16T20:02:56Z + 2022-07-16T20:03:01Z + 2022-07-16T20:03:06Z + 2022-07-16T20:03:11Z + 2022-07-16T20:03:16Z + 2022-07-16T20:03:22Z + 2022-07-16T20:03:27Z + 2022-07-16T20:03:32Z + 2022-07-16T20:03:37Z + 2022-07-16T20:03:42Z + 2022-07-16T20:03:47Z + 2022-07-16T20:03:52Z + 2022-07-16T20:03:57Z + 2022-07-16T20:04:02Z + 2022-07-16T20:04:07Z + 2022-07-16T20:04:12Z + 2022-07-16T20:04:17Z + 2022-07-16T20:04:22Z + 2022-07-16T20:04:27Z + 2022-07-16T20:04:32Z + 2022-07-16T20:04:37Z + 2022-07-16T20:04:42Z + 2022-07-16T20:04:47Z + 2022-07-16T20:04:52Z + 2022-07-16T20:04:57Z + 2022-07-16T20:05:02Z + 2022-07-16T20:05:07Z + 2022-07-16T20:05:12Z + 2022-07-16T20:05:17Z + 2022-07-16T20:05:22Z + 2022-07-16T20:05:27Z + 2022-07-16T20:05:32Z + 2022-07-16T20:05:37Z + 2022-07-16T20:05:42Z + 2022-07-16T20:05:47Z + 2022-07-16T20:05:52Z + 2022-07-16T20:05:57Z + 2022-07-16T20:06:02Z + 2022-07-16T20:06:07Z + 2022-07-16T20:06:12Z + 2022-07-16T20:06:17Z + 2022-07-16T20:06:22Z + 2022-07-16T20:06:27Z + 2022-07-16T20:06:32Z + 2022-07-16T20:06:37Z + 2022-07-16T20:06:42Z + 2022-07-16T20:06:47Z + 2022-07-16T20:06:52Z + 2022-07-16T20:06:57Z + 2022-07-16T20:07:02Z + 2022-07-16T20:07:07Z + 2022-07-16T20:07:12Z + 2022-07-16T20:07:17Z + 2022-07-16T20:07:22Z + 2022-07-16T20:07:27Z + 2022-07-16T20:07:32Z + 2022-07-16T20:07:37Z + 2022-07-16T20:07:42Z + 2022-07-16T20:07:47Z + 2022-07-16T20:07:52Z + 2022-07-16T20:07:57Z + 2022-07-16T20:08:02Z + 2022-07-16T20:08:07Z + 2022-07-16T20:08:12Z + 2022-07-16T20:08:17Z + 2022-07-16T20:08:22Z + 2022-07-16T20:08:27Z + 2022-07-16T20:08:32Z + 2022-07-16T20:08:37Z + 2022-07-16T20:08:42Z + 2022-07-16T20:08:47Z + 2022-07-16T20:08:52Z + 2022-07-16T20:08:57Z + 2022-07-16T20:09:02Z + 2022-07-16T20:09:07Z + 2022-07-16T20:09:12Z + 2022-07-16T20:09:17Z + 2022-07-16T20:09:22Z + 2022-07-16T20:09:27Z + 2022-07-16T20:09:32Z + 2022-07-16T20:09:37Z + 2022-07-16T20:09:42Z + 2022-07-16T20:09:47Z + 2022-07-16T20:09:52Z + 2022-07-16T20:09:57Z + 2022-07-16T20:10:02Z + 2022-07-16T20:10:07Z + 2022-07-16T20:10:12Z + 2022-07-16T20:10:17Z + 2022-07-16T20:10:22Z + 2022-07-16T20:10:27Z + 2022-07-16T20:10:32Z + 2022-07-16T20:10:37Z + 2022-07-16T20:10:42Z + 2022-07-16T20:10:47Z + 2022-07-16T20:10:52Z + 2022-07-16T20:10:57Z + 2022-07-16T20:11:02Z + 2022-07-16T20:11:07Z + 2022-07-16T20:11:12Z + 2022-07-16T20:11:17Z + 2022-07-16T20:11:22Z + 2022-07-16T20:11:27Z + 2022-07-16T20:11:32Z + 2022-07-16T20:11:37Z + 2022-07-16T20:11:42Z + 2022-07-16T20:11:47Z + 2022-07-16T20:11:52Z + 2022-07-16T20:11:57Z + 2022-07-16T20:12:02Z + 2022-07-16T20:12:07Z + 2022-07-16T20:12:12Z + 2022-07-16T20:12:17Z + 2022-07-16T20:12:22Z + 2022-07-16T20:12:27Z + 2022-07-16T20:12:32Z + 2022-07-16T20:12:37Z + 2022-07-16T20:12:42Z + 2022-07-16T20:12:47Z + 2022-07-16T20:12:52Z + 2022-07-16T20:12:57Z + 2022-07-16T20:13:02Z + 2022-07-16T20:13:07Z + 2022-07-16T20:13:12Z + 2022-07-16T20:13:17Z + 2022-07-16T20:13:22Z + 2022-07-16T20:13:27Z + 2022-07-16T20:13:32Z + 2022-07-16T20:13:37Z + 2022-07-16T20:13:42Z + 2022-07-16T20:13:47Z + 2022-07-16T20:13:52Z + 2022-07-16T20:13:57Z + 2022-07-16T20:14:02Z + 2022-07-16T20:14:07Z + 2022-07-16T20:14:12Z + 2022-07-16T20:14:17Z + 2022-07-16T20:14:22Z + 2022-07-16T20:14:27Z + 2022-07-16T20:14:32Z + 2022-07-16T20:14:37Z + 2022-07-16T20:14:42Z + 2022-07-16T20:14:47Z + 2022-07-16T20:14:52Z + 2022-07-16T20:14:57Z + 2022-07-16T20:15:02Z + 2022-07-16T20:15:07Z + 2022-07-16T20:15:12Z + 2022-07-16T20:15:17Z + 2022-07-16T20:15:22Z + 2022-07-16T20:15:27Z + 2022-07-16T20:15:32Z + 2022-07-16T20:15:37Z + 2022-07-16T20:15:42Z + 2022-07-16T20:15:47Z + 2022-07-16T20:15:52Z + 2022-07-16T20:15:57Z + 2022-07-16T20:16:02Z + 2022-07-16T20:16:07Z + 2022-07-16T20:16:12Z + 2022-07-16T20:16:17Z + 2022-07-16T20:16:22Z + 2022-07-16T20:16:27Z + 2022-07-16T20:16:33Z + 2022-07-16T20:16:38Z + 2022-07-16T20:16:43Z + 2022-07-16T20:16:48Z + 2022-07-16T20:16:53Z + 2022-07-16T20:16:58Z + 2022-07-16T20:17:03Z + 2022-07-16T20:17:08Z + 2022-07-16T20:17:13Z + 2022-07-16T20:17:18Z + 2022-07-16T20:17:23Z + 2022-07-16T20:17:28Z + 2022-07-16T20:17:33Z + 2022-07-16T20:17:38Z + 2022-07-16T20:17:43Z + 2022-07-16T20:17:48Z + 2022-07-16T20:17:53Z + 2022-07-16T20:17:58Z + 2022-07-16T20:18:03Z + 2022-07-16T20:18:08Z + 2022-07-16T20:18:13Z + 2022-07-16T20:18:18Z + 2022-07-16T20:18:23Z + 2022-07-16T20:18:28Z + 2022-07-16T20:18:33Z + 2022-07-16T20:18:38Z + 2022-07-16T20:18:43Z + 2022-07-16T20:18:48Z + 2022-07-16T20:18:53Z + 2022-07-16T20:18:58Z + 2022-07-16T20:19:03Z + 2022-07-16T20:19:08Z + 2022-07-16T20:19:13Z + 2022-07-16T20:19:18Z + 2022-07-16T20:19:23Z + 2022-07-16T20:19:28Z + 2022-07-16T20:19:33Z + 2022-07-16T20:19:38Z + 2022-07-16T20:19:43Z + 2022-07-16T20:19:48Z + 2022-07-16T20:19:53Z + 2022-07-16T20:19:58Z + 2022-07-16T20:20:03Z + 2022-07-16T20:20:08Z + 2022-07-16T20:20:13Z + 2022-07-16T20:20:18Z + 2022-07-16T20:20:23Z + 2022-07-16T20:20:28Z + 2022-07-16T20:20:33Z + 2022-07-16T20:20:38Z + 2022-07-16T20:20:43Z + 2022-07-16T20:20:48Z + 2022-07-16T20:20:53Z + 2022-07-16T20:20:58Z + 2022-07-16T20:21:03Z + 2022-07-16T20:21:08Z + 2022-07-16T20:21:13Z + 2022-07-16T20:21:18Z + 2022-07-16T20:21:23Z + 2022-07-16T20:21:28Z + 2022-07-16T20:21:33Z + 2022-07-16T20:21:38Z + 2022-07-16T20:21:43Z + 2022-07-16T20:21:48Z + 2022-07-16T20:21:53Z + 2022-07-16T20:21:58Z + 2022-07-16T20:22:03Z + 2022-07-16T20:22:08Z + 2022-07-16T20:22:13Z + 2022-07-16T20:22:18Z + 2022-07-16T20:22:23Z + 2022-07-16T20:22:28Z + 2022-07-16T20:22:33Z + 2022-07-16T20:22:38Z + 2022-07-16T20:22:43Z + 2022-07-16T20:22:48Z + 2022-07-16T20:22:53Z + 2022-07-16T20:22:58Z + 2022-07-16T20:23:03Z + 2022-07-16T20:23:08Z + 2022-07-16T20:23:13Z + 2022-07-16T20:23:18Z + 2022-07-16T20:23:23Z + 2022-07-16T20:23:28Z + 2022-07-16T20:23:33Z + 2022-07-16T20:23:38Z + 2022-07-16T20:23:43Z + 2022-07-16T20:23:48Z + 2022-07-16T20:23:53Z + 2022-07-16T20:23:58Z + 2022-07-16T20:24:03Z + 2022-07-16T20:24:08Z + 2022-07-16T20:24:13Z + 2022-07-16T20:24:18Z + 2022-07-16T20:24:23Z + 2022-07-16T20:24:28Z + 2022-07-16T20:24:33Z + 2022-07-16T20:24:38Z + 2022-07-16T20:24:43Z + 2022-07-16T20:24:48Z + 2022-07-16T20:24:53Z + 2022-07-16T20:24:58Z + 2022-07-16T20:25:03Z + 2022-07-16T20:25:08Z + 2022-07-16T20:25:13Z + 2022-07-16T20:25:18Z + 2022-07-16T20:25:23Z + 2022-07-16T20:25:28Z + 2022-07-16T20:25:33Z + 2022-07-16T20:25:38Z + 2022-07-16T20:25:43Z + 2022-07-16T20:25:48Z + 2022-07-16T20:25:53Z + 2022-07-16T20:25:58Z + 2022-07-16T20:26:03Z + 2022-07-16T20:26:08Z + 2022-07-16T20:26:13Z + 2022-07-16T20:26:18Z + 2022-07-16T20:26:23Z + 2022-07-16T20:26:28Z + 2022-07-16T20:26:33Z + 2022-07-16T20:26:38Z + 2022-07-16T20:26:43Z + 2022-07-16T20:26:48Z + 2022-07-16T20:26:53Z + 2022-07-16T20:26:58Z + 2022-07-16T20:27:03Z + 2022-07-16T20:27:08Z + 2022-07-16T20:27:13Z + 2022-07-16T20:27:18Z + 2022-07-16T20:27:23Z + 2022-07-16T20:27:28Z + 2022-07-16T20:27:33Z + 2022-07-16T20:27:38Z + 2022-07-16T20:27:43Z + 2022-07-16T20:27:48Z + 2022-07-16T20:27:53Z + 2022-07-16T20:27:58Z + 2022-07-16T20:28:03Z + 2022-07-16T20:28:08Z + 2022-07-16T20:28:13Z + 2022-07-16T20:28:18Z + 2022-07-16T20:28:23Z + 2022-07-16T20:28:28Z + 2022-07-16T20:28:33Z + 2022-07-16T20:28:38Z + 2022-07-16T20:28:43Z + 2022-07-16T20:28:48Z + 2022-07-16T20:28:53Z + 2022-07-16T20:28:58Z + 2022-07-16T20:29:03Z + 2022-07-16T20:29:09Z + 2022-07-16T20:29:13Z + 2022-07-16T20:29:19Z + 2022-07-16T20:29:24Z + 2022-07-16T20:29:29Z + 2022-07-16T20:29:34Z + 2022-07-16T20:29:39Z + 2022-07-16T20:29:44Z + 2022-07-16T20:29:49Z + 2022-07-16T20:29:54Z + 2022-07-16T20:29:59Z + 2022-07-16T20:30:04Z + 2022-07-16T20:30:09Z + 2022-07-16T20:30:14Z + 2022-07-16T20:30:19Z + 2022-07-16T20:30:24Z + 2022-07-16T20:30:29Z + 2022-07-16T20:30:34Z + 2022-07-16T20:30:39Z + 2022-07-16T20:30:44Z + 2022-07-16T20:30:49Z + 2022-07-16T20:30:54Z + 2022-07-16T20:30:59Z + 2022-07-16T20:31:04Z + 2022-07-16T20:31:09Z + 2022-07-16T20:31:14Z + 2022-07-16T20:31:19Z + 2022-07-16T20:31:24Z + 2022-07-16T20:31:29Z + 2022-07-16T20:31:34Z + 2022-07-16T20:31:39Z + 2022-07-16T20:31:44Z + 2022-07-16T20:31:49Z + 2022-07-16T20:31:54Z + 2022-07-16T20:31:59Z + 2022-07-16T20:32:04Z + 2022-07-16T20:32:09Z + 2022-07-16T20:32:14Z + 2022-07-16T20:32:19Z + 2022-07-16T20:32:24Z + 2022-07-16T20:32:29Z + 2022-07-16T20:32:34Z + 2022-07-16T20:32:39Z + 2022-07-16T20:32:44Z + 2022-07-16T20:32:49Z + 2022-07-16T20:32:54Z + 2022-07-16T20:32:59Z + 2022-07-16T20:33:04Z + 2022-07-16T20:33:09Z + 2022-07-16T20:33:14Z + 2022-07-16T20:33:19Z + 2022-07-16T20:33:24Z + 2022-07-16T20:33:29Z + 2022-07-16T20:33:34Z + 2022-07-16T20:33:39Z + 2022-07-16T20:33:44Z + 2022-07-16T20:33:49Z + 2022-07-16T20:33:54Z + 2022-07-16T20:33:59Z + 2022-07-16T20:34:04Z + 2022-07-16T20:34:09Z + 2022-07-16T20:34:14Z + 2022-07-16T20:34:19Z + 2022-07-16T20:34:24Z + 2022-07-16T20:34:29Z + 2022-07-16T20:34:34Z + 2022-07-16T20:34:39Z + 2022-07-16T20:34:44Z + 2022-07-16T20:34:49Z + 2022-07-16T20:34:54Z + 2022-07-16T20:34:59Z + 2022-07-16T20:35:04Z + 2022-07-16T20:35:09Z + 2022-07-16T20:35:14Z + 2022-07-16T20:35:19Z + 2022-07-16T20:35:24Z + 2022-07-16T20:35:29Z + 2022-07-16T20:35:34Z + 2022-07-16T20:35:39Z + 2022-07-16T20:35:44Z + 2022-07-16T20:35:49Z + 2022-07-16T20:35:54Z + 2022-07-16T20:35:59Z + 2022-07-16T20:36:04Z + 2022-07-16T20:36:09Z + 2022-07-16T20:36:14Z + 2022-07-16T20:36:19Z + 2022-07-16T20:36:24Z + 2022-07-16T20:36:29Z + 2022-07-16T20:36:34Z + 2022-07-16T20:36:39Z + 2022-07-16T20:36:44Z + 2022-07-16T20:36:49Z + 2022-07-16T20:36:54Z + 2022-07-16T20:36:59Z + 2022-07-16T20:37:04Z + 2022-07-16T20:37:09Z + 2022-07-16T20:37:14Z + 2022-07-16T20:37:19Z + 2022-07-16T20:37:24Z + 2022-07-16T20:37:29Z + 2022-07-16T20:37:34Z + 2022-07-16T20:37:39Z + 2022-07-16T20:37:44Z + 2022-07-16T20:37:49Z + 2022-07-16T20:37:54Z + 2022-07-16T20:37:59Z + 2022-07-16T20:38:04Z + 2022-07-16T20:38:09Z + 2022-07-16T20:38:14Z + 2022-07-16T20:38:19Z + 2022-07-16T20:38:24Z + 2022-07-16T20:38:29Z + 2022-07-16T20:38:34Z + 2022-07-16T20:38:39Z + 2022-07-16T20:38:44Z + 2022-07-16T20:38:49Z + 2022-07-16T20:38:54Z + 2022-07-16T20:38:59Z + 2022-07-16T20:39:05Z + 2022-07-16T20:39:10Z + 2022-07-16T20:39:15Z + 2022-07-16T20:39:20Z + 2022-07-16T20:39:25Z + 2022-07-16T20:39:30Z + 2022-07-16T20:39:35Z + 2022-07-16T20:39:40Z + 2022-07-16T20:39:45Z + 2022-07-16T20:39:50Z + 2022-07-16T20:39:55Z + 2022-07-16T20:40:00Z + 2022-07-16T20:40:05Z + 2022-07-16T20:40:10Z + 2022-07-16T20:40:15Z + 2022-07-16T20:40:20Z + 2022-07-16T20:40:25Z + 2022-07-16T20:40:30Z + 2022-07-16T20:40:35Z + 2022-07-16T20:40:40Z + 2022-07-16T20:40:45Z + 2022-07-16T20:40:50Z + 2022-07-16T20:40:55Z + 2022-07-16T20:41:00Z + 2022-07-16T20:41:05Z + 2022-07-16T20:41:10Z + 2022-07-16T20:41:15Z + 2022-07-16T20:41:20Z + 2022-07-16T20:41:25Z + 2022-07-16T20:41:30Z + 2022-07-16T20:41:35Z + 2022-07-16T20:41:40Z + 2022-07-16T20:41:45Z + 2022-07-16T20:41:50Z + 2022-07-16T20:41:55Z + 2022-07-16T20:42:00Z + 2022-07-16T20:42:05Z + 2022-07-16T20:42:10Z + 2022-07-16T20:42:15Z + 2022-07-16T20:42:20Z + 2022-07-16T20:42:25Z + 2022-07-16T20:42:30Z + 2022-07-16T20:42:35Z + 2022-07-16T20:42:40Z + 2022-07-16T20:42:45Z + 2022-07-16T20:42:50Z + 2022-07-16T20:42:55Z + 2022-07-16T20:43:00Z + 2022-07-16T20:43:05Z + 2022-07-16T20:43:10Z + 2022-07-16T20:43:15Z + 2022-07-16T20:43:20Z + 2022-07-16T20:43:25Z + 2022-07-16T20:43:30Z + 2022-07-16T20:43:35Z + 2022-07-16T20:43:40Z + 2022-07-16T20:43:45Z + 2022-07-16T20:43:50Z + 2022-07-16T20:43:55Z + 2022-07-16T20:44:00Z + 2022-07-16T20:44:05Z + 2022-07-16T20:44:10Z + 2022-07-16T20:44:15Z + 2022-07-16T20:44:20Z + 2022-07-16T20:44:25Z + 2022-07-16T20:44:30Z + 2022-07-16T20:44:35Z + 2022-07-16T20:44:40Z + 2022-07-16T20:44:45Z + 2022-07-16T20:44:50Z + 2022-07-16T20:44:55Z + 2022-07-16T20:45:00Z + 2022-07-16T20:45:05Z + 2022-07-16T20:45:10Z + 2022-07-16T20:45:15Z + 2022-07-16T20:45:20Z + 2022-07-16T20:45:25Z + 2022-07-16T20:45:30Z + 2022-07-16T20:45:35Z + 2022-07-16T20:45:40Z + 2022-07-16T20:45:45Z + 2022-07-16T20:45:50Z + 2022-07-16T20:45:55Z + 2022-07-16T20:46:00Z + 2022-07-16T20:46:05Z + 2022-07-16T20:46:10Z + 2022-07-16T20:46:15Z + 2022-07-16T20:46:20Z + 2022-07-16T20:46:25Z + 2022-07-16T20:46:30Z + 2022-07-16T20:46:35Z + 2022-07-16T20:46:40Z + 2022-07-16T20:46:45Z + 2022-07-16T20:46:50Z + 2022-07-16T20:46:55Z + 2022-07-16T20:47:00Z + 2022-07-16T20:47:05Z + 2022-07-16T20:47:10Z + 2022-07-16T20:47:15Z + 2022-07-16T20:47:20Z + 2022-07-16T20:47:25Z + 2022-07-16T20:47:30Z + 2022-07-16T20:47:35Z + 2022-07-16T20:47:40Z + 2022-07-16T20:47:45Z + 2022-07-16T20:47:50Z + 2022-07-16T20:47:55Z + 2022-07-16T20:48:00Z + 2022-07-16T20:48:05Z + 2022-07-16T20:48:10Z + 2022-07-16T20:48:15Z + 2022-07-16T20:48:20Z + 2022-07-16T20:48:25Z + 2022-07-16T20:48:30Z + 2022-07-16T20:48:35Z + 2022-07-16T20:48:40Z + 2022-07-16T20:48:45Z + 2022-07-16T20:48:50Z + 2022-07-16T20:48:55Z + 2022-07-16T20:49:00Z + 2022-07-16T20:49:05Z + 2022-07-16T20:49:10Z + 2022-07-16T20:49:15Z + 2022-07-16T20:49:20Z + 2022-07-16T20:49:25Z + 2022-07-16T20:49:31Z + 2022-07-16T20:49:36Z + 2022-07-16T20:49:41Z + 2022-07-16T20:49:46Z + 2022-07-16T20:49:51Z + 2022-07-16T20:49:56Z + 2022-07-16T20:50:01Z + 2022-07-16T20:50:06Z + 2022-07-16T20:50:11Z + 2022-07-16T20:50:16Z + 2022-07-16T20:50:21Z + 2022-07-16T20:50:26Z + 2022-07-16T20:50:31Z + 2022-07-16T20:50:36Z + 2022-07-16T20:50:41Z + 2022-07-16T20:50:46Z + 2022-07-16T20:50:51Z + 2022-07-16T20:50:56Z + 2022-07-16T20:51:01Z + 2022-07-16T20:51:06Z + 2022-07-16T20:51:11Z + 2022-07-16T20:51:16Z + 2022-07-16T20:51:21Z + 2022-07-16T20:51:26Z + 2022-07-16T20:51:31Z + 2022-07-16T20:51:36Z + 2022-07-16T20:51:41Z + 2022-07-16T20:51:46Z + 2022-07-16T20:51:51Z + 2022-07-16T20:51:56Z + 2022-07-16T20:52:01Z + 2022-07-16T20:52:06Z + 2022-07-16T20:52:11Z + 2022-07-16T20:52:16Z + 2022-07-16T20:52:21Z + 2022-07-16T20:52:26Z + 2022-07-16T20:52:31Z + 2022-07-16T20:52:36Z + 2022-07-16T20:52:41Z + 2022-07-16T20:52:46Z + 2022-07-16T20:52:51Z + 2022-07-16T20:52:56Z + 2022-07-16T20:53:01Z + 2022-07-16T20:53:06Z + 2022-07-16T20:53:11Z + 2022-07-16T20:53:16Z + 2022-07-16T20:53:21Z + 2022-07-16T20:53:26Z + 2022-07-16T20:53:31Z + 2022-07-16T20:53:36Z + 2022-07-16T20:53:41Z + 2022-07-16T20:53:46Z + 2022-07-16T20:53:51Z + 2022-07-16T20:53:56Z + 2022-07-16T20:54:01Z + 2022-07-16T20:54:06Z + 2022-07-16T20:54:11Z + 2022-07-16T20:54:16Z + 2022-07-16T20:54:21Z + 2022-07-16T20:54:26Z + 2022-07-16T20:54:31Z + 2022-07-16T20:54:36Z + 2022-07-16T20:54:41Z + 2022-07-16T20:54:46Z + 2022-07-16T20:54:51Z + 2022-07-16T20:54:56Z + 2022-07-16T20:55:01Z + 2022-07-16T20:55:06Z + 2022-07-16T20:55:11Z + 2022-07-16T20:55:16Z + 2022-07-16T20:55:21Z + 2022-07-16T20:55:26Z + 2022-07-16T20:55:31Z + 2022-07-16T20:55:36Z + 2022-07-16T20:55:41Z + 2022-07-16T20:55:46Z + 2022-07-16T20:55:51Z + 2022-07-16T20:55:56Z + 2022-07-16T20:56:01Z + 2022-07-16T20:56:06Z + 2022-07-16T20:56:11Z + 2022-07-16T20:56:16Z + 2022-07-16T20:56:21Z + 2022-07-16T20:56:26Z + 2022-07-16T20:56:31Z + 2022-07-16T20:56:36Z + 2022-07-16T20:56:41Z + 2022-07-16T20:56:46Z + 2022-07-16T20:56:51Z + 2022-07-16T20:56:56Z + 2022-07-16T20:57:01Z + 2022-07-16T20:57:06Z + 2022-07-16T20:57:11Z + 2022-07-16T20:57:16Z + 2022-07-16T20:57:21Z + 2022-07-16T20:57:26Z + 2022-07-16T20:57:31Z + 2022-07-16T20:57:36Z + 2022-07-16T20:57:41Z + 2022-07-16T20:57:46Z + 2022-07-16T20:57:51Z + 2022-07-16T20:57:56Z + 2022-07-16T20:58:01Z + 2022-07-16T20:58:06Z + 2022-07-16T20:58:11Z + 2022-07-16T20:58:16Z + 2022-07-16T20:58:21Z + 2022-07-16T20:58:26Z + 2022-07-16T20:58:31Z + 2022-07-16T20:58:36Z + 2022-07-16T20:58:41Z + 2022-07-16T20:58:46Z + 2022-07-16T20:58:51Z + 2022-07-16T20:58:56Z + 2022-07-16T20:59:01Z + 2022-07-16T20:59:06Z + 2022-07-16T20:59:11Z + 2022-07-16T20:59:16Z + 2022-07-16T20:59:21Z + 2022-07-16T20:59:26Z + 2022-07-16T20:59:31Z + 2022-07-16T20:59:36Z + 2022-07-16T20:59:41Z + 2022-07-16T20:59:46Z + 2022-07-16T20:59:51Z + 2022-07-16T20:59:56Z + 2022-07-16T21:00:01Z + 2022-07-16T21:00:06Z + 2022-07-16T21:00:11Z + 2022-07-16T21:00:16Z + 2022-07-16T21:00:21Z + 2022-07-16T21:00:26Z + 2022-07-16T21:00:32Z + 2022-07-16T21:00:37Z + 2022-07-16T21:00:42Z + 2022-07-16T21:00:47Z + 2022-07-16T21:00:52Z + 2022-07-16T21:00:57Z + 2022-07-16T21:01:02Z + 2022-07-16T21:01:07Z + 2022-07-16T21:01:12Z + 2022-07-16T21:01:17Z + 2022-07-16T21:01:22Z + 2022-07-16T21:01:27Z + 2022-07-16T21:01:32Z + 2022-07-16T21:01:37Z + 2022-07-16T21:01:42Z + 2022-07-16T21:01:47Z + 2022-07-16T21:01:52Z + 2022-07-16T21:01:57Z + 2022-07-16T21:02:02Z + 2022-07-16T21:02:07Z + 2022-07-16T21:02:12Z + 2022-07-16T21:02:17Z + 2022-07-16T21:02:22Z + 2022-07-16T21:02:27Z + 2022-07-16T21:02:32Z + 2022-07-16T21:02:37Z + 2022-07-16T21:02:42Z + 2022-07-16T21:02:47Z + 2022-07-16T21:02:52Z + 2022-07-16T21:02:57Z + 2022-07-16T21:03:02Z + 2022-07-16T21:03:07Z + 2022-07-16T21:03:12Z + 2022-07-16T21:03:17Z + 2022-07-16T21:03:22Z + 2022-07-16T21:03:27Z + 2022-07-16T21:03:32Z + 2022-07-16T21:03:37Z + 2022-07-16T21:03:42Z + 2022-07-16T21:03:47Z + 2022-07-16T21:03:52Z + 2022-07-16T21:03:57Z + 2022-07-16T21:04:02Z + 2022-07-16T21:04:07Z + 2022-07-16T21:04:12Z + 2022-07-16T21:04:17Z + 2022-07-16T21:04:22Z + 2022-07-16T21:04:27Z + 2022-07-16T21:04:32Z + 2022-07-16T21:04:37Z + 2022-07-16T21:04:42Z + 2022-07-16T21:04:47Z + 2022-07-16T21:04:52Z + 2022-07-16T21:04:57Z + 2022-07-16T21:05:02Z + 2022-07-16T21:05:07Z + 2022-07-16T21:05:12Z + 2022-07-16T21:05:17Z + 2022-07-16T21:05:22Z + 2022-07-16T21:05:28Z + 2022-07-16T21:05:33Z + 2022-07-16T21:05:38Z + 2022-07-16T21:05:43Z + 2022-07-16T21:05:48Z + 2022-07-16T21:05:53Z + 2022-07-16T21:05:58Z + 2022-07-16T21:06:03Z + 2022-07-16T21:06:08Z + 2022-07-16T21:06:13Z + 2022-07-16T21:06:18Z + 2022-07-16T21:06:23Z + 2022-07-16T21:06:28Z + 2022-07-16T21:06:33Z + 2022-07-16T21:06:38Z + 2022-07-16T21:06:43Z + 2022-07-16T21:06:48Z + 2022-07-16T21:06:53Z + 2022-07-16T21:06:58Z + 2022-07-16T21:07:03Z + 2022-07-16T21:07:08Z + 2022-07-16T21:07:13Z + 2022-07-16T21:07:19Z + 2022-07-16T21:07:24Z + 2022-07-16T21:07:28Z + 2022-07-16T21:07:34Z + 2022-07-16T21:07:39Z + 2022-07-16T21:07:44Z + 2022-07-16T21:07:49Z + 2022-07-16T21:07:54Z + 2022-07-16T21:07:59Z + 2022-07-16T21:08:04Z + 2022-07-16T21:08:09Z + 2022-07-16T21:08:14Z + 2022-07-16T21:08:19Z + 2022-07-16T21:08:24Z + 2022-07-16T21:08:29Z + 2022-07-16T21:08:34Z + 2022-07-16T21:08:39Z + 2022-07-16T21:08:44Z + 2022-07-16T21:08:49Z + 2022-07-16T21:08:54Z + 2022-07-16T21:08:59Z + 2022-07-16T21:09:04Z + 2022-07-16T21:09:09Z + 2022-07-16T21:09:14Z + 2022-07-16T21:09:19Z + 2022-07-16T21:09:24Z + 2022-07-16T21:09:29Z + 2022-07-16T21:09:34Z + 2022-07-16T21:09:39Z + 2022-07-16T21:09:44Z + 2022-07-16T21:09:49Z + 2022-07-16T21:09:54Z + 2022-07-16T21:10:00Z + 2022-07-16T21:10:05Z + 2022-07-16T21:10:10Z + 2022-07-16T21:10:15Z + 2022-07-16T21:10:20Z + 2022-07-16T21:10:25Z + 2022-07-16T21:10:30Z + 2022-07-16T21:10:35Z + 2022-07-16T21:10:40Z + 2022-07-16T21:10:45Z + 2022-07-16T21:10:50Z + 2022-07-16T21:10:55Z + 2022-07-16T21:11:00Z + 2022-07-16T21:11:05Z + 2022-07-16T21:11:10Z + 2022-07-16T21:11:15Z + 2022-07-16T21:11:20Z + -80.443083 43.840333 438.00 + -80.443083 43.840333 438.00 + -80.443083 43.840333 438.00 + -80.442617 43.839933 438.00 + -80.441667 43.839200 439.00 + -80.440567 43.838433 439.00 + -80.439233 43.837517 442.00 + -80.437850 43.836533 460.00 + -80.436450 43.835600 476.00 + -80.435117 43.834700 498.00 + -80.433833 43.833833 515.00 + -80.432483 43.833000 527.00 + -80.431400 43.832050 543.00 + -80.430767 43.830933 551.00 + -80.430767 43.829700 558.00 + -80.431133 43.828533 569.00 + -80.431967 43.827483 572.00 + -80.433300 43.826650 587.00 + -80.434950 43.826117 598.00 + -80.436800 43.825667 613.00 + -80.438317 43.825250 630.00 + -80.440050 43.825017 645.00 + -80.441817 43.825250 653.00 + -80.443417 43.825967 658.00 + -80.444700 43.827117 664.00 + -80.445300 43.828633 674.00 + -80.445100 43.830217 693.00 + -80.444250 43.831683 701.00 + -80.442550 43.832883 707.00 + -80.440667 43.833500 716.00 + -80.438600 43.833683 723.00 + -80.436650 43.833267 731.00 + -80.435117 43.832383 738.00 + -80.434150 43.831200 747.00 + -80.433833 43.829900 760.00 + -80.434267 43.828650 770.00 + -80.435350 43.827617 784.00 + -80.436817 43.826950 810.00 + -80.438400 43.826483 822.00 + -80.439983 43.826083 832.00 + -80.441567 43.825700 842.00 + -80.443217 43.825317 850.00 + -80.444850 43.824883 870.00 + -80.446267 43.824200 887.00 + -80.447117 43.823100 905.00 + -80.447167 43.821850 922.00 + -80.446417 43.820617 924.00 + -80.444900 43.819717 929.00 + -80.442883 43.819250 938.00 + -80.440683 43.819350 953.00 + -80.438333 43.820033 962.00 + -80.436700 43.821067 973.00 + -80.434900 43.822217 992.00 + -80.432783 43.822983 1004.00 + -80.430450 43.823183 1014.00 + -80.428217 43.822950 1027.00 + -80.426083 43.822233 1042.00 + -80.424683 43.821150 1058.00 + -80.423833 43.819800 1067.00 + -80.423767 43.818350 1077.00 + -80.424400 43.817033 1096.00 + -80.425667 43.816033 1102.00 + -80.427400 43.815400 1110.00 + -80.429400 43.815200 1120.00 + -80.431450 43.815367 1136.00 + -80.433483 43.815633 1154.00 + -80.435483 43.815517 1174.00 + -80.437300 43.814950 1194.00 + -80.438550 43.813850 1217.00 + -80.438850 43.812467 1236.00 + -80.438283 43.811150 1262.00 + -80.437033 43.810083 1288.00 + -80.435283 43.809367 1316.00 + -80.432900 43.809350 1327.00 + -80.430750 43.809950 1342.00 + -80.429117 43.809300 1347.00 + -80.427983 43.808300 1348.00 + -80.427067 43.807283 1346.00 + -80.425767 43.806633 1341.00 + -80.424533 43.807233 1336.00 + -80.424433 43.808267 1333.00 + -80.425217 43.809133 1330.00 + -80.426517 43.809633 1328.00 + -80.428017 43.809800 1328.00 + -80.429567 43.809767 1320.00 + -80.431083 43.809567 1319.00 + -80.432583 43.809317 1325.00 + -80.434083 43.808967 1336.00 + -80.434733 43.808067 1349.00 + -80.433900 43.807333 1358.00 + -80.432517 43.807600 1373.00 + -80.431917 43.808567 1383.00 + -80.432533 43.809533 1390.00 + -80.433900 43.809750 1400.00 + -80.434967 43.809000 1408.00 + -80.434883 43.808033 1423.00 + -80.433683 43.807633 1437.00 + -80.432600 43.808233 1454.00 + -80.432683 43.809283 1459.00 + -80.433933 43.809817 1471.00 + -80.435117 43.809400 1485.00 + -80.435283 43.808483 1490.00 + -80.434300 43.807800 1503.00 + -80.432933 43.807950 1522.00 + -80.432150 43.808833 1535.00 + -80.432667 43.809950 1540.00 + -80.434017 43.810300 1555.00 + -80.435250 43.809933 1567.00 + -80.436217 43.809083 1582.00 + -80.435717 43.808200 1591.00 + -80.434367 43.808000 1597.00 + -80.433183 43.808700 1613.00 + -80.433233 43.809800 1632.00 + -80.434617 43.810167 1643.00 + -80.435617 43.809400 1656.00 + -80.435033 43.808533 1666.00 + -80.433600 43.808583 1670.00 + -80.432950 43.809700 1689.00 + -80.433483 43.810800 1703.00 + -80.435017 43.811067 1717.00 + -80.436033 43.810283 1729.00 + -80.435650 43.809317 1738.00 + -80.434000 43.809100 1744.00 + -80.432850 43.809933 1761.00 + -80.432517 43.811067 1777.00 + -80.433733 43.811683 1786.00 + -80.434950 43.811167 1797.00 + -80.434833 43.810183 1809.00 + -80.433483 43.809817 1815.00 + -80.432267 43.810533 1833.00 + -80.432500 43.811567 1848.00 + -80.433817 43.811933 1856.00 + -80.434867 43.811283 1869.00 + -80.434717 43.810367 1881.00 + -80.433517 43.809850 1892.00 + -80.432033 43.810100 1906.00 + -80.431267 43.811050 1910.00 + -80.431600 43.812083 1912.00 + -80.432783 43.812750 1912.00 + -80.434267 43.812533 1919.00 + -80.434917 43.811567 1931.00 + -80.434283 43.810550 1941.00 + -80.432750 43.810283 1961.00 + -80.431500 43.810967 1973.00 + -80.431317 43.812017 1980.00 + -80.432133 43.812850 1981.00 + -80.433450 43.813300 1989.00 + -80.434850 43.813383 2002.00 + -80.435733 43.812700 2004.00 + -80.435333 43.811700 2000.00 + -80.433933 43.811300 2007.00 + -80.432483 43.811700 2024.00 + -80.432167 43.812750 2029.00 + -80.433300 43.813467 2039.00 + -80.434483 43.813100 2049.00 + -80.434733 43.812217 2055.00 + -80.433833 43.811417 2056.00 + -80.432450 43.811633 2076.00 + -80.431950 43.812650 2075.00 + -80.432867 43.813567 2085.00 + -80.434233 43.813417 2100.00 + -80.434767 43.812550 2104.00 + -80.434017 43.811700 2113.00 + -80.432517 43.811800 2125.00 + -80.431917 43.812883 2131.00 + -80.432817 43.813767 2140.00 + -80.434117 43.813517 2152.00 + -80.434300 43.812600 2155.00 + -80.433133 43.812000 2172.00 + -80.431817 43.812517 2176.00 + -80.431600 43.813667 2184.00 + -80.432667 43.814417 2193.00 + -80.433900 43.814017 2200.00 + -80.434000 43.813067 2202.00 + -80.432650 43.812833 2214.00 + -80.431700 43.813650 2213.00 + -80.432317 43.814683 2213.00 + -80.433767 43.815017 2218.00 + -80.435250 43.814850 2216.00 + -80.436467 43.814283 2210.00 + -80.436550 43.813300 2206.00 + -80.435483 43.812550 2216.00 + -80.434117 43.812117 2213.00 + -80.432633 43.812583 2211.00 + -80.432300 43.813750 2220.00 + -80.433433 43.814467 2222.00 + -80.434767 43.814050 2225.00 + -80.434717 43.813033 2234.00 + -80.433383 43.812633 2236.00 + -80.432083 43.813150 2227.00 + -80.432117 43.814433 2226.00 + -80.432550 43.815750 2222.00 + -80.433067 43.817150 2219.00 + -80.433650 43.818650 2219.00 + -80.434467 43.820100 2231.00 + -80.435967 43.820100 2247.00 + -80.436100 43.819167 2243.00 + -80.435233 43.818217 2221.00 + -80.433733 43.817283 2213.00 + -80.432033 43.816450 2211.00 + -80.430167 43.815717 2208.00 + -80.428183 43.815050 2203.00 + -80.426133 43.814483 2197.00 + -80.424017 43.813967 2190.00 + -80.421867 43.813417 2193.00 + -80.420200 43.812900 2222.00 + -80.418750 43.812450 2214.00 + -80.417233 43.811883 2212.00 + -80.415567 43.811367 2201.00 + -80.413683 43.810767 2191.00 + -80.411750 43.810050 2182.00 + -80.409733 43.809367 2173.00 + -80.407667 43.808667 2162.00 + -80.405600 43.807817 2153.00 + -80.403567 43.806883 2148.00 + -80.401533 43.805983 2143.00 + -80.399700 43.805167 2155.00 + -80.397983 43.804483 2148.00 + -80.396000 43.803917 2126.00 + -80.393850 43.803217 2116.00 + -80.391833 43.802383 2112.00 + -80.390033 43.801517 2109.00 + -80.388400 43.800600 2107.00 + -80.386883 43.799633 2101.00 + -80.385317 43.798533 2096.00 + -80.383900 43.797517 2090.00 + -80.382517 43.796450 2089.00 + -80.381283 43.795317 2091.00 + -80.380267 43.794083 2106.00 + -80.379533 43.792983 2118.00 + -80.378967 43.791983 2118.00 + -80.378450 43.790883 2104.00 + -80.377833 43.789633 2092.00 + -80.377183 43.788300 2083.00 + -80.376517 43.786900 2076.00 + -80.375850 43.785467 2060.00 + -80.375217 43.783933 2050.00 + -80.374633 43.782500 2051.00 + -80.374117 43.781100 2044.00 + -80.373717 43.779650 2032.00 + -80.373333 43.778150 2018.00 + -80.373000 43.776583 2004.00 + -80.372633 43.774950 1992.00 + -80.372267 43.773317 1985.00 + -80.371933 43.771733 1985.00 + -80.371617 43.770217 1985.00 + -80.371150 43.768733 1982.00 + -80.370617 43.767300 1978.00 + -80.370033 43.765850 1966.00 + -80.369367 43.764333 1955.00 + -80.368717 43.762750 1942.00 + -80.368050 43.761083 1932.00 + -80.367367 43.759417 1921.00 + -80.366800 43.757733 1917.00 + -80.366283 43.756100 1909.00 + -80.365783 43.754467 1903.00 + -80.365367 43.752833 1895.00 + -80.364917 43.751200 1880.00 + -80.364450 43.749517 1875.00 + -80.363883 43.747783 1870.00 + -80.363350 43.746083 1873.00 + -80.362750 43.744417 1873.00 + -80.362200 43.742750 1873.00 + -80.361567 43.741083 1868.00 + -80.360983 43.739400 1853.00 + -80.360383 43.737667 1845.00 + -80.359733 43.735950 1839.00 + -80.359050 43.734200 1824.00 + -80.358317 43.732417 1815.00 + -80.357617 43.730483 1816.00 + -80.357033 43.728850 1818.00 + -80.356500 43.727217 1811.00 + -80.355983 43.725550 1801.00 + -80.355350 43.723833 1787.00 + -80.354700 43.722133 1773.00 + -80.354083 43.720483 1764.00 + -80.353583 43.718900 1757.00 + -80.353150 43.717333 1749.00 + -80.352650 43.715750 1736.00 + -80.352000 43.714067 1721.00 + -80.351183 43.712400 1717.00 + -80.350367 43.710750 1714.00 + -80.349417 43.709217 1716.00 + -80.348567 43.707833 1730.00 + -80.347850 43.706617 1737.00 + -80.346983 43.705567 1733.00 + -80.346517 43.704450 1729.00 + -80.347133 43.703383 1725.00 + -80.348217 43.702467 1733.00 + -80.349300 43.701550 1732.00 + -80.350450 43.700683 1726.00 + -80.351683 43.699867 1716.00 + -80.352967 43.699033 1704.00 + -80.354367 43.698200 1695.00 + -80.355867 43.697400 1686.00 + -80.357267 43.696533 1684.00 + -80.358633 43.695717 1676.00 + -80.359983 43.694967 1668.00 + -80.361317 43.694167 1660.00 + -80.362583 43.693250 1655.00 + -80.363833 43.692283 1654.00 + -80.365100 43.691367 1659.00 + -80.366250 43.690450 1666.00 + -80.367400 43.689550 1671.00 + -80.368283 43.688550 1681.00 + -80.367300 43.687633 1691.00 + -80.365600 43.687550 1703.00 + -80.364500 43.688450 1714.00 + -80.364900 43.689467 1719.00 + -80.366100 43.689900 1724.00 + -80.367183 43.689550 1727.00 + -80.367983 43.688800 1724.00 + -80.368633 43.687900 1721.00 + -80.369267 43.686917 1729.00 + -80.369983 43.685883 1734.00 + -80.369617 43.684767 1748.00 + -80.368050 43.684667 1753.00 + -80.367250 43.685667 1754.00 + -80.368033 43.686633 1769.00 + -80.369367 43.686833 1786.00 + -80.369500 43.685817 1794.00 + -80.368050 43.685450 1802.00 + -80.366983 43.686317 1807.00 + -80.367450 43.687450 1826.00 + -80.368683 43.687833 1841.00 + -80.369167 43.686833 1849.00 + -80.368133 43.685917 1865.00 + -80.366500 43.685933 1876.00 + -80.365517 43.686883 1891.00 + -80.366150 43.687817 1907.00 + -80.367383 43.687667 1923.00 + -80.367483 43.686750 1938.00 + -80.366167 43.686217 1939.00 + -80.365267 43.687250 1942.00 + -80.366250 43.688050 1961.00 + -80.367550 43.687867 1976.00 + -80.367517 43.686917 1987.00 + -80.366083 43.686533 1992.00 + -80.364700 43.687183 1998.00 + -80.364267 43.688350 2009.00 + -80.364617 43.689517 2025.00 + -80.365867 43.690117 2039.00 + -80.366983 43.689567 2040.00 + -80.366717 43.688517 2055.00 + -80.365267 43.688317 2071.00 + -80.364017 43.689133 2070.00 + -80.364117 43.690333 2088.00 + -80.364917 43.691217 2090.00 + -80.366333 43.691267 2090.00 + -80.367100 43.690400 2093.00 + -80.367033 43.689267 2105.00 + -80.365683 43.688767 2118.00 + -80.364567 43.689583 2122.00 + -80.365217 43.690467 2133.00 + -80.366500 43.690333 2140.00 + -80.366967 43.689433 2155.00 + -80.366333 43.688550 2159.00 + -80.364783 43.688167 2167.00 + -80.363500 43.688717 2173.00 + -80.363200 43.689833 2160.00 + -80.363667 43.690933 2166.00 + -80.364467 43.691900 2175.00 + -80.365433 43.692750 2176.00 + -80.366800 43.692783 2170.00 + -80.367183 43.691783 2174.00 + -80.366267 43.690900 2186.00 + -80.364750 43.690600 2191.00 + -80.363100 43.690967 2204.00 + -80.361700 43.691650 2215.00 + -80.360750 43.692650 2219.00 + -80.361067 43.693750 2220.00 + -80.362450 43.694067 2217.00 + -80.363417 43.693350 2215.00 + -80.363200 43.692317 2217.00 + -80.361917 43.691600 2227.00 + -80.360317 43.691600 2234.00 + -80.358933 43.692300 2223.00 + -80.358833 43.693467 2230.00 + -80.360000 43.694067 2229.00 + -80.361533 43.694000 2225.00 + -80.362967 43.694000 2230.00 + -80.364383 43.693883 2232.00 + -80.365833 43.693700 2235.00 + -80.367333 43.693500 2247.00 + -80.368850 43.693317 2248.00 + -80.370533 43.693117 2248.00 + -80.372367 43.692817 2248.00 + -80.374183 43.692600 2253.00 + -80.375767 43.692517 2248.00 + -80.377450 43.692317 2229.00 + -80.379383 43.692017 2217.00 + -80.381383 43.691617 2213.00 + -80.383067 43.691167 2222.00 + -80.384517 43.690900 2224.00 + -80.385933 43.690600 2217.00 + -80.387383 43.690300 2211.00 + -80.388767 43.689917 2205.00 + -80.390167 43.689417 2196.00 + -80.391733 43.688967 2189.00 + -80.393350 43.688550 2188.00 + -80.394967 43.688200 2188.00 + -80.396533 43.687967 2185.00 + -80.398150 43.687783 2177.00 + -80.399833 43.687933 2173.00 + -80.401533 43.688150 2162.00 + -80.403333 43.688333 2151.00 + -80.405200 43.688550 2146.00 + -80.407017 43.688750 2144.00 + -80.408817 43.688933 2128.00 + -80.410733 43.689050 2128.00 + -80.412700 43.689217 2113.00 + -80.414783 43.689383 2100.00 + -80.416933 43.689467 2094.00 + -80.419050 43.689550 2085.00 + -80.421250 43.689633 2078.00 + -80.423350 43.689733 2078.00 + -80.425350 43.689800 2074.00 + -80.427233 43.689767 2074.00 + -80.429050 43.689750 2071.00 + -80.430717 43.689817 2072.00 + -80.432267 43.689700 2068.00 + -80.433717 43.689300 2060.00 + -80.435117 43.688617 2059.00 + -80.436383 43.687783 2067.00 + -80.437567 43.686700 2080.00 + -80.437483 43.685500 2099.00 + -80.436067 43.685533 2091.00 + -80.435817 43.686817 2076.00 + -80.436817 43.687933 2096.00 + -80.438267 43.688700 2109.00 + -80.439383 43.688033 2120.00 + -80.438317 43.687400 2122.00 + -80.437967 43.688667 2130.00 + -80.439433 43.689267 2151.00 + -80.440600 43.688600 2154.00 + -80.440100 43.687650 2159.00 + -80.438650 43.687383 2167.00 + -80.437233 43.687717 2188.00 + -80.436233 43.688467 2201.00 + -80.436633 43.689533 2212.00 + -80.437950 43.689933 2220.00 + -80.439050 43.689333 2222.00 + -80.439017 43.688250 2225.00 + -80.438000 43.687433 2237.00 + -80.436633 43.687017 2251.00 + -80.435417 43.687550 2252.00 + -80.435683 43.688650 2257.00 + -80.437017 43.689217 2271.00 + -80.438483 43.689117 2280.00 + -80.439583 43.688383 2283.00 + -80.438783 43.687517 2280.00 + -80.437600 43.688267 2286.00 + -80.437433 43.689500 2293.00 + -80.437600 43.690850 2293.00 + -80.437917 43.692167 2304.00 + -80.438350 43.693350 2312.00 + -80.438733 43.694550 2312.00 + -80.439133 43.695983 2303.00 + -80.439617 43.697583 2285.00 + -80.440233 43.699150 2282.00 + -80.440617 43.700883 2262.00 + -80.440817 43.702817 2240.00 + -80.440933 43.704917 2214.00 + -80.441017 43.707200 2186.00 + -80.441067 43.709483 2184.00 + -80.441067 43.711700 2175.00 + -80.441067 43.713883 2171.00 + -80.441083 43.715967 2173.00 + -80.441100 43.717900 2176.00 + -80.441067 43.719767 2174.00 + -80.441067 43.721600 2164.00 + -80.441033 43.723433 2156.00 + -80.441083 43.725267 2150.00 + -80.441150 43.727050 2152.00 + -80.441150 43.728750 2155.00 + -80.441067 43.730500 2143.00 + -80.441017 43.732283 2128.00 + -80.441083 43.734167 2118.00 + -80.441117 43.736100 2106.00 + -80.441000 43.738000 2096.00 + -80.440817 43.739817 2098.00 + -80.440683 43.741550 2093.00 + -80.440533 43.743333 2085.00 + -80.440433 43.745150 2091.00 + -80.440317 43.746883 2093.00 + -80.440217 43.748583 2089.00 + -80.440150 43.750267 2082.00 + -80.440150 43.752033 2070.00 + -80.440217 43.753917 2061.00 + -80.440117 43.755850 2054.00 + -80.439900 43.757817 2043.00 + -80.439650 43.759833 2029.00 + -80.439483 43.761867 2027.00 + -80.439367 43.763800 2027.00 + -80.439350 43.765900 2019.00 + -80.439267 43.767783 2011.00 + -80.439100 43.769617 2006.00 + -80.438983 43.771417 1993.00 + -80.438883 43.773233 1979.00 + -80.438717 43.775067 1966.00 + -80.438533 43.776933 1955.00 + -80.438350 43.778783 1949.00 + -80.438133 43.780583 1940.00 + -80.437867 43.782433 1926.00 + -80.437667 43.784350 1914.00 + -80.437583 43.786317 1903.00 + -80.437483 43.788283 1902.00 + -80.437350 43.790150 1906.00 + -80.437183 43.791950 1900.00 + -80.437017 43.793750 1893.00 + -80.436817 43.795533 1889.00 + -80.436533 43.797350 1869.00 + -80.435583 43.799100 1863.00 + -80.434467 43.800683 1862.00 + -80.433400 43.802300 1856.00 + -80.432333 43.803950 1849.00 + -80.431200 43.805617 1848.00 + -80.430017 43.807233 1855.00 + -80.428983 43.808717 1865.00 + -80.428033 43.810167 1871.00 + -80.427150 43.811550 1881.00 + -80.426250 43.812900 1889.00 + -80.425233 43.814183 1896.00 + -80.424300 43.815550 1900.00 + -80.423450 43.817000 1897.00 + -80.422700 43.818500 1887.00 + -80.421950 43.820067 1881.00 + -80.421167 43.821667 1879.00 + -80.420417 43.823317 1877.00 + -80.419767 43.825017 1874.00 + -80.418883 43.826717 1866.00 + -80.417900 43.828383 1863.00 + -80.417000 43.830017 1860.00 + -80.416100 43.831617 1852.00 + -80.415233 43.833283 1845.00 + -80.414467 43.835017 1840.00 + -80.414550 43.836550 1870.00 + -80.415967 43.836833 1884.00 + -80.416833 43.836150 1897.00 + -80.416800 43.835167 1899.00 + -80.415950 43.834283 1903.00 + -80.414400 43.833917 1903.00 + -80.412667 43.834267 1902.00 + -80.411367 43.835167 1902.00 + -80.410733 43.836367 1900.00 + -80.410783 43.837583 1902.00 + -80.411483 43.838650 1904.00 + -80.412783 43.839367 1902.00 + -80.414433 43.839783 1898.00 + -80.416150 43.840133 1911.00 + -80.417733 43.840467 1921.00 + -80.419267 43.840283 1936.00 + -80.419700 43.839367 1946.00 + -80.418933 43.838533 1957.00 + -80.417517 43.838117 1967.00 + -80.415950 43.838217 1978.00 + -80.414600 43.838883 1979.00 + -80.414333 43.840017 1983.00 + -80.415367 43.840783 1988.00 + -80.416800 43.840517 1993.00 + -80.417183 43.839533 2008.00 + -80.416300 43.838717 2018.00 + -80.414833 43.838500 2028.00 + -80.413467 43.838967 2031.00 + -80.412833 43.840000 2027.00 + -80.413317 43.841067 2029.00 + -80.414550 43.841783 2037.00 + -80.416017 43.841867 2044.00 + -80.417183 43.841333 2051.00 + -80.417700 43.840383 2059.00 + -80.417550 43.839333 2070.00 + -80.417000 43.838400 2078.00 + -80.415767 43.837800 2078.00 + -80.414150 43.837833 2077.00 + -80.412750 43.838483 2080.00 + -80.412167 43.839567 2083.00 + -80.412483 43.840667 2083.00 + -80.413417 43.841567 2087.00 + -80.414600 43.842400 2087.00 + -80.415950 43.843150 2087.00 + -80.417483 43.844000 2096.00 + -80.418817 43.844833 2112.00 + -80.420317 43.845233 2114.00 + -80.420533 43.844383 2119.00 + -80.419033 43.844117 2124.00 + -80.417350 43.844500 2136.00 + -80.416183 43.845350 2156.00 + -80.416550 43.846433 2165.00 + -80.417950 43.846567 2169.00 + -80.418200 43.845750 2171.00 + -80.416733 43.845333 2184.00 + -80.415317 43.845733 2200.00 + -80.414767 43.846767 2204.00 + -80.415017 43.848000 2206.00 + -80.415400 43.849250 2209.00 + -80.415917 43.850467 2212.00 + -80.416417 43.851667 2212.00 + -80.416967 43.852933 2199.00 + -80.417667 43.854317 2192.00 + -80.418367 43.855717 2196.00 + -80.419183 43.857000 2198.00 + -80.419883 43.858267 2193.00 + -80.420600 43.859600 2188.00 + -80.421333 43.860967 2181.00 + -80.421983 43.862367 2175.00 + -80.422467 43.863733 2177.00 + -80.422983 43.865000 2170.00 + -80.423650 43.866317 2155.00 + -80.424283 43.867767 2140.00 + -80.424950 43.869250 2135.00 + -80.425617 43.870733 2130.00 + -80.426183 43.872350 2123.00 + -80.426633 43.873817 2123.00 + -80.427167 43.875233 2119.00 + -80.427683 43.876683 2116.00 + -80.428050 43.878067 2117.00 + -80.428467 43.879417 2110.00 + -80.428933 43.880800 2102.00 + -80.429400 43.882233 2097.00 + -80.429883 43.883633 2095.00 + -80.430400 43.885017 2090.00 + -80.430900 43.886417 2087.00 + -80.431433 43.887800 2081.00 + -80.432117 43.889183 2071.00 + -80.432817 43.890633 2067.00 + -80.433500 43.892083 2065.00 + -80.434017 43.893567 2069.00 + -80.434433 43.895050 2064.00 + -80.434867 43.896517 2060.00 + -80.435383 43.897967 2050.00 + -80.435917 43.899450 2039.00 + -80.436367 43.900967 2033.00 + -80.436633 43.902383 2057.00 + -80.436700 43.903517 2075.00 + -80.436883 43.904767 2074.00 + -80.437083 43.906000 2081.00 + -80.437267 43.907083 2081.00 + -80.437550 43.908483 2081.00 + -80.437767 43.909767 2078.00 + -80.438000 43.911100 2061.00 + -80.438300 43.912567 2047.00 + -80.438567 43.914083 2039.00 + -80.438867 43.915617 2029.00 + -80.439233 43.917167 2021.00 + -80.439500 43.918733 2009.00 + -80.439800 43.920300 2006.00 + -80.440050 43.921750 2008.00 + -80.440233 43.923150 2004.00 + -80.440367 43.924550 1993.00 + -80.440500 43.926033 1982.00 + -80.440733 43.927533 1972.00 + -80.441083 43.929067 1960.00 + -80.441250 43.930633 1957.00 + -80.440950 43.932067 1968.00 + -80.440467 43.933383 1978.00 + -80.439800 43.934633 1981.00 + -80.439833 43.935900 1996.00 + -80.440867 43.936750 2008.00 + -80.441933 43.936400 2017.00 + -80.441417 43.935550 2021.00 + -80.439950 43.935333 2035.00 + -80.438650 43.935967 2045.00 + -80.438267 43.937133 2049.00 + -80.439083 43.938083 2052.00 + -80.440433 43.938050 2060.00 + -80.441050 43.937250 2066.00 + -80.440567 43.936333 2075.00 + -80.439300 43.935817 2085.00 + -80.437800 43.935650 2092.00 + -80.436283 43.936100 2090.00 + -80.435650 43.937250 2097.00 + -80.435917 43.938383 2101.00 + -80.437033 43.939000 2106.00 + -80.438350 43.939050 2111.00 + -80.439300 43.938517 2120.00 + -80.439433 43.937667 2122.00 + -80.438433 43.936900 2124.00 + -80.436917 43.936967 2137.00 + -80.435867 43.937783 2136.00 + -80.435567 43.939033 2129.00 + -80.435600 43.940333 2131.00 + -80.435900 43.941600 2131.00 + -80.436367 43.942883 2129.00 + -80.436917 43.944183 2128.00 + -80.437550 43.945450 2128.00 + -80.438183 43.946750 2124.00 + -80.438850 43.948033 2122.00 + -80.439650 43.949283 2125.00 + -80.440567 43.950633 2129.00 + -80.441450 43.951867 2132.00 + -80.442367 43.953133 2129.00 + -80.443217 43.954417 2125.00 + -80.443933 43.955667 2120.00 + -80.444650 43.956933 2108.00 + -80.445417 43.958217 2106.00 + -80.446150 43.959533 2096.00 + -80.446917 43.960833 2095.00 + -80.447400 43.962133 2095.00 + -80.447767 43.963417 2083.00 + -80.448250 43.964783 2070.00 + -80.448750 43.966200 2066.00 + -80.449233 43.967533 2069.00 + -80.449750 43.968817 2067.00 + -80.450267 43.970033 2061.00 + -80.450833 43.971333 2044.00 + -80.451617 43.972683 2034.00 + -80.452317 43.974100 2029.00 + -80.453133 43.975500 2022.00 + -80.453967 43.976867 2022.00 + -80.454783 43.978217 2022.00 + -80.455600 43.979500 2022.00 + -80.456467 43.980683 2021.00 + -80.457317 43.981900 2009.00 + -80.458150 43.983133 2005.00 + -80.458950 43.984350 2000.00 + -80.459767 43.985583 1989.00 + -80.460617 43.986867 1977.00 + -80.461417 43.988150 1970.00 + -80.462217 43.989317 1969.00 + -80.463150 43.990433 1956.00 + -80.464183 43.991567 1952.00 + -80.465217 43.992717 1948.00 + -80.466183 43.993883 1943.00 + -80.467200 43.995050 1928.00 + -80.468267 43.996267 1910.00 + -80.469367 43.997617 1895.00 + -80.470500 43.999000 1880.00 + -80.471600 44.000433 1869.00 + -80.472633 44.001883 1858.00 + -80.473717 44.003317 1850.00 + -80.474700 44.004767 1843.00 + -80.475683 44.006233 1834.00 + -80.476600 44.007700 1826.00 + -80.477517 44.009133 1817.00 + -80.478483 44.010517 1820.00 + -80.479333 44.011733 1831.00 + -80.480283 44.012867 1831.00 + -80.481350 44.014033 1834.00 + -80.482483 44.015183 1843.00 + -80.483600 44.016367 1855.00 + -80.483317 44.017867 1868.00 + -80.481683 44.018667 1877.00 + -80.480350 44.018050 1886.00 + -80.481067 44.017133 1892.00 + -80.482917 44.017283 1907.00 + -80.484033 44.018467 1929.00 + -80.483567 44.019867 1942.00 + -80.482067 44.020433 1952.00 + -80.481000 44.019783 1961.00 + -80.481600 44.018800 1967.00 + -80.483317 44.018867 1982.00 + -80.483833 44.020167 2004.00 + -80.482533 44.021067 2009.00 + -80.481183 44.020733 2015.00 + -80.481417 44.019850 2027.00 + -80.482783 44.019450 2034.00 + -80.484267 44.020300 2038.00 + -80.484067 44.021917 2036.00 + -80.482267 44.022700 2043.00 + -80.480933 44.022317 2068.00 + -80.480133 44.021600 2075.00 + -80.479417 44.020783 2087.00 + -80.479017 44.019917 2091.00 + -80.479917 44.019183 2087.00 + -80.481550 44.019483 2094.00 + -80.482700 44.020600 2103.00 + -80.483233 44.021967 2111.00 + -80.482517 44.023283 2117.00 + -80.480950 44.023783 2120.00 + -80.480100 44.023200 2134.00 + -80.481017 44.022600 2131.00 + -80.482667 44.022750 2136.00 + -80.484150 44.023533 2146.00 + -80.485333 44.024600 2148.00 + -80.486433 44.025783 2145.00 + -80.487517 44.026917 2138.00 + -80.488650 44.027950 2136.00 + -80.489733 44.029000 2129.00 + -80.490867 44.030117 2116.00 + -80.490700 44.031483 2108.00 + -80.489133 44.031717 2099.00 + -80.488350 44.030783 2088.00 + -80.487733 44.029650 2071.00 + -80.487133 44.028383 2062.00 + -80.486533 44.026967 2040.00 + -80.485917 44.025367 2022.00 + -80.485350 44.023717 2027.00 + -80.484900 44.022083 2028.00 + -80.484417 44.020517 2030.00 + -80.483933 44.018950 2029.00 + -80.483433 44.017433 2035.00 + -80.482917 44.015867 2037.00 + -80.482483 44.014250 2031.00 + -80.482000 44.012600 2019.00 + -80.481433 44.010950 2009.00 + -80.480783 44.009300 2001.00 + -80.480117 44.007650 1991.00 + -80.479450 44.005950 1977.00 + -80.478833 44.004217 1967.00 + -80.478217 44.002467 1956.00 + -80.477567 44.000683 1948.00 + -80.476900 43.998933 1946.00 + -80.476217 43.997183 1935.00 + -80.475617 43.995433 1929.00 + -80.475100 43.993717 1922.00 + -80.474567 43.992017 1911.00 + -80.473983 43.990317 1900.00 + -80.473483 43.988600 1892.00 + -80.473067 43.986883 1880.00 + -80.472633 43.985133 1866.00 + -80.472217 43.983417 1857.00 + -80.471883 43.981717 1845.00 + -80.471550 43.980033 1827.00 + -80.471183 43.978350 1813.00 + -80.470867 43.976633 1793.00 + -80.470417 43.974950 1786.00 + -80.469833 43.973117 1779.00 + -80.469183 43.971483 1775.00 + -80.468600 43.969833 1774.00 + -80.468067 43.968183 1771.00 + -80.467483 43.966483 1758.00 + -80.466867 43.964767 1749.00 + -80.466267 43.963100 1736.00 + -80.465717 43.961433 1722.00 + -80.465183 43.959783 1703.00 + -80.464617 43.958100 1685.00 + -80.464133 43.956400 1674.00 + -80.463783 43.954700 1664.00 + -80.463417 43.952983 1650.00 + -80.463033 43.951233 1642.00 + -80.462667 43.949483 1639.00 + -80.462250 43.947767 1634.00 + -80.461850 43.945983 1632.00 + -80.461467 43.944217 1639.00 + -80.461133 43.942483 1644.00 + -80.460783 43.940750 1642.00 + -80.460483 43.939017 1633.00 + -80.460200 43.937283 1628.00 + -80.459933 43.935550 1620.00 + -80.459633 43.933767 1606.00 + -80.459317 43.931950 1598.00 + -80.458950 43.930117 1590.00 + -80.458567 43.928283 1583.00 + -80.458133 43.926467 1587.00 + -80.457683 43.924733 1581.00 + -80.457267 43.923017 1575.00 + -80.456917 43.921317 1565.00 + -80.456533 43.919633 1551.00 + -80.456183 43.917933 1538.00 + -80.455817 43.916267 1520.00 + -80.455400 43.914567 1509.00 + -80.455067 43.912900 1497.00 + -80.454900 43.911283 1486.00 + -80.454733 43.909650 1464.00 + -80.454517 43.908017 1453.00 + -80.454383 43.906383 1447.00 + -80.454233 43.904767 1430.00 + -80.454033 43.902933 1408.00 + -80.453783 43.900950 1383.00 + -80.453517 43.898933 1370.00 + -80.453217 43.896983 1357.00 + -80.452867 43.895083 1349.00 + -80.452533 43.893200 1332.00 + -80.452217 43.891300 1319.00 + -80.451983 43.889383 1310.00 + -80.451767 43.887483 1300.00 + -80.451567 43.885533 1300.00 + -80.451367 43.883650 1303.00 + -80.451150 43.881833 1303.00 + -80.450833 43.880033 1295.00 + -80.450400 43.878250 1282.00 + -80.449850 43.876450 1271.00 + -80.449300 43.874617 1254.00 + -80.448950 43.872667 1241.00 + -80.448750 43.870633 1235.00 + -80.448717 43.868600 1232.00 + -80.448750 43.866567 1230.00 + -80.448800 43.864583 1226.00 + -80.448883 43.862600 1217.00 + -80.449067 43.860683 1213.00 + -80.449450 43.858883 1210.00 + -80.450083 43.857167 1202.00 + -80.450900 43.855517 1197.00 + -80.451850 43.853967 1191.00 + -80.452817 43.852467 1184.00 + -80.453533 43.850983 1180.00 + -80.454167 43.849367 1177.00 + -80.454617 43.847900 1167.00 + -80.455050 43.846350 1156.00 + -80.455317 43.844733 1145.00 + -80.455333 43.843067 1138.00 + -80.455217 43.841450 1142.00 + -80.455067 43.839950 1145.00 + -80.454850 43.838517 1149.00 + -80.454583 43.837267 1153.00 + -80.454167 43.836083 1138.00 + -80.453483 43.834967 1132.00 + -80.452700 43.833900 1119.00 + -80.451717 43.832800 1107.00 + -80.450633 43.831667 1099.00 + -80.449400 43.830550 1081.00 + -80.448217 43.829417 1065.00 + -80.447017 43.828350 1049.00 + -80.445867 43.827350 1043.00 + -80.444683 43.826433 1021.00 + -80.443350 43.825600 997.00 + -80.441833 43.824883 972.00 + -80.440083 43.824383 952.00 + -80.438200 43.824050 933.00 + -80.436283 43.823900 915.00 + -80.434350 43.824083 900.00 + -80.432483 43.824517 885.00 + -80.430700 43.825133 867.00 + -80.428983 43.825817 846.00 + -80.427300 43.826550 830.00 + -80.425733 43.827333 814.00 + -80.424217 43.828167 799.00 + -80.422750 43.829083 783.00 + -80.421333 43.830050 762.00 + -80.420200 43.831217 746.00 + -80.419800 43.832567 736.00 + -80.420200 43.833850 723.00 + -80.421250 43.834967 711.00 + -80.422550 43.835967 699.00 + -80.423917 43.836917 691.00 + -80.425367 43.837883 680.00 + -80.426800 43.838917 662.00 + -80.428100 43.840067 648.00 + -80.429167 43.841300 636.00 + -80.430033 43.842617 629.00 + -80.430733 43.844033 623.00 + -80.431250 43.845567 622.00 + -80.431583 43.847067 618.00 + -80.431950 43.848550 609.00 + -80.432533 43.849917 603.00 + -80.433750 43.850917 596.00 + -80.435317 43.851267 586.00 + -80.436950 43.851283 574.00 + -80.438617 43.851017 558.00 + -80.440267 43.850617 543.00 + -80.441800 43.850050 529.00 + -80.443267 43.849383 511.00 + -80.444617 43.848583 496.00 + -80.445483 43.847517 484.00 + -80.445250 43.846283 472.00 + -80.444717 43.845050 459.00 + -80.444150 43.843833 451.00 + -80.443633 43.842650 444.00 + -80.443167 43.841567 443.00 + -80.442850 43.840800 443.00 + -80.442750 43.840550 443.00 + -80.442750 43.840550 443.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840567 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442750 43.840550 444.00 + -80.442733 43.840533 444.00 + -80.442700 43.840483 444.00 + -80.442650 43.840433 445.00 + -80.442583 43.840383 444.00 + -80.442517 43.840317 444.00 + -80.442450 43.840267 444.00 + -80.442383 43.840200 444.00 + -80.442300 43.840150 444.00 + -80.442233 43.840117 444.00 + -80.442200 43.840067 444.00 + -80.442167 43.840017 444.00 + -80.442117 43.839983 444.00 + -80.442067 43.839933 444.00 + -80.442033 43.839900 444.00 + -80.441983 43.839850 444.00 + -80.441933 43.839817 444.00 + -80.441883 43.839767 444.00 + -80.441833 43.839733 444.00 + -80.441767 43.839683 444.00 + -80.441717 43.839650 444.00 + -80.441650 43.839617 444.00 + -80.441600 43.839567 444.00 + -80.441533 43.839533 444.00 + -80.441500 43.839483 444.00 + -80.441433 43.839450 444.00 + -80.441350 43.839400 444.00 + -80.441317 43.839367 444.00 + -80.441250 43.839317 444.00 + -80.441200 43.839283 444.00 + -80.441150 43.839250 444.00 + -80.441100 43.839200 444.00 + -80.441067 43.839167 443.00 + -80.441017 43.839133 443.00 + -80.440967 43.839083 444.00 + -80.440933 43.839050 443.00 + -80.440883 43.839017 443.00 + -80.440817 43.838983 443.00 + -80.440767 43.838933 443.00 + -80.440700 43.838900 443.00 + -80.440667 43.838867 443.00 + -80.440617 43.838817 444.00 + -80.440533 43.838767 444.00 + -80.440483 43.838733 444.00 + -80.440433 43.838700 443.00 + -80.440383 43.838650 444.00 + -80.440333 43.838600 444.00 + -80.440267 43.838567 443.00 + -80.440233 43.838533 443.00 + -80.440183 43.838483 444.00 + -80.440117 43.838450 444.00 + -80.440083 43.838417 443.00 + -80.440033 43.838383 443.00 + -80.439983 43.838350 444.00 + -80.439950 43.838300 443.00 + -80.439883 43.838267 444.00 + -80.439850 43.838233 444.00 + -80.439800 43.838183 444.00 + -80.439750 43.838150 444.00 + -80.439717 43.838117 444.00 + -80.439683 43.838083 444.00 + -80.439617 43.838050 443.00 + -80.439567 43.838000 443.00 + -80.439517 43.837967 444.00 + -80.439483 43.837933 443.00 + -80.439433 43.837900 443.00 + -80.439367 43.837867 444.00 + -80.439317 43.837817 444.00 + -80.439250 43.837783 443.00 + -80.439200 43.837733 443.00 + -80.439150 43.837700 443.00 + -80.439100 43.837667 443.00 + -80.439050 43.837633 443.00 + -80.439000 43.837600 443.00 + -80.438950 43.837550 443.00 + -80.438900 43.837517 443.00 + -80.438833 43.837483 443.00 + -80.438783 43.837450 443.00 + + + + 0 + 0 + 0 + 0.46 + 0.76 + 0.96 + 1.12 + 1.11 + 1.08 + 1.01 + 1.03 + 1.01 + 0.97 + 1 + 0.97 + 0.95 + 0.99 + 1.03 + 1.02 + 1.03 + 1.03 + 1.01 + 1.07 + 1.12 + 1.22 + 1.31 + 1.26 + 1.28 + 1.22 + 1.19 + 1.21 + 1.15 + 1.12 + 1.08 + 1.03 + 1.03 + 1.04 + 0.98 + 0.97 + 0.95 + 0.97 + 1.02 + 0.99 + 1 + 1 + 1.02 + 1.12 + 1.17 + 1.27 + 1.29 + 1.36 + 1.4 + 1.38 + 1.36 + 1.33 + 1.28 + 1.21 + 1.17 + 1.18 + 1.15 + 1.1 + 1.09 + 1.14 + 1.19 + 1.18 + 1.19 + 1.16 + 1.13 + 1.15 + 1.1 + 1.09 + 1.14 + 1.21 + 1.31 + 1.26 + 1.08 + 0.97 + 0.95 + 0.93 + 0.88 + 0.82 + 0.83 + 0.87 + 0.88 + 0.9 + 0.88 + 0.89 + 0.91 + 0.79 + 0.82 + 0.88 + 0.87 + 0.85 + 0.81 + 0.82 + 0.77 + 0.81 + 0.84 + 0.87 + 0.85 + 0.74 + 0.79 + 0.81 + 0.83 + 0.88 + 0.89 + 0.83 + 0.86 + 0.78 + 0.79 + 0.88 + 0.91 + 0.91 + 0.9 + 0.84 + 0.8 + 0.97 + 0.98 + 0.97 + 0.92 + 0.85 + 0.87 + 0.94 + 0.97 + 0.93 + 0.87 + 0.85 + 0.8 + 0.92 + 0.9 + 0.86 + 0.84 + 0.81 + 0.76 + 0.88 + 0.91 + 0.89 + 0.85 + 0.9 + 0.89 + 0.89 + 0.95 + 0.93 + 0.91 + 0.85 + 0.83 + 0.83 + 0.77 + 0.83 + 0.88 + 0.93 + 0.9 + 0.89 + 0.79 + 0.75 + 0.75 + 0.93 + 0.83 + 0.96 + 0.89 + 0.79 + 0.81 + 0.87 + 0.95 + 0.96 + 0.88 + 0.77 + 0.84 + 0.86 + 0.96 + 0.94 + 0.85 + 0.78 + 0.87 + 0.85 + 0.93 + 0.9 + 0.88 + 0.85 + 0.84 + 0.86 + 0.85 + 0.93 + 1 + 0.94 + 0.9 + 0.87 + 0.85 + 0.86 + 0.99 + 1.03 + 1.11 + 1.2 + 1.26 + 1.2 + 0.82 + 0.8 + 1.04 + 1.17 + 1.2 + 1.24 + 1.26 + 1.28 + 1.3 + 1.3 + 0.87 + 0.97 + 0.99 + 1.13 + 1.23 + 1.27 + 1.3 + 1.35 + 1.39 + 1.38 + 1.35 + 1.14 + 1.15 + 1.34 + 1.36 + 1.29 + 1.22 + 1.17 + 1.16 + 1.14 + 1.16 + 1.15 + 1.17 + 1.07 + 0.9 + 0.86 + 0.99 + 1.1 + 1.15 + 1.19 + 1.24 + 1.24 + 1.17 + 1.16 + 1.19 + 1.24 + 1.29 + 1.32 + 1.32 + 1.24 + 1.22 + 1.19 + 1.19 + 1.24 + 1.29 + 1.35 + 1.39 + 1.39 + 1.36 + 1.34 + 1.32 + 1.31 + 1.37 + 1.39 + 1.41 + 1.38 + 1.38 + 1.36 + 1.38 + 1.41 + 1.41 + 1.43 + 1.48 + 1.48 + 1.4 + 1.33 + 1.34 + 1.39 + 1.42 + 1.4 + 1.32 + 1.27 + 1.28 + 1.34 + 1.41 + 1.41 + 1.38 + 1.3 + 1.12 + 1 + 0.96 + 0.92 + 0.96 + 0.95 + 0.97 + 0.95 + 0.96 + 1.01 + 1.07 + 1.08 + 1.03 + 1 + 0.98 + 1.01 + 1.05 + 1.04 + 1.02 + 0.98 + 0.99 + 0.97 + 0.99 + 1.05 + 0.94 + 0.83 + 0.75 + 0.7 + 0.78 + 0.84 + 0.86 + 0.96 + 0.94 + 0.99 + 0.94 + 0.91 + 0.84 + 0.93 + 0.95 + 1.01 + 0.9 + 0.85 + 0.98 + 0.96 + 0.99 + 0.95 + 0.81 + 0.77 + 0.81 + 1.06 + 1 + 0.82 + 0.79 + 0.88 + 0.96 + 0.97 + 0.98 + 0.91 + 0.77 + 0.87 + 0.89 + 0.92 + 1.04 + 0.9 + 0.88 + 0.83 + 0.88 + 0.93 + 0.98 + 0.94 + 0.78 + 0.79 + 0.79 + 0.88 + 0.95 + 0.87 + 0.96 + 0.89 + 0.89 + 0.87 + 0.83 + 0.9 + 0.9 + 0.96 + 0.99 + 0.96 + 0.97 + 0.89 + 0.84 + 0.84 + 0.89 + 0.95 + 0.95 + 1.04 + 0.88 + 0.86 + 0.88 + 0.81 + 0.82 + 0.88 + 0.86 + 0.93 + 1.04 + 1.11 + 0.99 + 0.91 + 1.07 + 1.19 + 1.16 + 0.94 + 0.84 + 0.86 + 0.86 + 0.86 + 0.94 + 1 + 0.98 + 0.95 + 0.92 + 0.96 + 0.98 + 1.01 + 1.08 + 1.08 + 1.05 + 1.08 + 1.12 + 1.18 + 1.25 + 1.22 + 1.25 + 1.25 + 1.18 + 1.12 + 1.06 + 1.03 + 0.92 + 0.89 + 0.93 + 0.98 + 1.03 + 1.14 + 0.93 + 0.91 + 1.08 + 1.07 + 1.04 + 0.92 + 1.01 + 1.11 + 0.95 + 0.89 + 0.85 + 0.87 + 0.86 + 0.9 + 0.9 + 0.83 + 0.86 + 0.9 + 0.88 + 0.86 + 0.91 + 0.95 + 0.88 + 0.88 + 0.92 + 0.99 + 0.97 + 1.02 + 1.1 + 1.02 + 0.95 + 1.07 + 1.24 + 1.29 + 1.34 + 1.47 + 1.61 + 1.74 + 1.86 + 1.79 + 1.76 + 1.71 + 1.61 + 1.51 + 1.46 + 1.47 + 1.46 + 1.45 + 1.4 + 1.36 + 1.4 + 1.46 + 1.52 + 1.54 + 1.49 + 1.39 + 1.42 + 1.44 + 1.42 + 1.37 + 1.34 + 1.37 + 1.46 + 1.53 + 1.56 + 1.59 + 1.64 + 1.58 + 1.52 + 1.51 + 1.5 + 1.44 + 1.43 + 1.46 + 1.49 + 1.48 + 1.47 + 1.45 + 1.5 + 1.56 + 1.58 + 1.54 + 1.44 + 1.44 + 1.44 + 1.42 + 1.51 + 1.44 + 1.41 + 1.43 + 1.48 + 1.48 + 1.4 + 1.3 + 1.25 + 1.2 + 1.18 + 1.19 + 1.23 + 1.27 + 1.29 + 1.34 + 1.38 + 1.39 + 1.41 + 1.47 + 1.43 + 1.38 + 1.39 + 1.43 + 1.45 + 1.06 + 0.82 + 0.74 + 0.84 + 0.89 + 1.01 + 1.06 + 1.04 + 1.02 + 0.95 + 0.94 + 0.94 + 1.05 + 0.99 + 0.94 + 0.87 + 0.79 + 0.84 + 0.9 + 0.93 + 0.97 + 0.9 + 0.89 + 0.87 + 0.83 + 0.86 + 0.88 + 0.9 + 0.9 + 0.93 + 0.9 + 0.82 + 0.79 + 0.84 + 0.83 + 0.82 + 0.92 + 0.96 + 0.95 + 0.91 + 0.89 + 0.93 + 0.97 + 0.98 + 1.02 + 1.01 + 0.89 + 0.79 + 1.01 + 1.01 + 0.95 + 0.94 + 0.75 + 0.85 + 0.93 + 0.89 + 0.94 + 1.02 + 1.02 + 0.99 + 1 + 1.13 + 1.21 + 1.16 + 1.09 + 1.12 + 1.15 + 1.18 + 1.17 + 1.06 + 1.08 + 1.16 + 1.24 + 1.24 + 1.23 + 1.23 + 1.16 + 1.19 + 1.17 + 1.09 + 1.12 + 1.16 + 1.16 + 1.15 + 1.16 + 1.15 + 1.14 + 1.2 + 1.23 + 1.23 + 1.21 + 1.22 + 1.18 + 1.21 + 1.23 + 1.22 + 1.05 + 0.9 + 1.03 + 0.96 + 1.01 + 1.04 + 1.01 + 1.13 + 1.21 + 1.23 + 1.25 + 1.26 + 1.26 + 1.24 + 1.12 + 1.11 + 1.14 + 1.2 + 1.22 + 1.25 + 1.23 + 1.11 + 1.07 + 1.05 + 0.99 + 0.86 + 0.71 + 0.86 + 0.91 + 0.94 + 0.97 + 0.88 + 0.78 + 0.77 + 0.82 + 0.86 + 0.89 + 1.02 + 0.98 + 0.88 + 0.8 + 0.75 + 0.66 + 0.76 + 0.92 + 0.88 + 0.96 + 1.05 + 1.02 + 1.03 + 1.08 + 1.06 + 1.1 + 1.09 + 1.1 + 1.09 + 1.09 + 1.12 + 1.14 + 1.12 + 1.08 + 1.1 + 1.11 + 1.14 + 1.12 + 1.01 + 1.08 + 1.16 + 1.16 + 1.08 + 1.02 + 1.03 + 1.13 + 1.19 + 1.2 + 1.21 + 1.19 + 1.15 + 1.09 + 1.06 + 1.09 + 1.09 + 1.08 + 1.11 + 1.13 + 1.1 + 1 + 1.07 + 1.09 + 1.08 + 1.08 + 1.11 + 1.2 + 1.27 + 1.3 + 1.31 + 1.3 + 1.29 + 1.3 + 1.3 + 1.27 + 1.26 + 1.16 + 1.05 + 1.08 + 1.12 + 1.12 + 1.21 + 1.24 + 1.11 + 0.89 + 1 + 1.13 + 1.19 + 1.11 + 0.9 + 0.79 + 0.95 + 1.11 + 1.15 + 0.98 + 0.78 + 0.78 + 0.97 + 1.27 + 1.36 + 1.06 + 0.73 + 0.76 + 0.74 + 0.77 + 0.91 + 1.06 + 1.12 + 1.14 + 1.13 + 0.91 + 0.65 + 0.89 + 1.04 + 1.07 + 1.12 + 1.11 + 1.08 + 1.03 + 1.05 + 1.16 + 1.13 + 0.9 + 0.9 + 1.01 + 1.11 + 1.24 + 1.36 + 1.34 + 1.31 + 1.28 + 1.26 + 1.25 + 1.3 + 1.32 + 1.35 + 1.36 + 1.37 + 1.37 + 1.42 + 1.44 + 1.45 + 1.47 + 1.44 + 1.45 + 1.42 + 1.39 + 1.39 + 1.4 + 1.39 + 1.4 + 1.42 + 1.38 + 1.36 + 1.36 + 1.37 + 1.38 + 1.36 + 1.36 + 1.36 + 1.35 + 1.36 + 1.42 + 1.39 + 1.36 + 1.36 + 1.37 + 1.38 + 1.38 + 1.37 + 1.4 + 1.41 + 1.4 + 1.41 + 1.43 + 1.41 + 1.39 + 1.4 + 1.4 + 1.39 + 1.4 + 1.45 + 1.47 + 1.48 + 1.49 + 1.44 + 1.41 + 1.37 + 1.36 + 1.37 + 1.35 + 1.37 + 1.37 + 1.32 + 1.29 + 1.31 + 1.31 + 1.29 + 1.35 + 1.53 + 1.63 + 1.59 + 1.55 + 1.51 + 1.51 + 1.54 + 1.52 + 1.54 + 1.53 + 1.49 + 1.45 + 1.44 + 1.46 + 1.47 + 1.54 + 1.6 + 1.63 + 1.63 + 1.6 + 1.58 + 1.57 + 1.48 + 1.44 + 1.41 + 1.37 + 1.34 + 1.28 + 1.23 + 1.2 + 1.22 + 1.27 + 1.32 + 1.33 + 1.24 + 1.18 + 1.1 + 0.97 + 0.98 + 0.93 + 1.01 + 1.07 + 1.1 + 1.18 + 1.11 + 1.09 + 1 + 1.01 + 1.03 + 1.07 + 1.09 + 1.11 + 1.12 + 1.12 + 1.13 + 1.15 + 1.14 + 1.1 + 1.1 + 1.11 + 1.11 + 1.13 + 1.15 + 1.08 + 1.07 + 1.07 + 1.09 + 1.11 + 1.15 + 1.18 + 1.17 + 1.16 + 1.16 + 1.23 + 1.25 + 1.2 + 1.18 + 1.12 + 1.02 + 0.94 + 0.95 + 1 + 1 + 0.99 + 0.99 + 1.01 + 0.98 + 1.01 + 1.03 + 1.01 + 0.95 + 0.85 + 0.38 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0.01 + 0.06 + 0.06 + 0.05 + 0.06 + 0.05 + 0.07 + 0.06 + 0.02 + 0.04 + 0.04 + 0.03 + 0.04 + 0.04 + 0.04 + 0.04 + 0.04 + 0.04 + 0.05 + 0.05 + 0.04 + 0.05 + 0.02 + 0.02 + 0.03 + 0.05 + 0.05 + 0.04 + 0.02 + 0.04 + 0.03 + 0.04 + 0.04 + 0.03 + 0.04 + 0.04 + 0.04 + 0.04 + 0.04 + 0.05 + 0.05 + 0.04 + 0.03 + 0.03 + 0.05 + 0.05 + 0.04 + 0.04 + 0.04 + 0.04 + 0.02 + 0.02 + 0.04 + 0.02 + 0.03 + 0.03 + 0.04 + 0.04 + 0.03 + 0.03 + 0.05 + 0.04 + 0.04 + 0.04 + 0.03 + 0.03 + 0.04 + 0.05 + 0.05 + 0.04 + 0.04 + 0.04 + 0.04 + 0.03 + 0.03 + 0.04 + 0.04 + + + 9 + 9 + 9 + 9 + 8 + 9 + 13 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 8 + 9 + 9 + 11 + 10 + 11 + 9 + 10 + 10 + 9 + 9 + 8 + 10 + 10 + 9 + 10 + 11 + 8 + 9 + 8 + 10 + 10 + 9 + 8 + 10 + 9 + 9 + 9 + 10 + 9 + 10 + 10 + 8 + 10 + 10 + 10 + 10 + 9 + 10 + 8 + 7 + 11 + 10 + 11 + 9 + 8 + 8 + 10 + 10 + 10 + 7 + 10 + 8 + 11 + 15 + 9 + 8 + 9 + 10 + 11 + 10 + 9 + 9 + 9 + 10 + 9 + 8 + 10 + 11 + 11 + 10 + 10 + 10 + 10 + 10 + 10 + 11 + 10 + 11 + 10 + 9 + 10 + 11 + 10 + 9 + 11 + 10 + 10 + 10 + 10 + 11 + 9 + 10 + 10 + 10 + 10 + 12 + 9 + 10 + 10 + 10 + 10 + 11 + 10 + 12 + 11 + 10 + 10 + 11 + 10 + 10 + 11 + 11 + 9 + 10 + 9 + 10 + 9 + 10 + 10 + 10 + 11 + 9 + 9 + 10 + 10 + 9 + 10 + 11 + 10 + 10 + 10 + 11 + 10 + 10 + 9 + 12 + 9 + 11 + 10 + 10 + 11 + 11 + 10 + 11 + 11 + 9 + 13 + 10 + 10 + 10 + 11 + 9 + 13 + 9 + 11 + 10 + 9 + 8 + 11 + 11 + 8 + 10 + 10 + 10 + 11 + 12 + 11 + 10 + 12 + 8 + 9 + 9 + 10 + 15 + 10 + 8 + 10 + 9 + 9 + 9 + 9 + 10 + 8 + 12 + 5 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 11 + 8 + 8 + 9 + 10 + 10 + 10 + 9 + 9 + 9 + 11 + 9 + 10 + 7 + 9 + 8 + 9 + 10 + 9 + 10 + 11 + 10 + 8 + 9 + 9 + 9 + 9 + 8 + 10 + 7 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 8 + 8 + 8 + 8 + 11 + 8 + 10 + 10 + 8 + 9 + 8 + 7 + 8 + 12 + 10 + 9 + 9 + 8 + 9 + 10 + 9 + 8 + 8 + 8 + 9 + 9 + 11 + 9 + 8 + 9 + 9 + 10 + 11 + 9 + 10 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 11 + 13 + 10 + 11 + 11 + 10 + 10 + 9 + 9 + 9 + 9 + 12 + 10 + 11 + 11 + 8 + 11 + 11 + 11 + 13 + 9 + 12 + 13 + 10 + 10 + 11 + 11 + 11 + 9 + 14 + 11 + 10 + 12 + 11 + 10 + 10 + 9 + 10 + 9 + 12 + 10 + 9 + 13 + 8 + 11 + 10 + 10 + 10 + 11 + 12 + 10 + 11 + 9 + 10 + 10 + 8 + 12 + 8 + 9 + 10 + 12 + 11 + 9 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 9 + 9 + 12 + 10 + 10 + 10 + 9 + 9 + 10 + 8 + 10 + 9 + 10 + 8 + 9 + 10 + 9 + 11 + 9 + 9 + 9 + 9 + 8 + 10 + 10 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 10 + 11 + 10 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 10 + 9 + 10 + 9 + 10 + 10 + 8 + 11 + 11 + 11 + 9 + 13 + 13 + 16 + 11 + 10 + 12 + 11 + 11 + 8 + 12 + 10 + 9 + 10 + 10 + 10 + 10 + 11 + 9 + 9 + 9 + 12 + 15 + 10 + 10 + 9 + 8 + 9 + 10 + 8 + 7 + 10 + 10 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 7 + 9 + 9 + 9 + 8 + 9 + 9 + 10 + 10 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 10 + 8 + 9 + 10 + 10 + 9 + 9 + 9 + 9 + 10 + 9 + 10 + 8 + 9 + 9 + 8 + 11 + 7 + 8 + 9 + 10 + 9 + 10 + 9 + 9 + 9 + 10 + 10 + 9 + 9 + 11 + 9 + 8 + 9 + 8 + 9 + 8 + 10 + 9 + 9 + 9 + 11 + 12 + 9 + 9 + 10 + 10 + 10 + 9 + 10 + 9 + 10 + 8 + 10 + 9 + 11 + 9 + 10 + 9 + 9 + 9 + 10 + 10 + 10 + 11 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 9 + 9 + 9 + 9 + 10 + 10 + 9 + 9 + 10 + 9 + 10 + 9 + 9 + 9 + 14 + 11 + 9 + 9 + 10 + 12 + 11 + 13 + 10 + 10 + 9 + 9 + 9 + 9 + 8 + 9 + 10 + 10 + 8 + 10 + 8 + 9 + 10 + 8 + 9 + 10 + 9 + 9 + 10 + 10 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 8 + 10 + 10 + 11 + 11 + 9 + 10 + 8 + 10 + 9 + 8 + 9 + 9 + 10 + 9 + 9 + 10 + 10 + 8 + 9 + 9 + 9 + 9 + 9 + 10 + 8 + 9 + 12 + 10 + 11 + 11 + 11 + 11 + 9 + 10 + 10 + 9 + 10 + 10 + 9 + 9 + 11 + 9 + 10 + 8 + 10 + 9 + 10 + 11 + 9 + 10 + 10 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 8 + 9 + 8 + 9 + 10 + 11 + 9 + 9 + 10 + 8 + 9 + 10 + 10 + 9 + 8 + 9 + 10 + 10 + 9 + 10 + 9 + 9 + 10 + 8 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 10 + 9 + 10 + 10 + 8 + 10 + 10 + 10 + 13 + 11 + 11 + 12 + 11 + 9 + 8 + 10 + 11 + 9 + 10 + 13 + 12 + 11 + 11 + 9 + 11 + 11 + 12 + 12 + 8 + 10 + 9 + 10 + 11 + 11 + 10 + 9 + 9 + 12 + 10 + 11 + 10 + 8 + 8 + 9 + 9 + 9 + 9 + 12 + 12 + 12 + 9 + 9 + 9 + 9 + 10 + 8 + 9 + 9 + 11 + 9 + 10 + 10 + 8 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 10 + 10 + 9 + 9 + 11 + 9 + 9 + 10 + 8 + 9 + 9 + 9 + 10 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 11 + 8 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 11 + 8 + 9 + 9 + 9 + 8 + 8 + 10 + 6 + 9 + 9 + 10 + 10 + 9 + 10 + 7 + 9 + 9 + 10 + 8 + 9 + 10 + 8 + 11 + 10 + 8 + 9 + 9 + 9 + 7 + 9 + 9 + 10 + 10 + 9 + 10 + 9 + 8 + 9 + 10 + 9 + 9 + 10 + 8 + 8 + 9 + 9 + 10 + 9 + 8 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 5 + 9 + 9 + 10 + 7 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 10 + 11 + 9 + 9 + 9 + 8 + 9 + 10 + 9 + 9 + 9 + 8 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 10 + 11 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 8 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 10 + 10 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + + + 12 + 12 + 12 + 12 + 12 + 12 + 12 + 12 + 12 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 9 + 10 + 9 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 12 + 12 + 12 + 12 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 10 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + + + + + + + GNSSALTTRK + #multiTrack + + absolute + 2022-07-16T19:41:31Z + 2022-07-16T19:41:46Z + 2022-07-16T19:42:01Z + 2022-07-16T19:42:16Z + 2022-07-16T19:42:22Z + 2022-07-16T19:42:27Z + 2022-07-16T19:42:32Z + 2022-07-16T19:42:37Z + 2022-07-16T19:42:42Z + 2022-07-16T19:42:47Z + 2022-07-16T19:42:52Z + 2022-07-16T19:42:57Z + 2022-07-16T19:43:02Z + 2022-07-16T19:43:07Z + 2022-07-16T19:43:13Z + 2022-07-16T19:43:17Z + 2022-07-16T19:43:22Z + 2022-07-16T19:43:27Z + 2022-07-16T19:43:32Z + 2022-07-16T19:43:38Z + 2022-07-16T19:43:42Z + 2022-07-16T19:43:47Z + 2022-07-16T19:43:52Z + 2022-07-16T19:43:58Z + 2022-07-16T19:44:03Z + 2022-07-16T19:44:08Z + 2022-07-16T19:44:13Z + 2022-07-16T19:44:18Z + 2022-07-16T19:44:23Z + 2022-07-16T19:44:28Z + 2022-07-16T19:44:33Z + 2022-07-16T19:44:38Z + 2022-07-16T19:44:43Z + 2022-07-16T19:44:48Z + 2022-07-16T19:44:53Z + 2022-07-16T19:44:58Z + 2022-07-16T19:45:03Z + 2022-07-16T19:45:08Z + 2022-07-16T19:45:13Z + 2022-07-16T19:45:18Z + 2022-07-16T19:45:23Z + 2022-07-16T19:45:28Z + 2022-07-16T19:45:33Z + 2022-07-16T19:45:38Z + 2022-07-16T19:45:43Z + 2022-07-16T19:45:48Z + 2022-07-16T19:45:53Z + 2022-07-16T19:45:58Z + 2022-07-16T19:46:03Z + 2022-07-16T19:46:08Z + 2022-07-16T19:46:13Z + 2022-07-16T19:46:18Z + 2022-07-16T19:46:23Z + 2022-07-16T19:46:28Z + 2022-07-16T19:46:33Z + 2022-07-16T19:46:38Z + 2022-07-16T19:46:43Z + 2022-07-16T19:46:48Z + 2022-07-16T19:46:53Z + 2022-07-16T19:46:58Z + 2022-07-16T19:47:03Z + 2022-07-16T19:47:08Z + 2022-07-16T19:47:13Z + 2022-07-16T19:47:18Z + 2022-07-16T19:47:23Z + 2022-07-16T19:47:28Z + 2022-07-16T19:47:33Z + 2022-07-16T19:47:39Z + 2022-07-16T19:47:44Z + 2022-07-16T19:47:49Z + 2022-07-16T19:47:53Z + 2022-07-16T19:47:59Z + 2022-07-16T19:48:03Z + 2022-07-16T19:48:09Z + 2022-07-16T19:48:14Z + 2022-07-16T19:48:19Z + 2022-07-16T19:48:24Z + 2022-07-16T19:48:29Z + 2022-07-16T19:48:34Z + 2022-07-16T19:48:39Z + 2022-07-16T19:48:44Z + 2022-07-16T19:48:49Z + 2022-07-16T19:48:54Z + 2022-07-16T19:48:59Z + 2022-07-16T19:49:04Z + 2022-07-16T19:49:09Z + 2022-07-16T19:49:14Z + 2022-07-16T19:49:19Z + 2022-07-16T19:49:24Z + 2022-07-16T19:49:29Z + 2022-07-16T19:49:34Z + 2022-07-16T19:49:39Z + 2022-07-16T19:49:44Z + 2022-07-16T19:49:49Z + 2022-07-16T19:49:54Z + 2022-07-16T19:49:59Z + 2022-07-16T19:50:04Z + 2022-07-16T19:50:09Z + 2022-07-16T19:50:14Z + 2022-07-16T19:50:19Z + 2022-07-16T19:50:24Z + 2022-07-16T19:50:29Z + 2022-07-16T19:50:34Z + 2022-07-16T19:50:40Z + 2022-07-16T19:50:45Z + 2022-07-16T19:50:50Z + 2022-07-16T19:50:55Z + 2022-07-16T19:51:00Z + 2022-07-16T19:51:05Z + 2022-07-16T19:51:10Z + 2022-07-16T19:51:15Z + 2022-07-16T19:51:20Z + 2022-07-16T19:51:25Z + 2022-07-16T19:51:30Z + 2022-07-16T19:51:35Z + 2022-07-16T19:51:40Z + 2022-07-16T19:51:45Z + 2022-07-16T19:51:50Z + 2022-07-16T19:51:55Z + 2022-07-16T19:52:00Z + 2022-07-16T19:52:05Z + 2022-07-16T19:52:10Z + 2022-07-16T19:52:15Z + 2022-07-16T19:52:20Z + 2022-07-16T19:52:25Z + 2022-07-16T19:52:30Z + 2022-07-16T19:52:35Z + 2022-07-16T19:52:40Z + 2022-07-16T19:52:45Z + 2022-07-16T19:52:50Z + 2022-07-16T19:52:55Z + 2022-07-16T19:53:00Z + 2022-07-16T19:53:05Z + 2022-07-16T19:53:10Z + 2022-07-16T19:53:15Z + 2022-07-16T19:53:20Z + 2022-07-16T19:53:25Z + 2022-07-16T19:53:30Z + 2022-07-16T19:53:35Z + 2022-07-16T19:53:40Z + 2022-07-16T19:53:45Z + 2022-07-16T19:53:50Z + 2022-07-16T19:53:55Z + 2022-07-16T19:54:00Z + 2022-07-16T19:54:05Z + 2022-07-16T19:54:11Z + 2022-07-16T19:54:16Z + 2022-07-16T19:54:21Z + 2022-07-16T19:54:26Z + 2022-07-16T19:54:31Z + 2022-07-16T19:54:36Z + 2022-07-16T19:54:41Z + 2022-07-16T19:54:46Z + 2022-07-16T19:54:51Z + 2022-07-16T19:54:56Z + 2022-07-16T19:55:01Z + 2022-07-16T19:55:06Z + 2022-07-16T19:55:11Z + 2022-07-16T19:55:16Z + 2022-07-16T19:55:21Z + 2022-07-16T19:55:26Z + 2022-07-16T19:55:31Z + 2022-07-16T19:55:36Z + 2022-07-16T19:55:41Z + 2022-07-16T19:55:46Z + 2022-07-16T19:55:51Z + 2022-07-16T19:55:56Z + 2022-07-16T19:56:01Z + 2022-07-16T19:56:06Z + 2022-07-16T19:56:11Z + 2022-07-16T19:56:16Z + 2022-07-16T19:56:21Z + 2022-07-16T19:56:26Z + 2022-07-16T19:56:31Z + 2022-07-16T19:56:36Z + 2022-07-16T19:56:41Z + 2022-07-16T19:56:46Z + 2022-07-16T19:56:51Z + 2022-07-16T19:56:56Z + 2022-07-16T19:57:01Z + 2022-07-16T19:57:06Z + 2022-07-16T19:57:11Z + 2022-07-16T19:57:16Z + 2022-07-16T19:57:21Z + 2022-07-16T19:57:26Z + 2022-07-16T19:57:31Z + 2022-07-16T19:57:36Z + 2022-07-16T19:57:41Z + 2022-07-16T19:57:46Z + 2022-07-16T19:57:51Z + 2022-07-16T19:57:56Z + 2022-07-16T19:58:01Z + 2022-07-16T19:58:06Z + 2022-07-16T19:58:11Z + 2022-07-16T19:58:16Z + 2022-07-16T19:58:21Z + 2022-07-16T19:58:26Z + 2022-07-16T19:58:31Z + 2022-07-16T19:58:36Z + 2022-07-16T19:58:41Z + 2022-07-16T19:58:46Z + 2022-07-16T19:58:51Z + 2022-07-16T19:58:56Z + 2022-07-16T19:59:01Z + 2022-07-16T19:59:06Z + 2022-07-16T19:59:11Z + 2022-07-16T19:59:16Z + 2022-07-16T19:59:21Z + 2022-07-16T19:59:26Z + 2022-07-16T19:59:31Z + 2022-07-16T19:59:36Z + 2022-07-16T19:59:41Z + 2022-07-16T19:59:46Z + 2022-07-16T19:59:51Z + 2022-07-16T19:59:56Z + 2022-07-16T20:00:01Z + 2022-07-16T20:00:06Z + 2022-07-16T20:00:11Z + 2022-07-16T20:00:16Z + 2022-07-16T20:00:21Z + 2022-07-16T20:00:26Z + 2022-07-16T20:00:31Z + 2022-07-16T20:00:36Z + 2022-07-16T20:00:41Z + 2022-07-16T20:00:46Z + 2022-07-16T20:00:51Z + 2022-07-16T20:00:56Z + 2022-07-16T20:01:01Z + 2022-07-16T20:01:06Z + 2022-07-16T20:01:11Z + 2022-07-16T20:01:16Z + 2022-07-16T20:01:21Z + 2022-07-16T20:01:26Z + 2022-07-16T20:01:31Z + 2022-07-16T20:01:36Z + 2022-07-16T20:01:41Z + 2022-07-16T20:01:46Z + 2022-07-16T20:01:51Z + 2022-07-16T20:01:56Z + 2022-07-16T20:02:01Z + 2022-07-16T20:02:06Z + 2022-07-16T20:02:11Z + 2022-07-16T20:02:16Z + 2022-07-16T20:02:21Z + 2022-07-16T20:02:26Z + 2022-07-16T20:02:31Z + 2022-07-16T20:02:36Z + 2022-07-16T20:02:41Z + 2022-07-16T20:02:46Z + 2022-07-16T20:02:51Z + 2022-07-16T20:02:56Z + 2022-07-16T20:03:01Z + 2022-07-16T20:03:06Z + 2022-07-16T20:03:11Z + 2022-07-16T20:03:16Z + 2022-07-16T20:03:22Z + 2022-07-16T20:03:27Z + 2022-07-16T20:03:32Z + 2022-07-16T20:03:37Z + 2022-07-16T20:03:42Z + 2022-07-16T20:03:47Z + 2022-07-16T20:03:52Z + 2022-07-16T20:03:57Z + 2022-07-16T20:04:02Z + 2022-07-16T20:04:07Z + 2022-07-16T20:04:12Z + 2022-07-16T20:04:17Z + 2022-07-16T20:04:22Z + 2022-07-16T20:04:27Z + 2022-07-16T20:04:32Z + 2022-07-16T20:04:37Z + 2022-07-16T20:04:42Z + 2022-07-16T20:04:47Z + 2022-07-16T20:04:52Z + 2022-07-16T20:04:57Z + 2022-07-16T20:05:02Z + 2022-07-16T20:05:07Z + 2022-07-16T20:05:12Z + 2022-07-16T20:05:17Z + 2022-07-16T20:05:22Z + 2022-07-16T20:05:27Z + 2022-07-16T20:05:32Z + 2022-07-16T20:05:37Z + 2022-07-16T20:05:42Z + 2022-07-16T20:05:47Z + 2022-07-16T20:05:52Z + 2022-07-16T20:05:57Z + 2022-07-16T20:06:02Z + 2022-07-16T20:06:07Z + 2022-07-16T20:06:12Z + 2022-07-16T20:06:17Z + 2022-07-16T20:06:22Z + 2022-07-16T20:06:27Z + 2022-07-16T20:06:32Z + 2022-07-16T20:06:37Z + 2022-07-16T20:06:42Z + 2022-07-16T20:06:47Z + 2022-07-16T20:06:52Z + 2022-07-16T20:06:57Z + 2022-07-16T20:07:02Z + 2022-07-16T20:07:07Z + 2022-07-16T20:07:12Z + 2022-07-16T20:07:17Z + 2022-07-16T20:07:22Z + 2022-07-16T20:07:27Z + 2022-07-16T20:07:32Z + 2022-07-16T20:07:37Z + 2022-07-16T20:07:42Z + 2022-07-16T20:07:47Z + 2022-07-16T20:07:52Z + 2022-07-16T20:07:57Z + 2022-07-16T20:08:02Z + 2022-07-16T20:08:07Z + 2022-07-16T20:08:12Z + 2022-07-16T20:08:17Z + 2022-07-16T20:08:22Z + 2022-07-16T20:08:27Z + 2022-07-16T20:08:32Z + 2022-07-16T20:08:37Z + 2022-07-16T20:08:42Z + 2022-07-16T20:08:47Z + 2022-07-16T20:08:52Z + 2022-07-16T20:08:57Z + 2022-07-16T20:09:02Z + 2022-07-16T20:09:07Z + 2022-07-16T20:09:12Z + 2022-07-16T20:09:17Z + 2022-07-16T20:09:22Z + 2022-07-16T20:09:27Z + 2022-07-16T20:09:32Z + 2022-07-16T20:09:37Z + 2022-07-16T20:09:42Z + 2022-07-16T20:09:47Z + 2022-07-16T20:09:52Z + 2022-07-16T20:09:57Z + 2022-07-16T20:10:02Z + 2022-07-16T20:10:07Z + 2022-07-16T20:10:12Z + 2022-07-16T20:10:17Z + 2022-07-16T20:10:22Z + 2022-07-16T20:10:27Z + 2022-07-16T20:10:32Z + 2022-07-16T20:10:37Z + 2022-07-16T20:10:42Z + 2022-07-16T20:10:47Z + 2022-07-16T20:10:52Z + 2022-07-16T20:10:57Z + 2022-07-16T20:11:02Z + 2022-07-16T20:11:07Z + 2022-07-16T20:11:12Z + 2022-07-16T20:11:17Z + 2022-07-16T20:11:22Z + 2022-07-16T20:11:27Z + 2022-07-16T20:11:32Z + 2022-07-16T20:11:37Z + 2022-07-16T20:11:42Z + 2022-07-16T20:11:47Z + 2022-07-16T20:11:52Z + 2022-07-16T20:11:57Z + 2022-07-16T20:12:02Z + 2022-07-16T20:12:07Z + 2022-07-16T20:12:12Z + 2022-07-16T20:12:17Z + 2022-07-16T20:12:22Z + 2022-07-16T20:12:27Z + 2022-07-16T20:12:32Z + 2022-07-16T20:12:37Z + 2022-07-16T20:12:42Z + 2022-07-16T20:12:47Z + 2022-07-16T20:12:52Z + 2022-07-16T20:12:57Z + 2022-07-16T20:13:02Z + 2022-07-16T20:13:07Z + 2022-07-16T20:13:12Z + 2022-07-16T20:13:17Z + 2022-07-16T20:13:22Z + 2022-07-16T20:13:27Z + 2022-07-16T20:13:32Z + 2022-07-16T20:13:37Z + 2022-07-16T20:13:42Z + 2022-07-16T20:13:47Z + 2022-07-16T20:13:52Z + 2022-07-16T20:13:57Z + 2022-07-16T20:14:02Z + 2022-07-16T20:14:07Z + 2022-07-16T20:14:12Z + 2022-07-16T20:14:17Z + 2022-07-16T20:14:22Z + 2022-07-16T20:14:27Z + 2022-07-16T20:14:32Z + 2022-07-16T20:14:37Z + 2022-07-16T20:14:42Z + 2022-07-16T20:14:47Z + 2022-07-16T20:14:52Z + 2022-07-16T20:14:57Z + 2022-07-16T20:15:02Z + 2022-07-16T20:15:07Z + 2022-07-16T20:15:12Z + 2022-07-16T20:15:17Z + 2022-07-16T20:15:22Z + 2022-07-16T20:15:27Z + 2022-07-16T20:15:32Z + 2022-07-16T20:15:37Z + 2022-07-16T20:15:42Z + 2022-07-16T20:15:47Z + 2022-07-16T20:15:52Z + 2022-07-16T20:15:57Z + 2022-07-16T20:16:02Z + 2022-07-16T20:16:07Z + 2022-07-16T20:16:12Z + 2022-07-16T20:16:17Z + 2022-07-16T20:16:22Z + 2022-07-16T20:16:27Z + 2022-07-16T20:16:33Z + 2022-07-16T20:16:38Z + 2022-07-16T20:16:43Z + 2022-07-16T20:16:48Z + 2022-07-16T20:16:53Z + 2022-07-16T20:16:58Z + 2022-07-16T20:17:03Z + 2022-07-16T20:17:08Z + 2022-07-16T20:17:13Z + 2022-07-16T20:17:18Z + 2022-07-16T20:17:23Z + 2022-07-16T20:17:28Z + 2022-07-16T20:17:33Z + 2022-07-16T20:17:38Z + 2022-07-16T20:17:43Z + 2022-07-16T20:17:48Z + 2022-07-16T20:17:53Z + 2022-07-16T20:17:58Z + 2022-07-16T20:18:03Z + 2022-07-16T20:18:08Z + 2022-07-16T20:18:13Z + 2022-07-16T20:18:18Z + 2022-07-16T20:18:23Z + 2022-07-16T20:18:28Z + 2022-07-16T20:18:33Z + 2022-07-16T20:18:38Z + 2022-07-16T20:18:43Z + 2022-07-16T20:18:48Z + 2022-07-16T20:18:53Z + 2022-07-16T20:18:58Z + 2022-07-16T20:19:03Z + 2022-07-16T20:19:08Z + 2022-07-16T20:19:13Z + 2022-07-16T20:19:18Z + 2022-07-16T20:19:23Z + 2022-07-16T20:19:28Z + 2022-07-16T20:19:33Z + 2022-07-16T20:19:38Z + 2022-07-16T20:19:43Z + 2022-07-16T20:19:48Z + 2022-07-16T20:19:53Z + 2022-07-16T20:19:58Z + 2022-07-16T20:20:03Z + 2022-07-16T20:20:08Z + 2022-07-16T20:20:13Z + 2022-07-16T20:20:18Z + 2022-07-16T20:20:23Z + 2022-07-16T20:20:28Z + 2022-07-16T20:20:33Z + 2022-07-16T20:20:38Z + 2022-07-16T20:20:43Z + 2022-07-16T20:20:48Z + 2022-07-16T20:20:53Z + 2022-07-16T20:20:58Z + 2022-07-16T20:21:03Z + 2022-07-16T20:21:08Z + 2022-07-16T20:21:13Z + 2022-07-16T20:21:18Z + 2022-07-16T20:21:23Z + 2022-07-16T20:21:28Z + 2022-07-16T20:21:33Z + 2022-07-16T20:21:38Z + 2022-07-16T20:21:43Z + 2022-07-16T20:21:48Z + 2022-07-16T20:21:53Z + 2022-07-16T20:21:58Z + 2022-07-16T20:22:03Z + 2022-07-16T20:22:08Z + 2022-07-16T20:22:13Z + 2022-07-16T20:22:18Z + 2022-07-16T20:22:23Z + 2022-07-16T20:22:28Z + 2022-07-16T20:22:33Z + 2022-07-16T20:22:38Z + 2022-07-16T20:22:43Z + 2022-07-16T20:22:48Z + 2022-07-16T20:22:53Z + 2022-07-16T20:22:58Z + 2022-07-16T20:23:03Z + 2022-07-16T20:23:08Z + 2022-07-16T20:23:13Z + 2022-07-16T20:23:18Z + 2022-07-16T20:23:23Z + 2022-07-16T20:23:28Z + 2022-07-16T20:23:33Z + 2022-07-16T20:23:38Z + 2022-07-16T20:23:43Z + 2022-07-16T20:23:48Z + 2022-07-16T20:23:53Z + 2022-07-16T20:23:58Z + 2022-07-16T20:24:03Z + 2022-07-16T20:24:08Z + 2022-07-16T20:24:13Z + 2022-07-16T20:24:18Z + 2022-07-16T20:24:23Z + 2022-07-16T20:24:28Z + 2022-07-16T20:24:33Z + 2022-07-16T20:24:38Z + 2022-07-16T20:24:43Z + 2022-07-16T20:24:48Z + 2022-07-16T20:24:53Z + 2022-07-16T20:24:58Z + 2022-07-16T20:25:03Z + 2022-07-16T20:25:08Z + 2022-07-16T20:25:13Z + 2022-07-16T20:25:18Z + 2022-07-16T20:25:23Z + 2022-07-16T20:25:28Z + 2022-07-16T20:25:33Z + 2022-07-16T20:25:38Z + 2022-07-16T20:25:43Z + 2022-07-16T20:25:48Z + 2022-07-16T20:25:53Z + 2022-07-16T20:25:58Z + 2022-07-16T20:26:03Z + 2022-07-16T20:26:08Z + 2022-07-16T20:26:13Z + 2022-07-16T20:26:18Z + 2022-07-16T20:26:23Z + 2022-07-16T20:26:28Z + 2022-07-16T20:26:33Z + 2022-07-16T20:26:38Z + 2022-07-16T20:26:43Z + 2022-07-16T20:26:48Z + 2022-07-16T20:26:53Z + 2022-07-16T20:26:58Z + 2022-07-16T20:27:03Z + 2022-07-16T20:27:08Z + 2022-07-16T20:27:13Z + 2022-07-16T20:27:18Z + 2022-07-16T20:27:23Z + 2022-07-16T20:27:28Z + 2022-07-16T20:27:33Z + 2022-07-16T20:27:38Z + 2022-07-16T20:27:43Z + 2022-07-16T20:27:48Z + 2022-07-16T20:27:53Z + 2022-07-16T20:27:58Z + 2022-07-16T20:28:03Z + 2022-07-16T20:28:08Z + 2022-07-16T20:28:13Z + 2022-07-16T20:28:18Z + 2022-07-16T20:28:23Z + 2022-07-16T20:28:28Z + 2022-07-16T20:28:33Z + 2022-07-16T20:28:38Z + 2022-07-16T20:28:43Z + 2022-07-16T20:28:48Z + 2022-07-16T20:28:53Z + 2022-07-16T20:28:58Z + 2022-07-16T20:29:03Z + 2022-07-16T20:29:09Z + 2022-07-16T20:29:13Z + 2022-07-16T20:29:19Z + 2022-07-16T20:29:24Z + 2022-07-16T20:29:29Z + 2022-07-16T20:29:34Z + 2022-07-16T20:29:39Z + 2022-07-16T20:29:44Z + 2022-07-16T20:29:49Z + 2022-07-16T20:29:54Z + 2022-07-16T20:29:59Z + 2022-07-16T20:30:04Z + 2022-07-16T20:30:09Z + 2022-07-16T20:30:14Z + 2022-07-16T20:30:19Z + 2022-07-16T20:30:24Z + 2022-07-16T20:30:29Z + 2022-07-16T20:30:34Z + 2022-07-16T20:30:39Z + 2022-07-16T20:30:44Z + 2022-07-16T20:30:49Z + 2022-07-16T20:30:54Z + 2022-07-16T20:30:59Z + 2022-07-16T20:31:04Z + 2022-07-16T20:31:09Z + 2022-07-16T20:31:14Z + 2022-07-16T20:31:19Z + 2022-07-16T20:31:24Z + 2022-07-16T20:31:29Z + 2022-07-16T20:31:34Z + 2022-07-16T20:31:39Z + 2022-07-16T20:31:44Z + 2022-07-16T20:31:49Z + 2022-07-16T20:31:54Z + 2022-07-16T20:31:59Z + 2022-07-16T20:32:04Z + 2022-07-16T20:32:09Z + 2022-07-16T20:32:14Z + 2022-07-16T20:32:19Z + 2022-07-16T20:32:24Z + 2022-07-16T20:32:29Z + 2022-07-16T20:32:34Z + 2022-07-16T20:32:39Z + 2022-07-16T20:32:44Z + 2022-07-16T20:32:49Z + 2022-07-16T20:32:54Z + 2022-07-16T20:32:59Z + 2022-07-16T20:33:04Z + 2022-07-16T20:33:09Z + 2022-07-16T20:33:14Z + 2022-07-16T20:33:19Z + 2022-07-16T20:33:24Z + 2022-07-16T20:33:29Z + 2022-07-16T20:33:34Z + 2022-07-16T20:33:39Z + 2022-07-16T20:33:44Z + 2022-07-16T20:33:49Z + 2022-07-16T20:33:54Z + 2022-07-16T20:33:59Z + 2022-07-16T20:34:04Z + 2022-07-16T20:34:09Z + 2022-07-16T20:34:14Z + 2022-07-16T20:34:19Z + 2022-07-16T20:34:24Z + 2022-07-16T20:34:29Z + 2022-07-16T20:34:34Z + 2022-07-16T20:34:39Z + 2022-07-16T20:34:44Z + 2022-07-16T20:34:49Z + 2022-07-16T20:34:54Z + 2022-07-16T20:34:59Z + 2022-07-16T20:35:04Z + 2022-07-16T20:35:09Z + 2022-07-16T20:35:14Z + 2022-07-16T20:35:19Z + 2022-07-16T20:35:24Z + 2022-07-16T20:35:29Z + 2022-07-16T20:35:34Z + 2022-07-16T20:35:39Z + 2022-07-16T20:35:44Z + 2022-07-16T20:35:49Z + 2022-07-16T20:35:54Z + 2022-07-16T20:35:59Z + 2022-07-16T20:36:04Z + 2022-07-16T20:36:09Z + 2022-07-16T20:36:14Z + 2022-07-16T20:36:19Z + 2022-07-16T20:36:24Z + 2022-07-16T20:36:29Z + 2022-07-16T20:36:34Z + 2022-07-16T20:36:39Z + 2022-07-16T20:36:44Z + 2022-07-16T20:36:49Z + 2022-07-16T20:36:54Z + 2022-07-16T20:36:59Z + 2022-07-16T20:37:04Z + 2022-07-16T20:37:09Z + 2022-07-16T20:37:14Z + 2022-07-16T20:37:19Z + 2022-07-16T20:37:24Z + 2022-07-16T20:37:29Z + 2022-07-16T20:37:34Z + 2022-07-16T20:37:39Z + 2022-07-16T20:37:44Z + 2022-07-16T20:37:49Z + 2022-07-16T20:37:54Z + 2022-07-16T20:37:59Z + 2022-07-16T20:38:04Z + 2022-07-16T20:38:09Z + 2022-07-16T20:38:14Z + 2022-07-16T20:38:19Z + 2022-07-16T20:38:24Z + 2022-07-16T20:38:29Z + 2022-07-16T20:38:34Z + 2022-07-16T20:38:39Z + 2022-07-16T20:38:44Z + 2022-07-16T20:38:49Z + 2022-07-16T20:38:54Z + 2022-07-16T20:38:59Z + 2022-07-16T20:39:05Z + 2022-07-16T20:39:10Z + 2022-07-16T20:39:15Z + 2022-07-16T20:39:20Z + 2022-07-16T20:39:25Z + 2022-07-16T20:39:30Z + 2022-07-16T20:39:35Z + 2022-07-16T20:39:40Z + 2022-07-16T20:39:45Z + 2022-07-16T20:39:50Z + 2022-07-16T20:39:55Z + 2022-07-16T20:40:00Z + 2022-07-16T20:40:05Z + 2022-07-16T20:40:10Z + 2022-07-16T20:40:15Z + 2022-07-16T20:40:20Z + 2022-07-16T20:40:25Z + 2022-07-16T20:40:30Z + 2022-07-16T20:40:35Z + 2022-07-16T20:40:40Z + 2022-07-16T20:40:45Z + 2022-07-16T20:40:50Z + 2022-07-16T20:40:55Z + 2022-07-16T20:41:00Z + 2022-07-16T20:41:05Z + 2022-07-16T20:41:10Z + 2022-07-16T20:41:15Z + 2022-07-16T20:41:20Z + 2022-07-16T20:41:25Z + 2022-07-16T20:41:30Z + 2022-07-16T20:41:35Z + 2022-07-16T20:41:40Z + 2022-07-16T20:41:45Z + 2022-07-16T20:41:50Z + 2022-07-16T20:41:55Z + 2022-07-16T20:42:00Z + 2022-07-16T20:42:05Z + 2022-07-16T20:42:10Z + 2022-07-16T20:42:15Z + 2022-07-16T20:42:20Z + 2022-07-16T20:42:25Z + 2022-07-16T20:42:30Z + 2022-07-16T20:42:35Z + 2022-07-16T20:42:40Z + 2022-07-16T20:42:45Z + 2022-07-16T20:42:50Z + 2022-07-16T20:42:55Z + 2022-07-16T20:43:00Z + 2022-07-16T20:43:05Z + 2022-07-16T20:43:10Z + 2022-07-16T20:43:15Z + 2022-07-16T20:43:20Z + 2022-07-16T20:43:25Z + 2022-07-16T20:43:30Z + 2022-07-16T20:43:35Z + 2022-07-16T20:43:40Z + 2022-07-16T20:43:45Z + 2022-07-16T20:43:50Z + 2022-07-16T20:43:55Z + 2022-07-16T20:44:00Z + 2022-07-16T20:44:05Z + 2022-07-16T20:44:10Z + 2022-07-16T20:44:15Z + 2022-07-16T20:44:20Z + 2022-07-16T20:44:25Z + 2022-07-16T20:44:30Z + 2022-07-16T20:44:35Z + 2022-07-16T20:44:40Z + 2022-07-16T20:44:45Z + 2022-07-16T20:44:50Z + 2022-07-16T20:44:55Z + 2022-07-16T20:45:00Z + 2022-07-16T20:45:05Z + 2022-07-16T20:45:10Z + 2022-07-16T20:45:15Z + 2022-07-16T20:45:20Z + 2022-07-16T20:45:25Z + 2022-07-16T20:45:30Z + 2022-07-16T20:45:35Z + 2022-07-16T20:45:40Z + 2022-07-16T20:45:45Z + 2022-07-16T20:45:50Z + 2022-07-16T20:45:55Z + 2022-07-16T20:46:00Z + 2022-07-16T20:46:05Z + 2022-07-16T20:46:10Z + 2022-07-16T20:46:15Z + 2022-07-16T20:46:20Z + 2022-07-16T20:46:25Z + 2022-07-16T20:46:30Z + 2022-07-16T20:46:35Z + 2022-07-16T20:46:40Z + 2022-07-16T20:46:45Z + 2022-07-16T20:46:50Z + 2022-07-16T20:46:55Z + 2022-07-16T20:47:00Z + 2022-07-16T20:47:05Z + 2022-07-16T20:47:10Z + 2022-07-16T20:47:15Z + 2022-07-16T20:47:20Z + 2022-07-16T20:47:25Z + 2022-07-16T20:47:30Z + 2022-07-16T20:47:35Z + 2022-07-16T20:47:40Z + 2022-07-16T20:47:45Z + 2022-07-16T20:47:50Z + 2022-07-16T20:47:55Z + 2022-07-16T20:48:00Z + 2022-07-16T20:48:05Z + 2022-07-16T20:48:10Z + 2022-07-16T20:48:15Z + 2022-07-16T20:48:20Z + 2022-07-16T20:48:25Z + 2022-07-16T20:48:30Z + 2022-07-16T20:48:35Z + 2022-07-16T20:48:40Z + 2022-07-16T20:48:45Z + 2022-07-16T20:48:50Z + 2022-07-16T20:48:55Z + 2022-07-16T20:49:00Z + 2022-07-16T20:49:05Z + 2022-07-16T20:49:10Z + 2022-07-16T20:49:15Z + 2022-07-16T20:49:20Z + 2022-07-16T20:49:25Z + 2022-07-16T20:49:31Z + 2022-07-16T20:49:36Z + 2022-07-16T20:49:41Z + 2022-07-16T20:49:46Z + 2022-07-16T20:49:51Z + 2022-07-16T20:49:56Z + 2022-07-16T20:50:01Z + 2022-07-16T20:50:06Z + 2022-07-16T20:50:11Z + 2022-07-16T20:50:16Z + 2022-07-16T20:50:21Z + 2022-07-16T20:50:26Z + 2022-07-16T20:50:31Z + 2022-07-16T20:50:36Z + 2022-07-16T20:50:41Z + 2022-07-16T20:50:46Z + 2022-07-16T20:50:51Z + 2022-07-16T20:50:56Z + 2022-07-16T20:51:01Z + 2022-07-16T20:51:06Z + 2022-07-16T20:51:11Z + 2022-07-16T20:51:16Z + 2022-07-16T20:51:21Z + 2022-07-16T20:51:26Z + 2022-07-16T20:51:31Z + 2022-07-16T20:51:36Z + 2022-07-16T20:51:41Z + 2022-07-16T20:51:46Z + 2022-07-16T20:51:51Z + 2022-07-16T20:51:56Z + 2022-07-16T20:52:01Z + 2022-07-16T20:52:06Z + 2022-07-16T20:52:11Z + 2022-07-16T20:52:16Z + 2022-07-16T20:52:21Z + 2022-07-16T20:52:26Z + 2022-07-16T20:52:31Z + 2022-07-16T20:52:36Z + 2022-07-16T20:52:41Z + 2022-07-16T20:52:46Z + 2022-07-16T20:52:51Z + 2022-07-16T20:52:56Z + 2022-07-16T20:53:01Z + 2022-07-16T20:53:06Z + 2022-07-16T20:53:11Z + 2022-07-16T20:53:16Z + 2022-07-16T20:53:21Z + 2022-07-16T20:53:26Z + 2022-07-16T20:53:31Z + 2022-07-16T20:53:36Z + 2022-07-16T20:53:41Z + 2022-07-16T20:53:46Z + 2022-07-16T20:53:51Z + 2022-07-16T20:53:56Z + 2022-07-16T20:54:01Z + 2022-07-16T20:54:06Z + 2022-07-16T20:54:11Z + 2022-07-16T20:54:16Z + 2022-07-16T20:54:21Z + 2022-07-16T20:54:26Z + 2022-07-16T20:54:31Z + 2022-07-16T20:54:36Z + 2022-07-16T20:54:41Z + 2022-07-16T20:54:46Z + 2022-07-16T20:54:51Z + 2022-07-16T20:54:56Z + 2022-07-16T20:55:01Z + 2022-07-16T20:55:06Z + 2022-07-16T20:55:11Z + 2022-07-16T20:55:16Z + 2022-07-16T20:55:21Z + 2022-07-16T20:55:26Z + 2022-07-16T20:55:31Z + 2022-07-16T20:55:36Z + 2022-07-16T20:55:41Z + 2022-07-16T20:55:46Z + 2022-07-16T20:55:51Z + 2022-07-16T20:55:56Z + 2022-07-16T20:56:01Z + 2022-07-16T20:56:06Z + 2022-07-16T20:56:11Z + 2022-07-16T20:56:16Z + 2022-07-16T20:56:21Z + 2022-07-16T20:56:26Z + 2022-07-16T20:56:31Z + 2022-07-16T20:56:36Z + 2022-07-16T20:56:41Z + 2022-07-16T20:56:46Z + 2022-07-16T20:56:51Z + 2022-07-16T20:56:56Z + 2022-07-16T20:57:01Z + 2022-07-16T20:57:06Z + 2022-07-16T20:57:11Z + 2022-07-16T20:57:16Z + 2022-07-16T20:57:21Z + 2022-07-16T20:57:26Z + 2022-07-16T20:57:31Z + 2022-07-16T20:57:36Z + 2022-07-16T20:57:41Z + 2022-07-16T20:57:46Z + 2022-07-16T20:57:51Z + 2022-07-16T20:57:56Z + 2022-07-16T20:58:01Z + 2022-07-16T20:58:06Z + 2022-07-16T20:58:11Z + 2022-07-16T20:58:16Z + 2022-07-16T20:58:21Z + 2022-07-16T20:58:26Z + 2022-07-16T20:58:31Z + 2022-07-16T20:58:36Z + 2022-07-16T20:58:41Z + 2022-07-16T20:58:46Z + 2022-07-16T20:58:51Z + 2022-07-16T20:58:56Z + 2022-07-16T20:59:01Z + 2022-07-16T20:59:06Z + 2022-07-16T20:59:11Z + 2022-07-16T20:59:16Z + 2022-07-16T20:59:21Z + 2022-07-16T20:59:26Z + 2022-07-16T20:59:31Z + 2022-07-16T20:59:36Z + 2022-07-16T20:59:41Z + 2022-07-16T20:59:46Z + 2022-07-16T20:59:51Z + 2022-07-16T20:59:56Z + 2022-07-16T21:00:01Z + 2022-07-16T21:00:06Z + 2022-07-16T21:00:11Z + 2022-07-16T21:00:16Z + 2022-07-16T21:00:21Z + 2022-07-16T21:00:26Z + 2022-07-16T21:00:32Z + 2022-07-16T21:00:37Z + 2022-07-16T21:00:42Z + 2022-07-16T21:00:47Z + 2022-07-16T21:00:52Z + 2022-07-16T21:00:57Z + 2022-07-16T21:01:02Z + 2022-07-16T21:01:07Z + 2022-07-16T21:01:12Z + 2022-07-16T21:01:17Z + 2022-07-16T21:01:22Z + 2022-07-16T21:01:27Z + 2022-07-16T21:01:32Z + 2022-07-16T21:01:37Z + 2022-07-16T21:01:42Z + 2022-07-16T21:01:47Z + 2022-07-16T21:01:52Z + 2022-07-16T21:01:57Z + 2022-07-16T21:02:02Z + 2022-07-16T21:02:07Z + 2022-07-16T21:02:12Z + 2022-07-16T21:02:17Z + 2022-07-16T21:02:22Z + 2022-07-16T21:02:27Z + 2022-07-16T21:02:32Z + 2022-07-16T21:02:37Z + 2022-07-16T21:02:42Z + 2022-07-16T21:02:47Z + 2022-07-16T21:02:52Z + 2022-07-16T21:02:57Z + 2022-07-16T21:03:02Z + 2022-07-16T21:03:07Z + 2022-07-16T21:03:12Z + 2022-07-16T21:03:17Z + 2022-07-16T21:03:22Z + 2022-07-16T21:03:27Z + 2022-07-16T21:03:32Z + 2022-07-16T21:03:37Z + 2022-07-16T21:03:42Z + 2022-07-16T21:03:47Z + 2022-07-16T21:03:52Z + 2022-07-16T21:03:57Z + 2022-07-16T21:04:02Z + 2022-07-16T21:04:07Z + 2022-07-16T21:04:12Z + 2022-07-16T21:04:17Z + 2022-07-16T21:04:22Z + 2022-07-16T21:04:27Z + 2022-07-16T21:04:32Z + 2022-07-16T21:04:37Z + 2022-07-16T21:04:42Z + 2022-07-16T21:04:47Z + 2022-07-16T21:04:52Z + 2022-07-16T21:04:57Z + 2022-07-16T21:05:02Z + 2022-07-16T21:05:07Z + 2022-07-16T21:05:12Z + 2022-07-16T21:05:17Z + 2022-07-16T21:05:22Z + 2022-07-16T21:05:28Z + 2022-07-16T21:05:33Z + 2022-07-16T21:05:38Z + 2022-07-16T21:05:43Z + 2022-07-16T21:05:48Z + 2022-07-16T21:05:53Z + 2022-07-16T21:05:58Z + 2022-07-16T21:06:03Z + 2022-07-16T21:06:08Z + 2022-07-16T21:06:13Z + 2022-07-16T21:06:18Z + 2022-07-16T21:06:23Z + 2022-07-16T21:06:28Z + 2022-07-16T21:06:33Z + 2022-07-16T21:06:38Z + 2022-07-16T21:06:43Z + 2022-07-16T21:06:48Z + 2022-07-16T21:06:53Z + 2022-07-16T21:06:58Z + 2022-07-16T21:07:03Z + 2022-07-16T21:07:08Z + 2022-07-16T21:07:13Z + 2022-07-16T21:07:19Z + 2022-07-16T21:07:24Z + 2022-07-16T21:07:28Z + 2022-07-16T21:07:34Z + 2022-07-16T21:07:39Z + 2022-07-16T21:07:44Z + 2022-07-16T21:07:49Z + 2022-07-16T21:07:54Z + 2022-07-16T21:07:59Z + 2022-07-16T21:08:04Z + 2022-07-16T21:08:09Z + 2022-07-16T21:08:14Z + 2022-07-16T21:08:19Z + 2022-07-16T21:08:24Z + 2022-07-16T21:08:29Z + 2022-07-16T21:08:34Z + 2022-07-16T21:08:39Z + 2022-07-16T21:08:44Z + 2022-07-16T21:08:49Z + 2022-07-16T21:08:54Z + 2022-07-16T21:08:59Z + 2022-07-16T21:09:04Z + 2022-07-16T21:09:09Z + 2022-07-16T21:09:14Z + 2022-07-16T21:09:19Z + 2022-07-16T21:09:24Z + 2022-07-16T21:09:29Z + 2022-07-16T21:09:34Z + 2022-07-16T21:09:39Z + 2022-07-16T21:09:44Z + 2022-07-16T21:09:49Z + 2022-07-16T21:09:54Z + 2022-07-16T21:10:00Z + 2022-07-16T21:10:05Z + 2022-07-16T21:10:10Z + 2022-07-16T21:10:15Z + 2022-07-16T21:10:20Z + 2022-07-16T21:10:25Z + 2022-07-16T21:10:30Z + 2022-07-16T21:10:35Z + 2022-07-16T21:10:40Z + 2022-07-16T21:10:45Z + 2022-07-16T21:10:50Z + 2022-07-16T21:10:55Z + 2022-07-16T21:11:00Z + 2022-07-16T21:11:05Z + 2022-07-16T21:11:10Z + 2022-07-16T21:11:15Z + 2022-07-16T21:11:20Z + -80.443083 43.840333 463.00 + -80.443083 43.840333 463.00 + -80.443083 43.840333 463.00 + -80.442617 43.839933 463.00 + -80.441667 43.839200 463.00 + -80.440567 43.838433 464.00 + -80.439233 43.837517 466.00 + -80.437850 43.836533 484.00 + -80.436450 43.835600 503.00 + -80.435117 43.834700 524.00 + -80.433833 43.833833 543.00 + -80.432483 43.833000 557.00 + -80.431400 43.832050 574.00 + -80.430767 43.830933 584.00 + -80.430767 43.829700 590.00 + -80.431133 43.828533 601.00 + -80.431967 43.827483 611.00 + -80.433300 43.826650 626.00 + -80.434950 43.826117 638.00 + -80.436800 43.825667 656.00 + -80.438317 43.825250 672.00 + -80.440050 43.825017 687.00 + -80.441817 43.825250 697.00 + -80.443417 43.825967 702.00 + -80.444700 43.827117 709.00 + -80.445300 43.828633 719.00 + -80.445100 43.830217 738.00 + -80.444250 43.831683 748.00 + -80.442550 43.832883 755.00 + -80.440667 43.833500 765.00 + -80.438600 43.833683 773.00 + -80.436650 43.833267 782.00 + -80.435117 43.832383 790.00 + -80.434150 43.831200 799.00 + -80.433833 43.829900 811.00 + -80.434267 43.828650 820.00 + -80.435350 43.827617 834.00 + -80.436817 43.826950 856.00 + -80.438400 43.826483 869.00 + -80.439983 43.826083 879.00 + -80.441567 43.825700 888.00 + -80.443217 43.825317 895.00 + -80.444850 43.824883 917.00 + -80.446267 43.824200 936.00 + -80.447117 43.823100 952.00 + -80.447167 43.821850 970.00 + -80.446417 43.820617 972.00 + -80.444900 43.819717 978.00 + -80.442883 43.819250 986.00 + -80.440683 43.819350 1000.00 + -80.438333 43.820033 1011.00 + -80.436700 43.821067 1024.00 + -80.434900 43.822217 1045.00 + -80.432783 43.822983 1057.00 + -80.430450 43.823183 1068.00 + -80.428217 43.822950 1082.00 + -80.426083 43.822233 1099.00 + -80.424683 43.821150 1116.00 + -80.423833 43.819800 1124.00 + -80.423767 43.818350 1135.00 + -80.424400 43.817033 1155.00 + -80.425667 43.816033 1160.00 + -80.427400 43.815400 1168.00 + -80.429400 43.815200 1177.00 + -80.431450 43.815367 1194.00 + -80.433483 43.815633 1213.00 + -80.435483 43.815517 1233.00 + -80.437300 43.814950 1252.00 + -80.438550 43.813850 1276.00 + -80.438850 43.812467 1296.00 + -80.438283 43.811150 1323.00 + -80.437033 43.810083 1349.00 + -80.435283 43.809367 1375.00 + -80.432900 43.809350 1391.00 + -80.430750 43.809950 1410.00 + -80.429117 43.809300 1414.00 + -80.427983 43.808300 1417.00 + -80.427067 43.807283 1412.00 + -80.425767 43.806633 1407.00 + -80.424533 43.807233 1402.00 + -80.424433 43.808267 1400.00 + -80.425217 43.809133 1395.00 + -80.426517 43.809633 1394.00 + -80.428017 43.809800 1393.00 + -80.429567 43.809767 1384.00 + -80.431083 43.809567 1383.00 + -80.432583 43.809317 1389.00 + -80.434083 43.808967 1400.00 + -80.434733 43.808067 1415.00 + -80.433900 43.807333 1425.00 + -80.432517 43.807600 1440.00 + -80.431917 43.808567 1451.00 + -80.432533 43.809533 1459.00 + -80.433900 43.809750 1470.00 + -80.434967 43.809000 1479.00 + -80.434883 43.808033 1494.00 + -80.433683 43.807633 1508.00 + -80.432600 43.808233 1527.00 + -80.432683 43.809283 1533.00 + -80.433933 43.809817 1545.00 + -80.435117 43.809400 1560.00 + -80.435283 43.808483 1565.00 + -80.434300 43.807800 1577.00 + -80.432933 43.807950 1596.00 + -80.432150 43.808833 1612.00 + -80.432667 43.809950 1617.00 + -80.434017 43.810300 1631.00 + -80.435250 43.809933 1643.00 + -80.436217 43.809083 1659.00 + -80.435717 43.808200 1670.00 + -80.434367 43.808000 1676.00 + -80.433183 43.808700 1693.00 + -80.433233 43.809800 1712.00 + -80.434617 43.810167 1724.00 + -80.435617 43.809400 1738.00 + -80.435033 43.808533 1750.00 + -80.433600 43.808583 1753.00 + -80.432950 43.809700 1773.00 + -80.433483 43.810800 1787.00 + -80.435017 43.811067 1800.00 + -80.436033 43.810283 1813.00 + -80.435650 43.809317 1822.00 + -80.434000 43.809100 1829.00 + -80.432850 43.809933 1847.00 + -80.432517 43.811067 1862.00 + -80.433733 43.811683 1872.00 + -80.434950 43.811167 1883.00 + -80.434833 43.810183 1896.00 + -80.433483 43.809817 1900.00 + -80.432267 43.810533 1919.00 + -80.432500 43.811567 1935.00 + -80.433817 43.811933 1943.00 + -80.434867 43.811283 1955.00 + -80.434717 43.810367 1968.00 + -80.433517 43.809850 1978.00 + -80.432033 43.810100 1993.00 + -80.431267 43.811050 2001.00 + -80.431600 43.812083 2002.00 + -80.432783 43.812750 2000.00 + -80.434267 43.812533 2007.00 + -80.434917 43.811567 2019.00 + -80.434283 43.810550 2029.00 + -80.432750 43.810283 2051.00 + -80.431500 43.810967 2065.00 + -80.431317 43.812017 2072.00 + -80.432133 43.812850 2071.00 + -80.433450 43.813300 2079.00 + -80.434850 43.813383 2092.00 + -80.435733 43.812700 2093.00 + -80.435333 43.811700 2090.00 + -80.433933 43.811300 2098.00 + -80.432483 43.811700 2117.00 + -80.432167 43.812750 2122.00 + -80.433300 43.813467 2133.00 + -80.434483 43.813100 2144.00 + -80.434733 43.812217 2149.00 + -80.433833 43.811417 2150.00 + -80.432450 43.811633 2172.00 + -80.431950 43.812650 2170.00 + -80.432867 43.813567 2183.00 + -80.434233 43.813417 2198.00 + -80.434767 43.812550 2200.00 + -80.434017 43.811700 2211.00 + -80.432517 43.811800 2223.00 + -80.431917 43.812883 2230.00 + -80.432817 43.813767 2239.00 + -80.434117 43.813517 2253.00 + -80.434300 43.812600 2254.00 + -80.433133 43.812000 2271.00 + -80.431817 43.812517 2277.00 + -80.431600 43.813667 2284.00 + -80.432667 43.814417 2292.00 + -80.433900 43.814017 2300.00 + -80.434000 43.813067 2300.00 + -80.432650 43.812833 2315.00 + -80.431700 43.813650 2312.00 + -80.432317 43.814683 2314.00 + -80.433767 43.815017 2319.00 + -80.435250 43.814850 2316.00 + -80.436467 43.814283 2307.00 + -80.436550 43.813300 2304.00 + -80.435483 43.812550 2315.00 + -80.434117 43.812117 2311.00 + -80.432633 43.812583 2310.00 + -80.432300 43.813750 2320.00 + -80.433433 43.814467 2322.00 + -80.434767 43.814050 2324.00 + -80.434717 43.813033 2335.00 + -80.433383 43.812633 2337.00 + -80.432083 43.813150 2328.00 + -80.432117 43.814433 2329.00 + -80.432550 43.815750 2321.00 + -80.433067 43.817150 2315.00 + -80.433650 43.818650 2314.00 + -80.434467 43.820100 2322.00 + -80.435967 43.820100 2343.00 + -80.436100 43.819167 2341.00 + -80.435233 43.818217 2318.00 + -80.433733 43.817283 2307.00 + -80.432033 43.816450 2305.00 + -80.430167 43.815717 2301.00 + -80.428183 43.815050 2297.00 + -80.426133 43.814483 2292.00 + -80.424017 43.813967 2284.00 + -80.421867 43.813417 2286.00 + -80.420200 43.812900 2322.00 + -80.418750 43.812450 2311.00 + -80.417233 43.811883 2310.00 + -80.415567 43.811367 2300.00 + -80.413683 43.810767 2287.00 + -80.411750 43.810050 2278.00 + -80.409733 43.809367 2269.00 + -80.407667 43.808667 2258.00 + -80.405600 43.807817 2246.00 + -80.403567 43.806883 2240.00 + -80.401533 43.805983 2235.00 + -80.399700 43.805167 2251.00 + -80.397983 43.804483 2246.00 + -80.396000 43.803917 2223.00 + -80.393850 43.803217 2208.00 + -80.391833 43.802383 2204.00 + -80.390033 43.801517 2200.00 + -80.388400 43.800600 2197.00 + -80.386883 43.799633 2192.00 + -80.385317 43.798533 2186.00 + -80.383900 43.797517 2178.00 + -80.382517 43.796450 2178.00 + -80.381283 43.795317 2180.00 + -80.380267 43.794083 2197.00 + -80.379533 43.792983 2210.00 + -80.378967 43.791983 2208.00 + -80.378450 43.790883 2193.00 + -80.377833 43.789633 2181.00 + -80.377183 43.788300 2171.00 + -80.376517 43.786900 2163.00 + -80.375850 43.785467 2147.00 + -80.375217 43.783933 2138.00 + -80.374633 43.782500 2140.00 + -80.374117 43.781100 2132.00 + -80.373717 43.779650 2120.00 + -80.373333 43.778150 2106.00 + -80.373000 43.776583 2090.00 + -80.372633 43.774950 2078.00 + -80.372267 43.773317 2069.00 + -80.371933 43.771733 2073.00 + -80.371617 43.770217 2071.00 + -80.371150 43.768733 2068.00 + -80.370617 43.767300 2064.00 + -80.370033 43.765850 2052.00 + -80.369367 43.764333 2039.00 + -80.368717 43.762750 2025.00 + -80.368050 43.761083 2014.00 + -80.367367 43.759417 2004.00 + -80.366800 43.757733 2000.00 + -80.366283 43.756100 1992.00 + -80.365783 43.754467 1985.00 + -80.365367 43.752833 1978.00 + -80.364917 43.751200 1961.00 + -80.364450 43.749517 1957.00 + -80.363883 43.747783 1951.00 + -80.363350 43.746083 1955.00 + -80.362750 43.744417 1955.00 + -80.362200 43.742750 1956.00 + -80.361567 43.741083 1950.00 + -80.360983 43.739400 1936.00 + -80.360383 43.737667 1926.00 + -80.359733 43.735950 1919.00 + -80.359050 43.734200 1904.00 + -80.358317 43.732417 1893.00 + -80.357617 43.730483 1899.00 + -80.357033 43.728850 1899.00 + -80.356500 43.727217 1891.00 + -80.355983 43.725550 1880.00 + -80.355350 43.723833 1865.00 + -80.354700 43.722133 1851.00 + -80.354083 43.720483 1842.00 + -80.353583 43.718900 1836.00 + -80.353150 43.717333 1828.00 + -80.352650 43.715750 1813.00 + -80.352000 43.714067 1798.00 + -80.351183 43.712400 1792.00 + -80.350367 43.710750 1788.00 + -80.349417 43.709217 1793.00 + -80.348567 43.707833 1809.00 + -80.347850 43.706617 1816.00 + -80.346983 43.705567 1810.00 + -80.346517 43.704450 1807.00 + -80.347133 43.703383 1804.00 + -80.348217 43.702467 1814.00 + -80.349300 43.701550 1812.00 + -80.350450 43.700683 1805.00 + -80.351683 43.699867 1795.00 + -80.352967 43.699033 1782.00 + -80.354367 43.698200 1772.00 + -80.355867 43.697400 1764.00 + -80.357267 43.696533 1762.00 + -80.358633 43.695717 1753.00 + -80.359983 43.694967 1747.00 + -80.361317 43.694167 1738.00 + -80.362583 43.693250 1732.00 + -80.363833 43.692283 1732.00 + -80.365100 43.691367 1738.00 + -80.366250 43.690450 1744.00 + -80.367400 43.689550 1749.00 + -80.368283 43.688550 1758.00 + -80.367300 43.687633 1771.00 + -80.365600 43.687550 1784.00 + -80.364500 43.688450 1796.00 + -80.364900 43.689467 1802.00 + -80.366100 43.689900 1806.00 + -80.367183 43.689550 1808.00 + -80.367983 43.688800 1804.00 + -80.368633 43.687900 1801.00 + -80.369267 43.686917 1809.00 + -80.369983 43.685883 1814.00 + -80.369617 43.684767 1829.00 + -80.368050 43.684667 1834.00 + -80.367250 43.685667 1838.00 + -80.368033 43.686633 1853.00 + -80.369367 43.686833 1870.00 + -80.369500 43.685817 1880.00 + -80.368050 43.685450 1888.00 + -80.366983 43.686317 1893.00 + -80.367450 43.687450 1914.00 + -80.368683 43.687833 1927.00 + -80.369167 43.686833 1936.00 + -80.368133 43.685917 1955.00 + -80.366500 43.685933 1967.00 + -80.365517 43.686883 1981.00 + -80.366150 43.687817 1999.00 + -80.367383 43.687667 2015.00 + -80.367483 43.686750 2032.00 + -80.366167 43.686217 2031.00 + -80.365267 43.687250 2035.00 + -80.366250 43.688050 2055.00 + -80.367550 43.687867 2069.00 + -80.367517 43.686917 2081.00 + -80.366083 43.686533 2088.00 + -80.364700 43.687183 2094.00 + -80.364267 43.688350 2104.00 + -80.364617 43.689517 2118.00 + -80.365867 43.690117 2135.00 + -80.366983 43.689567 2132.00 + -80.366717 43.688517 2150.00 + -80.365267 43.688317 2167.00 + -80.364017 43.689133 2165.00 + -80.364117 43.690333 2186.00 + -80.364917 43.691217 2185.00 + -80.366333 43.691267 2187.00 + -80.367100 43.690400 2188.00 + -80.367033 43.689267 2201.00 + -80.365683 43.688767 2214.00 + -80.364567 43.689583 2218.00 + -80.365217 43.690467 2231.00 + -80.366500 43.690333 2238.00 + -80.366967 43.689433 2255.00 + -80.366333 43.688550 2257.00 + -80.364783 43.688167 2267.00 + -80.363500 43.688717 2274.00 + -80.363200 43.689833 2258.00 + -80.363667 43.690933 2267.00 + -80.364467 43.691900 2273.00 + -80.365433 43.692750 2272.00 + -80.366800 43.692783 2265.00 + -80.367183 43.691783 2271.00 + -80.366267 43.690900 2285.00 + -80.364750 43.690600 2290.00 + -80.363100 43.690967 2303.00 + -80.361700 43.691650 2315.00 + -80.360750 43.692650 2319.00 + -80.361067 43.693750 2320.00 + -80.362450 43.694067 2314.00 + -80.363417 43.693350 2315.00 + -80.363200 43.692317 2317.00 + -80.361917 43.691600 2328.00 + -80.360317 43.691600 2336.00 + -80.358933 43.692300 2323.00 + -80.358833 43.693467 2332.00 + -80.360000 43.694067 2330.00 + -80.361533 43.694000 2325.00 + -80.362967 43.694000 2331.00 + -80.364383 43.693883 2331.00 + -80.365833 43.693700 2333.00 + -80.367333 43.693500 2346.00 + -80.368850 43.693317 2345.00 + -80.370533 43.693117 2345.00 + -80.372367 43.692817 2346.00 + -80.374183 43.692600 2352.00 + -80.375767 43.692517 2346.00 + -80.377450 43.692317 2326.00 + -80.379383 43.692017 2313.00 + -80.381383 43.691617 2308.00 + -80.383067 43.691167 2321.00 + -80.384517 43.690900 2322.00 + -80.385933 43.690600 2315.00 + -80.387383 43.690300 2308.00 + -80.388767 43.689917 2303.00 + -80.390167 43.689417 2293.00 + -80.391733 43.688967 2285.00 + -80.393350 43.688550 2285.00 + -80.394967 43.688200 2286.00 + -80.396533 43.687967 2283.00 + -80.398150 43.687783 2274.00 + -80.399833 43.687933 2270.00 + -80.401533 43.688150 2257.00 + -80.403333 43.688333 2245.00 + -80.405200 43.688550 2238.00 + -80.407017 43.688750 2236.00 + -80.408817 43.688933 2229.00 + -80.410733 43.689050 2218.00 + -80.412700 43.689217 2200.00 + -80.414783 43.689383 2185.00 + -80.416933 43.689467 2179.00 + -80.419050 43.689550 2168.00 + -80.421250 43.689633 2160.00 + -80.423350 43.689733 2161.00 + -80.425350 43.689800 2158.00 + -80.427233 43.689767 2157.00 + -80.429050 43.689750 2154.00 + -80.430717 43.689817 2157.00 + -80.432267 43.689700 2152.00 + -80.433717 43.689300 2146.00 + -80.435117 43.688617 2145.00 + -80.436383 43.687783 2152.00 + -80.437567 43.686700 2164.00 + -80.437483 43.685500 2187.00 + -80.436067 43.685533 2180.00 + -80.435817 43.686817 2164.00 + -80.436817 43.687933 2185.00 + -80.438267 43.688700 2200.00 + -80.439383 43.688033 2210.00 + -80.438317 43.687400 2211.00 + -80.437967 43.688667 2224.00 + -80.439433 43.689267 2248.00 + -80.440600 43.688600 2250.00 + -80.440100 43.687650 2256.00 + -80.438650 43.687383 2264.00 + -80.437233 43.687717 2286.00 + -80.436233 43.688467 2298.00 + -80.436633 43.689533 2311.00 + -80.437950 43.689933 2321.00 + -80.439050 43.689333 2321.00 + -80.439017 43.688250 2323.00 + -80.438000 43.687433 2335.00 + -80.436633 43.687017 2350.00 + -80.435417 43.687550 2351.00 + -80.435683 43.688650 2359.00 + -80.437017 43.689217 2373.00 + -80.438483 43.689117 2381.00 + -80.439583 43.688383 2380.00 + -80.438783 43.687517 2376.00 + -80.437600 43.688267 2385.00 + -80.437433 43.689500 2391.00 + -80.437600 43.690850 2390.00 + -80.437917 43.692167 2400.00 + -80.438350 43.693350 2409.00 + -80.438733 43.694550 2405.00 + -80.439133 43.695983 2395.00 + -80.439617 43.697583 2393.00 + -80.440233 43.699150 2384.00 + -80.440617 43.700883 2365.00 + -80.440817 43.702817 2342.00 + -80.440933 43.704917 2315.00 + -80.441017 43.707200 2286.00 + -80.441067 43.709483 2283.00 + -80.441067 43.711700 2273.00 + -80.441067 43.713883 2268.00 + -80.441083 43.715967 2270.00 + -80.441100 43.717900 2271.00 + -80.441067 43.719767 2268.00 + -80.441067 43.721600 2257.00 + -80.441033 43.723433 2250.00 + -80.441083 43.725267 2243.00 + -80.441150 43.727050 2246.00 + -80.441150 43.728750 2248.00 + -80.441067 43.730500 2236.00 + -80.441017 43.732283 2221.00 + -80.441083 43.734167 2210.00 + -80.441117 43.736100 2198.00 + -80.441000 43.738000 2188.00 + -80.440817 43.739817 2190.00 + -80.440683 43.741550 2183.00 + -80.440533 43.743333 2174.00 + -80.440433 43.745150 2179.00 + -80.440317 43.746883 2182.00 + -80.440217 43.748583 2178.00 + -80.440150 43.750267 2171.00 + -80.440150 43.752033 2159.00 + -80.440217 43.753917 2149.00 + -80.440117 43.755850 2143.00 + -80.439900 43.757817 2131.00 + -80.439650 43.759833 2119.00 + -80.439483 43.761867 2116.00 + -80.439367 43.763800 2114.00 + -80.439350 43.765900 2105.00 + -80.439267 43.767783 2096.00 + -80.439100 43.769617 2092.00 + -80.438983 43.771417 2078.00 + -80.438883 43.773233 2063.00 + -80.438717 43.775067 2050.00 + -80.438533 43.776933 2039.00 + -80.438350 43.778783 2032.00 + -80.438133 43.780583 2022.00 + -80.437867 43.782433 2009.00 + -80.437667 43.784350 1996.00 + -80.437583 43.786317 1986.00 + -80.437483 43.788283 1986.00 + -80.437350 43.790150 1990.00 + -80.437183 43.791950 1982.00 + -80.437017 43.793750 1975.00 + -80.436817 43.795533 1970.00 + -80.436533 43.797350 1951.00 + -80.435583 43.799100 1948.00 + -80.434467 43.800683 1946.00 + -80.433400 43.802300 1940.00 + -80.432333 43.803950 1934.00 + -80.431200 43.805617 1934.00 + -80.430017 43.807233 1942.00 + -80.428983 43.808717 1953.00 + -80.428033 43.810167 1959.00 + -80.427150 43.811550 1968.00 + -80.426250 43.812900 1975.00 + -80.425233 43.814183 1983.00 + -80.424300 43.815550 1988.00 + -80.423450 43.817000 1984.00 + -80.422700 43.818500 1973.00 + -80.421950 43.820067 1967.00 + -80.421167 43.821667 1965.00 + -80.420417 43.823317 1963.00 + -80.419767 43.825017 1961.00 + -80.418883 43.826717 1952.00 + -80.417900 43.828383 1949.00 + -80.417000 43.830017 1945.00 + -80.416100 43.831617 1937.00 + -80.415233 43.833283 1930.00 + -80.414467 43.835017 1926.00 + -80.414550 43.836550 1954.00 + -80.415967 43.836833 1971.00 + -80.416833 43.836150 1983.00 + -80.416800 43.835167 1987.00 + -80.415950 43.834283 1990.00 + -80.414400 43.833917 1990.00 + -80.412667 43.834267 1991.00 + -80.411367 43.835167 1992.00 + -80.410733 43.836367 1990.00 + -80.410783 43.837583 1992.00 + -80.411483 43.838650 1992.00 + -80.412783 43.839367 1992.00 + -80.414433 43.839783 1987.00 + -80.416150 43.840133 2000.00 + -80.417733 43.840467 2009.00 + -80.419267 43.840283 2024.00 + -80.419700 43.839367 2035.00 + -80.418933 43.838533 2046.00 + -80.417517 43.838117 2056.00 + -80.415950 43.838217 2068.00 + -80.414600 43.838883 2072.00 + -80.414333 43.840017 2078.00 + -80.415367 43.840783 2084.00 + -80.416800 43.840517 2088.00 + -80.417183 43.839533 2103.00 + -80.416300 43.838717 2113.00 + -80.414833 43.838500 2123.00 + -80.413467 43.838967 2126.00 + -80.412833 43.840000 2122.00 + -80.413317 43.841067 2125.00 + -80.414550 43.841783 2134.00 + -80.416017 43.841867 2140.00 + -80.417183 43.841333 2147.00 + -80.417700 43.840383 2155.00 + -80.417550 43.839333 2166.00 + -80.417000 43.838400 2175.00 + -80.415767 43.837800 2174.00 + -80.414150 43.837833 2173.00 + -80.412750 43.838483 2177.00 + -80.412167 43.839567 2182.00 + -80.412483 43.840667 2179.00 + -80.413417 43.841567 2184.00 + -80.414600 43.842400 2184.00 + -80.415950 43.843150 2183.00 + -80.417483 43.844000 2192.00 + -80.418817 43.844833 2208.00 + -80.420317 43.845233 2212.00 + -80.420533 43.844383 2216.00 + -80.419033 43.844117 2220.00 + -80.417350 43.844500 2235.00 + -80.416183 43.845350 2256.00 + -80.416550 43.846433 2266.00 + -80.417950 43.846567 2271.00 + -80.418200 43.845750 2270.00 + -80.416733 43.845333 2286.00 + -80.415317 43.845733 2303.00 + -80.414767 43.846767 2309.00 + -80.415017 43.848000 2309.00 + -80.415400 43.849250 2312.00 + -80.415917 43.850467 2314.00 + -80.416417 43.851667 2311.00 + -80.416967 43.852933 2297.00 + -80.417667 43.854317 2291.00 + -80.418367 43.855717 2295.00 + -80.419183 43.857000 2297.00 + -80.419883 43.858267 2289.00 + -80.420600 43.859600 2284.00 + -80.421333 43.860967 2276.00 + -80.421983 43.862367 2269.00 + -80.422467 43.863733 2273.00 + -80.422983 43.865000 2265.00 + -80.423650 43.866317 2249.00 + -80.424283 43.867767 2234.00 + -80.424950 43.869250 2228.00 + -80.425617 43.870733 2223.00 + -80.426183 43.872350 2216.00 + -80.426633 43.873817 2216.00 + -80.427167 43.875233 2210.00 + -80.427683 43.876683 2207.00 + -80.428050 43.878067 2208.00 + -80.428467 43.879417 2201.00 + -80.428933 43.880800 2192.00 + -80.429400 43.882233 2188.00 + -80.429883 43.883633 2186.00 + -80.430400 43.885017 2179.00 + -80.430900 43.886417 2176.00 + -80.431433 43.887800 2171.00 + -80.432117 43.889183 2161.00 + -80.432817 43.890633 2156.00 + -80.433500 43.892083 2155.00 + -80.434017 43.893567 2159.00 + -80.434433 43.895050 2153.00 + -80.434867 43.896517 2148.00 + -80.435383 43.897967 2138.00 + -80.435917 43.899450 2126.00 + -80.436367 43.900967 2120.00 + -80.436633 43.902383 2144.00 + -80.436700 43.903517 2162.00 + -80.436883 43.904767 2160.00 + -80.437083 43.906000 2168.00 + -80.437267 43.907083 2168.00 + -80.437550 43.908483 2167.00 + -80.437767 43.909767 2164.00 + -80.438000 43.911100 2148.00 + -80.438300 43.912567 2134.00 + -80.438567 43.914083 2125.00 + -80.438867 43.915617 2116.00 + -80.439233 43.917167 2107.00 + -80.439500 43.918733 2096.00 + -80.439800 43.920300 2092.00 + -80.440050 43.921750 2094.00 + -80.440233 43.923150 2089.00 + -80.440367 43.924550 2078.00 + -80.440500 43.926033 2067.00 + -80.440733 43.927533 2057.00 + -80.441083 43.929067 2045.00 + -80.441250 43.930633 2044.00 + -80.440950 43.932067 2055.00 + -80.440467 43.933383 2062.00 + -80.439800 43.934633 2066.00 + -80.439833 43.935900 2082.00 + -80.440867 43.936750 2095.00 + -80.441933 43.936400 2106.00 + -80.441417 43.935550 2111.00 + -80.439950 43.935333 2126.00 + -80.438650 43.935967 2138.00 + -80.438267 43.937133 2143.00 + -80.439083 43.938083 2148.00 + -80.440433 43.938050 2155.00 + -80.441050 43.937250 2162.00 + -80.440567 43.936333 2171.00 + -80.439300 43.935817 2181.00 + -80.437800 43.935650 2187.00 + -80.436283 43.936100 2186.00 + -80.435650 43.937250 2194.00 + -80.435917 43.938383 2199.00 + -80.437033 43.939000 2205.00 + -80.438350 43.939050 2209.00 + -80.439300 43.938517 2217.00 + -80.439433 43.937667 2219.00 + -80.438433 43.936900 2221.00 + -80.436917 43.936967 2235.00 + -80.435867 43.937783 2233.00 + -80.435567 43.939033 2227.00 + -80.435600 43.940333 2229.00 + -80.435900 43.941600 2227.00 + -80.436367 43.942883 2224.00 + -80.436917 43.944183 2224.00 + -80.437550 43.945450 2222.00 + -80.438183 43.946750 2218.00 + -80.438850 43.948033 2216.00 + -80.439650 43.949283 2220.00 + -80.440567 43.950633 2226.00 + -80.441450 43.951867 2226.00 + -80.442367 43.953133 2223.00 + -80.443217 43.954417 2219.00 + -80.443933 43.955667 2212.00 + -80.444650 43.956933 2201.00 + -80.445417 43.958217 2198.00 + -80.446150 43.959533 2189.00 + -80.446917 43.960833 2188.00 + -80.447400 43.962133 2188.00 + -80.447767 43.963417 2174.00 + -80.448250 43.964783 2160.00 + -80.448750 43.966200 2156.00 + -80.449233 43.967533 2158.00 + -80.449750 43.968817 2157.00 + -80.450267 43.970033 2149.00 + -80.450833 43.971333 2132.00 + -80.451617 43.972683 2123.00 + -80.452317 43.974100 2119.00 + -80.453133 43.975500 2111.00 + -80.453967 43.976867 2112.00 + -80.454783 43.978217 2112.00 + -80.455600 43.979500 2113.00 + -80.456467 43.980683 2111.00 + -80.457317 43.981900 2099.00 + -80.458150 43.983133 2095.00 + -80.458950 43.984350 2090.00 + -80.459767 43.985583 2079.00 + -80.460617 43.986867 2066.00 + -80.461417 43.988150 2059.00 + -80.462217 43.989317 2057.00 + -80.463150 43.990433 2045.00 + -80.464183 43.991567 2040.00 + -80.465217 43.992717 2037.00 + -80.466183 43.993883 2032.00 + -80.467200 43.995050 2018.00 + -80.468267 43.996267 2000.00 + -80.469367 43.997617 1985.00 + -80.470500 43.999000 1969.00 + -80.471600 44.000433 1957.00 + -80.472633 44.001883 1947.00 + -80.473717 44.003317 1937.00 + -80.474700 44.004767 1931.00 + -80.475683 44.006233 1921.00 + -80.476600 44.007700 1912.00 + -80.477517 44.009133 1903.00 + -80.478483 44.010517 1907.00 + -80.479333 44.011733 1917.00 + -80.480283 44.012867 1916.00 + -80.481350 44.014033 1921.00 + -80.482483 44.015183 1930.00 + -80.483600 44.016367 1941.00 + -80.483317 44.017867 1957.00 + -80.481683 44.018667 1966.00 + -80.480350 44.018050 1976.00 + -80.481067 44.017133 1982.00 + -80.482917 44.017283 1997.00 + -80.484033 44.018467 2020.00 + -80.483567 44.019867 2032.00 + -80.482067 44.020433 2042.00 + -80.481000 44.019783 2052.00 + -80.481600 44.018800 2058.00 + -80.483317 44.018867 2075.00 + -80.483833 44.020167 2096.00 + -80.482533 44.021067 2102.00 + -80.481183 44.020733 2107.00 + -80.481417 44.019850 2120.00 + -80.482783 44.019450 2129.00 + -80.484267 44.020300 2133.00 + -80.484067 44.021917 2130.00 + -80.482267 44.022700 2137.00 + -80.480933 44.022317 2161.00 + -80.480133 44.021600 2171.00 + -80.479417 44.020783 2183.00 + -80.479017 44.019917 2186.00 + -80.479917 44.019183 2183.00 + -80.481550 44.019483 2190.00 + -80.482700 44.020600 2199.00 + -80.483233 44.021967 2206.00 + -80.482517 44.023283 2212.00 + -80.480950 44.023783 2216.00 + -80.480100 44.023200 2230.00 + -80.481017 44.022600 2230.00 + -80.482667 44.022750 2235.00 + -80.484150 44.023533 2244.00 + -80.485333 44.024600 2245.00 + -80.486433 44.025783 2240.00 + -80.487517 44.026917 2234.00 + -80.488650 44.027950 2232.00 + -80.489733 44.029000 2224.00 + -80.490867 44.030117 2211.00 + -80.490700 44.031483 2204.00 + -80.489133 44.031717 2193.00 + -80.488350 44.030783 2184.00 + -80.487733 44.029650 2167.00 + -80.487133 44.028383 2153.00 + -80.486533 44.026967 2130.00 + -80.485917 44.025367 2110.00 + -80.485350 44.023717 2117.00 + -80.484900 44.022083 2119.00 + -80.484417 44.020517 2120.00 + -80.483933 44.018950 2119.00 + -80.483433 44.017433 2126.00 + -80.482917 44.015867 2127.00 + -80.482483 44.014250 2121.00 + -80.482000 44.012600 2110.00 + -80.481433 44.010950 2100.00 + -80.480783 44.009300 2091.00 + -80.480117 44.007650 2081.00 + -80.479450 44.005950 2067.00 + -80.478833 44.004217 2056.00 + -80.478217 44.002467 2046.00 + -80.477567 44.000683 2037.00 + -80.476900 43.998933 2035.00 + -80.476217 43.997183 2023.00 + -80.475617 43.995433 2017.00 + -80.475100 43.993717 2010.00 + -80.474567 43.992017 2000.00 + -80.473983 43.990317 1988.00 + -80.473483 43.988600 1980.00 + -80.473067 43.986883 1967.00 + -80.472633 43.985133 1953.00 + -80.472217 43.983417 1944.00 + -80.471883 43.981717 1932.00 + -80.471550 43.980033 1914.00 + -80.471183 43.978350 1899.00 + -80.470867 43.976633 1878.00 + -80.470417 43.974950 1869.00 + -80.469833 43.973117 1862.00 + -80.469183 43.971483 1859.00 + -80.468600 43.969833 1858.00 + -80.468067 43.968183 1853.00 + -80.467483 43.966483 1841.00 + -80.466867 43.964767 1831.00 + -80.466267 43.963100 1818.00 + -80.465717 43.961433 1804.00 + -80.465183 43.959783 1784.00 + -80.464617 43.958100 1767.00 + -80.464133 43.956400 1754.00 + -80.463783 43.954700 1744.00 + -80.463417 43.952983 1729.00 + -80.463033 43.951233 1722.00 + -80.462667 43.949483 1719.00 + -80.462250 43.947767 1713.00 + -80.461850 43.945983 1712.00 + -80.461467 43.944217 1720.00 + -80.461133 43.942483 1726.00 + -80.460783 43.940750 1721.00 + -80.460483 43.939017 1712.00 + -80.460200 43.937283 1708.00 + -80.459933 43.935550 1699.00 + -80.459633 43.933767 1684.00 + -80.459317 43.931950 1676.00 + -80.458950 43.930117 1668.00 + -80.458567 43.928283 1660.00 + -80.458133 43.926467 1666.00 + -80.457683 43.924733 1659.00 + -80.457267 43.923017 1652.00 + -80.456917 43.921317 1642.00 + -80.456533 43.919633 1628.00 + -80.456183 43.917933 1615.00 + -80.455817 43.916267 1596.00 + -80.455400 43.914567 1585.00 + -80.455067 43.912900 1571.00 + -80.454900 43.911283 1560.00 + -80.454733 43.909650 1538.00 + -80.454517 43.908017 1525.00 + -80.454383 43.906383 1521.00 + -80.454233 43.904767 1503.00 + -80.454033 43.902933 1479.00 + -80.453783 43.900950 1453.00 + -80.453517 43.898933 1441.00 + -80.453217 43.896983 1427.00 + -80.452867 43.895083 1418.00 + -80.452533 43.893200 1401.00 + -80.452217 43.891300 1387.00 + -80.451983 43.889383 1377.00 + -80.451767 43.887483 1367.00 + -80.451567 43.885533 1367.00 + -80.451367 43.883650 1371.00 + -80.451150 43.881833 1369.00 + -80.450833 43.880033 1362.00 + -80.450400 43.878250 1348.00 + -80.449850 43.876450 1336.00 + -80.449300 43.874617 1319.00 + -80.448950 43.872667 1305.00 + -80.448750 43.870633 1299.00 + -80.448717 43.868600 1295.00 + -80.448750 43.866567 1293.00 + -80.448800 43.864583 1290.00 + -80.448883 43.862600 1279.00 + -80.449067 43.860683 1276.00 + -80.449450 43.858883 1271.00 + -80.450083 43.857167 1263.00 + -80.450900 43.855517 1257.00 + -80.451850 43.853967 1251.00 + -80.452817 43.852467 1244.00 + -80.453533 43.850983 1239.00 + -80.454167 43.849367 1236.00 + -80.454617 43.847900 1225.00 + -80.455050 43.846350 1213.00 + -80.455317 43.844733 1201.00 + -80.455333 43.843067 1195.00 + -80.455217 43.841450 1200.00 + -80.455067 43.839950 1202.00 + -80.454850 43.838517 1207.00 + -80.454583 43.837267 1210.00 + -80.454167 43.836083 1196.00 + -80.453483 43.834967 1189.00 + -80.452700 43.833900 1177.00 + -80.451717 43.832800 1164.00 + -80.450633 43.831667 1155.00 + -80.449400 43.830550 1137.00 + -80.448217 43.829417 1118.00 + -80.447017 43.828350 1103.00 + -80.445867 43.827350 1096.00 + -80.444683 43.826433 1073.00 + -80.443350 43.825600 1048.00 + -80.441833 43.824883 1022.00 + -80.440083 43.824383 1000.00 + -80.438200 43.824050 980.00 + -80.436283 43.823900 962.00 + -80.434350 43.824083 947.00 + -80.432483 43.824517 932.00 + -80.430700 43.825133 913.00 + -80.428983 43.825817 891.00 + -80.427300 43.826550 873.00 + -80.425733 43.827333 857.00 + -80.424217 43.828167 840.00 + -80.422750 43.829083 823.00 + -80.421333 43.830050 801.00 + -80.420200 43.831217 784.00 + -80.419800 43.832567 773.00 + -80.420200 43.833850 761.00 + -80.421250 43.834967 750.00 + -80.422550 43.835967 737.00 + -80.423917 43.836917 729.00 + -80.425367 43.837883 717.00 + -80.426800 43.838917 699.00 + -80.428100 43.840067 684.00 + -80.429167 43.841300 671.00 + -80.430033 43.842617 664.00 + -80.430733 43.844033 658.00 + -80.431250 43.845567 657.00 + -80.431583 43.847067 651.00 + -80.431950 43.848550 642.00 + -80.432533 43.849917 634.00 + -80.433750 43.850917 626.00 + -80.435317 43.851267 618.00 + -80.436950 43.851283 604.00 + -80.438617 43.851017 588.00 + -80.440267 43.850617 571.00 + -80.441800 43.850050 556.00 + -80.443267 43.849383 538.00 + -80.444617 43.848583 521.00 + -80.445483 43.847517 507.00 + -80.445250 43.846283 497.00 + -80.444717 43.845050 483.00 + -80.444150 43.843833 474.00 + -80.443633 43.842650 468.00 + -80.443167 43.841567 467.00 + -80.442850 43.840800 468.00 + -80.442750 43.840550 468.00 + -80.442750 43.840550 469.00 + -80.442750 43.840550 469.00 + -80.442750 43.840550 469.00 + -80.442750 43.840550 469.00 + -80.442750 43.840550 469.00 + -80.442750 43.840567 468.00 + -80.442750 43.840567 468.00 + -80.442750 43.840567 468.00 + -80.442750 43.840567 467.00 + -80.442750 43.840567 467.00 + -80.442750 43.840567 467.00 + -80.442750 43.840567 467.00 + -80.442750 43.840567 466.00 + -80.442750 43.840567 466.00 + -80.442750 43.840567 466.00 + -80.442750 43.840567 466.00 + -80.442750 43.840567 466.00 + -80.442750 43.840567 465.00 + -80.442750 43.840567 465.00 + -80.442750 43.840567 465.00 + -80.442750 43.840567 465.00 + -80.442750 43.840567 466.00 + -80.442750 43.840567 467.00 + -80.442750 43.840567 468.00 + -80.442750 43.840567 469.00 + -80.442750 43.840567 469.00 + -80.442750 43.840567 470.00 + -80.442750 43.840550 471.00 + -80.442750 43.840550 471.00 + -80.442750 43.840550 472.00 + -80.442750 43.840550 472.00 + -80.442750 43.840550 472.00 + -80.442750 43.840550 473.00 + -80.442750 43.840550 473.00 + -80.442750 43.840550 473.00 + -80.442750 43.840550 474.00 + -80.442750 43.840550 474.00 + -80.442750 43.840550 474.00 + -80.442750 43.840550 473.00 + -80.442750 43.840550 473.00 + -80.442750 43.840550 473.00 + -80.442750 43.840550 473.00 + -80.442733 43.840533 473.00 + -80.442700 43.840483 473.00 + -80.442650 43.840433 473.00 + -80.442583 43.840383 473.00 + -80.442517 43.840317 473.00 + -80.442450 43.840267 473.00 + -80.442383 43.840200 473.00 + -80.442300 43.840150 473.00 + -80.442233 43.840117 473.00 + -80.442200 43.840067 473.00 + -80.442167 43.840017 473.00 + -80.442117 43.839983 473.00 + -80.442067 43.839933 473.00 + -80.442033 43.839900 474.00 + -80.441983 43.839850 473.00 + -80.441933 43.839817 473.00 + -80.441883 43.839767 473.00 + -80.441833 43.839733 473.00 + -80.441767 43.839683 473.00 + -80.441717 43.839650 473.00 + -80.441650 43.839617 473.00 + -80.441600 43.839567 474.00 + -80.441533 43.839533 474.00 + -80.441500 43.839483 474.00 + -80.441433 43.839450 474.00 + -80.441350 43.839400 473.00 + -80.441317 43.839367 473.00 + -80.441250 43.839317 473.00 + -80.441200 43.839283 473.00 + -80.441150 43.839250 473.00 + -80.441100 43.839200 473.00 + -80.441067 43.839167 473.00 + -80.441017 43.839133 473.00 + -80.440967 43.839083 473.00 + -80.440933 43.839050 473.00 + -80.440883 43.839017 473.00 + -80.440817 43.838983 473.00 + -80.440767 43.838933 473.00 + -80.440700 43.838900 473.00 + -80.440667 43.838867 473.00 + -80.440617 43.838817 473.00 + -80.440533 43.838767 473.00 + -80.440483 43.838733 473.00 + -80.440433 43.838700 472.00 + -80.440383 43.838650 473.00 + -80.440333 43.838600 473.00 + -80.440267 43.838567 473.00 + -80.440233 43.838533 473.00 + -80.440183 43.838483 474.00 + -80.440117 43.838450 474.00 + -80.440083 43.838417 473.00 + -80.440033 43.838383 474.00 + -80.439983 43.838350 474.00 + -80.439950 43.838300 474.00 + -80.439883 43.838267 474.00 + -80.439850 43.838233 474.00 + -80.439800 43.838183 475.00 + -80.439750 43.838150 475.00 + -80.439717 43.838117 475.00 + -80.439683 43.838083 476.00 + -80.439617 43.838050 476.00 + -80.439567 43.838000 476.00 + -80.439517 43.837967 477.00 + -80.439483 43.837933 477.00 + -80.439433 43.837900 477.00 + -80.439367 43.837867 478.00 + -80.439317 43.837817 478.00 + -80.439250 43.837783 478.00 + -80.439200 43.837733 478.00 + -80.439150 43.837700 478.00 + -80.439100 43.837667 478.00 + -80.439050 43.837633 478.00 + -80.439000 43.837600 478.00 + -80.438950 43.837550 478.00 + -80.438900 43.837517 478.00 + -80.438833 43.837483 478.00 + -80.438783 43.837450 478.00 + + + + 0 + 0 + 0 + 0.46 + 0.76 + 0.96 + 1.12 + 1.11 + 1.08 + 1.01 + 1.03 + 1.01 + 0.97 + 1 + 0.97 + 0.95 + 0.99 + 1.03 + 1.02 + 1.03 + 1.03 + 1.01 + 1.07 + 1.12 + 1.22 + 1.31 + 1.26 + 1.28 + 1.22 + 1.19 + 1.21 + 1.15 + 1.12 + 1.08 + 1.03 + 1.03 + 1.04 + 0.98 + 0.97 + 0.95 + 0.97 + 1.02 + 0.99 + 1 + 1 + 1.02 + 1.12 + 1.17 + 1.27 + 1.29 + 1.36 + 1.4 + 1.38 + 1.36 + 1.33 + 1.28 + 1.21 + 1.17 + 1.18 + 1.15 + 1.1 + 1.09 + 1.14 + 1.19 + 1.18 + 1.19 + 1.16 + 1.13 + 1.15 + 1.1 + 1.09 + 1.14 + 1.21 + 1.31 + 1.26 + 1.08 + 0.97 + 0.95 + 0.93 + 0.88 + 0.82 + 0.83 + 0.87 + 0.88 + 0.9 + 0.88 + 0.89 + 0.91 + 0.79 + 0.82 + 0.88 + 0.87 + 0.85 + 0.81 + 0.82 + 0.77 + 0.81 + 0.84 + 0.87 + 0.85 + 0.74 + 0.79 + 0.81 + 0.83 + 0.88 + 0.89 + 0.83 + 0.86 + 0.78 + 0.79 + 0.88 + 0.91 + 0.91 + 0.9 + 0.84 + 0.8 + 0.97 + 0.98 + 0.97 + 0.92 + 0.85 + 0.87 + 0.94 + 0.97 + 0.93 + 0.87 + 0.85 + 0.8 + 0.92 + 0.9 + 0.86 + 0.84 + 0.81 + 0.76 + 0.88 + 0.91 + 0.89 + 0.85 + 0.9 + 0.89 + 0.89 + 0.95 + 0.93 + 0.91 + 0.85 + 0.83 + 0.83 + 0.77 + 0.83 + 0.88 + 0.93 + 0.9 + 0.89 + 0.79 + 0.75 + 0.75 + 0.93 + 0.83 + 0.96 + 0.89 + 0.79 + 0.81 + 0.87 + 0.95 + 0.96 + 0.88 + 0.77 + 0.84 + 0.86 + 0.96 + 0.94 + 0.85 + 0.78 + 0.87 + 0.85 + 0.93 + 0.9 + 0.88 + 0.85 + 0.84 + 0.86 + 0.85 + 0.93 + 1 + 0.94 + 0.9 + 0.87 + 0.85 + 0.86 + 0.99 + 1.03 + 1.11 + 1.2 + 1.26 + 1.2 + 0.82 + 0.8 + 1.04 + 1.17 + 1.2 + 1.24 + 1.26 + 1.28 + 1.3 + 1.3 + 0.87 + 0.97 + 0.99 + 1.13 + 1.23 + 1.27 + 1.3 + 1.35 + 1.39 + 1.38 + 1.35 + 1.14 + 1.15 + 1.34 + 1.36 + 1.29 + 1.22 + 1.17 + 1.16 + 1.14 + 1.16 + 1.15 + 1.17 + 1.07 + 0.9 + 0.86 + 0.99 + 1.1 + 1.15 + 1.19 + 1.24 + 1.24 + 1.17 + 1.16 + 1.19 + 1.24 + 1.29 + 1.32 + 1.32 + 1.24 + 1.22 + 1.19 + 1.19 + 1.24 + 1.29 + 1.35 + 1.39 + 1.39 + 1.36 + 1.34 + 1.32 + 1.31 + 1.37 + 1.39 + 1.41 + 1.38 + 1.38 + 1.36 + 1.38 + 1.41 + 1.41 + 1.43 + 1.48 + 1.48 + 1.4 + 1.33 + 1.34 + 1.39 + 1.42 + 1.4 + 1.32 + 1.27 + 1.28 + 1.34 + 1.41 + 1.41 + 1.38 + 1.3 + 1.12 + 1 + 0.96 + 0.92 + 0.96 + 0.95 + 0.97 + 0.95 + 0.96 + 1.01 + 1.07 + 1.08 + 1.03 + 1 + 0.98 + 1.01 + 1.05 + 1.04 + 1.02 + 0.98 + 0.99 + 0.97 + 0.99 + 1.05 + 0.94 + 0.83 + 0.75 + 0.7 + 0.78 + 0.84 + 0.86 + 0.96 + 0.94 + 0.99 + 0.94 + 0.91 + 0.84 + 0.93 + 0.95 + 1.01 + 0.9 + 0.85 + 0.98 + 0.96 + 0.99 + 0.95 + 0.81 + 0.77 + 0.81 + 1.06 + 1 + 0.82 + 0.79 + 0.88 + 0.96 + 0.97 + 0.98 + 0.91 + 0.77 + 0.87 + 0.89 + 0.92 + 1.04 + 0.9 + 0.88 + 0.83 + 0.88 + 0.93 + 0.98 + 0.94 + 0.78 + 0.79 + 0.79 + 0.88 + 0.95 + 0.87 + 0.96 + 0.89 + 0.89 + 0.87 + 0.83 + 0.9 + 0.9 + 0.96 + 0.99 + 0.96 + 0.97 + 0.89 + 0.84 + 0.84 + 0.89 + 0.95 + 0.95 + 1.04 + 0.88 + 0.86 + 0.88 + 0.81 + 0.82 + 0.88 + 0.86 + 0.93 + 1.04 + 1.11 + 0.99 + 0.91 + 1.07 + 1.19 + 1.16 + 0.94 + 0.84 + 0.86 + 0.86 + 0.86 + 0.94 + 1 + 0.98 + 0.95 + 0.92 + 0.96 + 0.98 + 1.01 + 1.08 + 1.08 + 1.05 + 1.08 + 1.12 + 1.18 + 1.25 + 1.22 + 1.25 + 1.25 + 1.18 + 1.12 + 1.06 + 1.03 + 0.92 + 0.89 + 0.93 + 0.98 + 1.03 + 1.14 + 0.93 + 0.91 + 1.08 + 1.07 + 1.04 + 0.92 + 1.01 + 1.11 + 0.95 + 0.89 + 0.85 + 0.87 + 0.86 + 0.9 + 0.9 + 0.83 + 0.86 + 0.9 + 0.88 + 0.86 + 0.91 + 0.95 + 0.88 + 0.88 + 0.92 + 0.99 + 0.97 + 1.02 + 1.1 + 1.02 + 0.95 + 1.07 + 1.24 + 1.29 + 1.34 + 1.47 + 1.61 + 1.74 + 1.86 + 1.79 + 1.76 + 1.71 + 1.61 + 1.51 + 1.46 + 1.47 + 1.46 + 1.45 + 1.4 + 1.36 + 1.4 + 1.46 + 1.52 + 1.54 + 1.49 + 1.39 + 1.42 + 1.44 + 1.42 + 1.37 + 1.34 + 1.37 + 1.46 + 1.53 + 1.56 + 1.59 + 1.64 + 1.58 + 1.52 + 1.51 + 1.5 + 1.44 + 1.43 + 1.46 + 1.49 + 1.48 + 1.47 + 1.45 + 1.5 + 1.56 + 1.58 + 1.54 + 1.44 + 1.44 + 1.44 + 1.42 + 1.51 + 1.44 + 1.41 + 1.43 + 1.48 + 1.48 + 1.4 + 1.3 + 1.25 + 1.2 + 1.18 + 1.19 + 1.23 + 1.27 + 1.29 + 1.34 + 1.38 + 1.39 + 1.41 + 1.47 + 1.43 + 1.38 + 1.39 + 1.43 + 1.45 + 1.06 + 0.82 + 0.74 + 0.84 + 0.89 + 1.01 + 1.06 + 1.04 + 1.02 + 0.95 + 0.94 + 0.94 + 1.05 + 0.99 + 0.94 + 0.87 + 0.79 + 0.84 + 0.9 + 0.93 + 0.97 + 0.9 + 0.89 + 0.87 + 0.83 + 0.86 + 0.88 + 0.9 + 0.9 + 0.93 + 0.9 + 0.82 + 0.79 + 0.84 + 0.83 + 0.82 + 0.92 + 0.96 + 0.95 + 0.91 + 0.89 + 0.93 + 0.97 + 0.98 + 1.02 + 1.01 + 0.89 + 0.79 + 1.01 + 1.01 + 0.95 + 0.94 + 0.75 + 0.85 + 0.93 + 0.89 + 0.94 + 1.02 + 1.02 + 0.99 + 1 + 1.13 + 1.21 + 1.16 + 1.09 + 1.12 + 1.15 + 1.18 + 1.17 + 1.06 + 1.08 + 1.16 + 1.24 + 1.24 + 1.23 + 1.23 + 1.16 + 1.19 + 1.17 + 1.09 + 1.12 + 1.16 + 1.16 + 1.15 + 1.16 + 1.15 + 1.14 + 1.2 + 1.23 + 1.23 + 1.21 + 1.22 + 1.18 + 1.21 + 1.23 + 1.22 + 1.05 + 0.9 + 1.03 + 0.96 + 1.01 + 1.04 + 1.01 + 1.13 + 1.21 + 1.23 + 1.25 + 1.26 + 1.26 + 1.24 + 1.12 + 1.11 + 1.14 + 1.2 + 1.22 + 1.25 + 1.23 + 1.11 + 1.07 + 1.05 + 0.99 + 0.86 + 0.71 + 0.86 + 0.91 + 0.94 + 0.97 + 0.88 + 0.78 + 0.77 + 0.82 + 0.86 + 0.89 + 1.02 + 0.98 + 0.88 + 0.8 + 0.75 + 0.66 + 0.76 + 0.92 + 0.88 + 0.96 + 1.05 + 1.02 + 1.03 + 1.08 + 1.06 + 1.1 + 1.09 + 1.1 + 1.09 + 1.09 + 1.12 + 1.14 + 1.12 + 1.08 + 1.1 + 1.11 + 1.14 + 1.12 + 1.01 + 1.08 + 1.16 + 1.16 + 1.08 + 1.02 + 1.03 + 1.13 + 1.19 + 1.2 + 1.21 + 1.19 + 1.15 + 1.09 + 1.06 + 1.09 + 1.09 + 1.08 + 1.11 + 1.13 + 1.1 + 1 + 1.07 + 1.09 + 1.08 + 1.08 + 1.11 + 1.2 + 1.27 + 1.3 + 1.31 + 1.3 + 1.29 + 1.3 + 1.3 + 1.27 + 1.26 + 1.16 + 1.05 + 1.08 + 1.12 + 1.12 + 1.21 + 1.24 + 1.11 + 0.89 + 1 + 1.13 + 1.19 + 1.11 + 0.9 + 0.79 + 0.95 + 1.11 + 1.15 + 0.98 + 0.78 + 0.78 + 0.97 + 1.27 + 1.36 + 1.06 + 0.73 + 0.76 + 0.74 + 0.77 + 0.91 + 1.06 + 1.12 + 1.14 + 1.13 + 0.91 + 0.65 + 0.89 + 1.04 + 1.07 + 1.12 + 1.11 + 1.08 + 1.03 + 1.05 + 1.16 + 1.13 + 0.9 + 0.9 + 1.01 + 1.11 + 1.24 + 1.36 + 1.34 + 1.31 + 1.28 + 1.26 + 1.25 + 1.3 + 1.32 + 1.35 + 1.36 + 1.37 + 1.37 + 1.42 + 1.44 + 1.45 + 1.47 + 1.44 + 1.45 + 1.42 + 1.39 + 1.39 + 1.4 + 1.39 + 1.4 + 1.42 + 1.38 + 1.36 + 1.36 + 1.37 + 1.38 + 1.36 + 1.36 + 1.36 + 1.35 + 1.36 + 1.42 + 1.39 + 1.36 + 1.36 + 1.37 + 1.38 + 1.38 + 1.37 + 1.4 + 1.41 + 1.4 + 1.41 + 1.43 + 1.41 + 1.39 + 1.4 + 1.4 + 1.39 + 1.4 + 1.45 + 1.47 + 1.48 + 1.49 + 1.44 + 1.41 + 1.37 + 1.36 + 1.37 + 1.35 + 1.37 + 1.37 + 1.32 + 1.29 + 1.31 + 1.31 + 1.29 + 1.35 + 1.53 + 1.63 + 1.59 + 1.55 + 1.51 + 1.51 + 1.54 + 1.52 + 1.54 + 1.53 + 1.49 + 1.45 + 1.44 + 1.46 + 1.47 + 1.54 + 1.6 + 1.63 + 1.63 + 1.6 + 1.58 + 1.57 + 1.48 + 1.44 + 1.41 + 1.37 + 1.34 + 1.28 + 1.23 + 1.2 + 1.22 + 1.27 + 1.32 + 1.33 + 1.24 + 1.18 + 1.1 + 0.97 + 0.98 + 0.93 + 1.01 + 1.07 + 1.1 + 1.18 + 1.11 + 1.09 + 1 + 1.01 + 1.03 + 1.07 + 1.09 + 1.11 + 1.12 + 1.12 + 1.13 + 1.15 + 1.14 + 1.1 + 1.1 + 1.11 + 1.11 + 1.13 + 1.15 + 1.08 + 1.07 + 1.07 + 1.09 + 1.11 + 1.15 + 1.18 + 1.17 + 1.16 + 1.16 + 1.23 + 1.25 + 1.2 + 1.18 + 1.12 + 1.02 + 0.94 + 0.95 + 1 + 1 + 0.99 + 0.99 + 1.01 + 0.98 + 1.01 + 1.03 + 1.01 + 0.95 + 0.85 + 0.38 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0.01 + 0.06 + 0.06 + 0.05 + 0.06 + 0.05 + 0.07 + 0.06 + 0.02 + 0.04 + 0.04 + 0.03 + 0.04 + 0.04 + 0.04 + 0.04 + 0.04 + 0.04 + 0.05 + 0.05 + 0.04 + 0.05 + 0.02 + 0.02 + 0.03 + 0.05 + 0.05 + 0.04 + 0.02 + 0.04 + 0.03 + 0.04 + 0.04 + 0.03 + 0.04 + 0.04 + 0.04 + 0.04 + 0.04 + 0.05 + 0.05 + 0.04 + 0.03 + 0.03 + 0.05 + 0.05 + 0.04 + 0.04 + 0.04 + 0.04 + 0.02 + 0.02 + 0.04 + 0.02 + 0.03 + 0.03 + 0.04 + 0.04 + 0.03 + 0.03 + 0.05 + 0.04 + 0.04 + 0.04 + 0.03 + 0.03 + 0.04 + 0.05 + 0.05 + 0.04 + 0.04 + 0.04 + 0.04 + 0.03 + 0.03 + 0.04 + 0.04 + + + 9 + 9 + 9 + 9 + 8 + 9 + 13 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 8 + 9 + 9 + 11 + 10 + 11 + 9 + 10 + 10 + 9 + 9 + 8 + 10 + 10 + 9 + 10 + 11 + 8 + 9 + 8 + 10 + 10 + 9 + 8 + 10 + 9 + 9 + 9 + 10 + 9 + 10 + 10 + 8 + 10 + 10 + 10 + 10 + 9 + 10 + 8 + 7 + 11 + 10 + 11 + 9 + 8 + 8 + 10 + 10 + 10 + 7 + 10 + 8 + 11 + 15 + 9 + 8 + 9 + 10 + 11 + 10 + 9 + 9 + 9 + 10 + 9 + 8 + 10 + 11 + 11 + 10 + 10 + 10 + 10 + 10 + 10 + 11 + 10 + 11 + 10 + 9 + 10 + 11 + 10 + 9 + 11 + 10 + 10 + 10 + 10 + 11 + 9 + 10 + 10 + 10 + 10 + 12 + 9 + 10 + 10 + 10 + 10 + 11 + 10 + 12 + 11 + 10 + 10 + 11 + 10 + 10 + 11 + 11 + 9 + 10 + 9 + 10 + 9 + 10 + 10 + 10 + 11 + 9 + 9 + 10 + 10 + 9 + 10 + 11 + 10 + 10 + 10 + 11 + 10 + 10 + 9 + 12 + 9 + 11 + 10 + 10 + 11 + 11 + 10 + 11 + 11 + 9 + 13 + 10 + 10 + 10 + 11 + 9 + 13 + 9 + 11 + 10 + 9 + 8 + 11 + 11 + 8 + 10 + 10 + 10 + 11 + 12 + 11 + 10 + 12 + 8 + 9 + 9 + 10 + 15 + 10 + 8 + 10 + 9 + 9 + 9 + 9 + 10 + 8 + 12 + 5 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 11 + 8 + 8 + 9 + 10 + 10 + 10 + 9 + 9 + 9 + 11 + 9 + 10 + 7 + 9 + 8 + 9 + 10 + 9 + 10 + 11 + 10 + 8 + 9 + 9 + 9 + 9 + 8 + 10 + 7 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 8 + 8 + 8 + 8 + 11 + 8 + 10 + 10 + 8 + 9 + 8 + 7 + 8 + 12 + 10 + 9 + 9 + 8 + 9 + 10 + 9 + 8 + 8 + 8 + 9 + 9 + 11 + 9 + 8 + 9 + 9 + 10 + 11 + 9 + 10 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 11 + 13 + 10 + 11 + 11 + 10 + 10 + 9 + 9 + 9 + 9 + 12 + 10 + 11 + 11 + 8 + 11 + 11 + 11 + 13 + 9 + 12 + 13 + 10 + 10 + 11 + 11 + 11 + 9 + 14 + 11 + 10 + 12 + 11 + 10 + 10 + 9 + 10 + 9 + 12 + 10 + 9 + 13 + 8 + 11 + 10 + 10 + 10 + 11 + 12 + 10 + 11 + 9 + 10 + 10 + 8 + 12 + 8 + 9 + 10 + 12 + 11 + 9 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 9 + 9 + 12 + 10 + 10 + 10 + 9 + 9 + 10 + 8 + 10 + 9 + 10 + 8 + 9 + 10 + 9 + 11 + 9 + 9 + 9 + 9 + 8 + 10 + 10 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 10 + 11 + 10 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 10 + 9 + 10 + 9 + 10 + 10 + 8 + 11 + 11 + 11 + 9 + 13 + 13 + 16 + 11 + 10 + 12 + 11 + 11 + 8 + 12 + 10 + 9 + 10 + 10 + 10 + 10 + 11 + 9 + 9 + 9 + 12 + 15 + 10 + 10 + 9 + 8 + 9 + 10 + 8 + 7 + 10 + 10 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 7 + 9 + 9 + 9 + 8 + 9 + 9 + 10 + 10 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 10 + 8 + 9 + 10 + 10 + 9 + 9 + 9 + 9 + 10 + 9 + 10 + 8 + 9 + 9 + 8 + 11 + 7 + 8 + 9 + 10 + 9 + 10 + 9 + 9 + 9 + 10 + 10 + 9 + 9 + 11 + 9 + 8 + 9 + 8 + 9 + 8 + 10 + 9 + 9 + 9 + 11 + 12 + 9 + 9 + 10 + 10 + 10 + 9 + 10 + 9 + 10 + 8 + 10 + 9 + 11 + 9 + 10 + 9 + 9 + 9 + 10 + 10 + 10 + 11 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 9 + 9 + 9 + 9 + 10 + 10 + 9 + 9 + 10 + 9 + 10 + 9 + 9 + 9 + 14 + 11 + 9 + 9 + 10 + 12 + 11 + 13 + 10 + 10 + 9 + 9 + 9 + 9 + 8 + 9 + 10 + 10 + 8 + 10 + 8 + 9 + 10 + 8 + 9 + 10 + 9 + 9 + 10 + 10 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 8 + 10 + 10 + 11 + 11 + 9 + 10 + 8 + 10 + 9 + 8 + 9 + 9 + 10 + 9 + 9 + 10 + 10 + 8 + 9 + 9 + 9 + 9 + 9 + 10 + 8 + 9 + 12 + 10 + 11 + 11 + 11 + 11 + 9 + 10 + 10 + 9 + 10 + 10 + 9 + 9 + 11 + 9 + 10 + 8 + 10 + 9 + 10 + 11 + 9 + 10 + 10 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 8 + 9 + 8 + 9 + 10 + 11 + 9 + 9 + 10 + 8 + 9 + 10 + 10 + 9 + 8 + 9 + 10 + 10 + 9 + 10 + 9 + 9 + 10 + 8 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 10 + 9 + 10 + 10 + 8 + 10 + 10 + 10 + 13 + 11 + 11 + 12 + 11 + 9 + 8 + 10 + 11 + 9 + 10 + 13 + 12 + 11 + 11 + 9 + 11 + 11 + 12 + 12 + 8 + 10 + 9 + 10 + 11 + 11 + 10 + 9 + 9 + 12 + 10 + 11 + 10 + 8 + 8 + 9 + 9 + 9 + 9 + 12 + 12 + 12 + 9 + 9 + 9 + 9 + 10 + 8 + 9 + 9 + 11 + 9 + 10 + 10 + 8 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 10 + 10 + 9 + 9 + 11 + 9 + 9 + 10 + 8 + 9 + 9 + 9 + 10 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 11 + 8 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 11 + 8 + 9 + 9 + 9 + 8 + 8 + 10 + 6 + 9 + 9 + 10 + 10 + 9 + 10 + 7 + 9 + 9 + 10 + 8 + 9 + 10 + 8 + 11 + 10 + 8 + 9 + 9 + 9 + 7 + 9 + 9 + 10 + 10 + 9 + 10 + 9 + 8 + 9 + 10 + 9 + 9 + 10 + 8 + 8 + 9 + 9 + 10 + 9 + 8 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 5 + 9 + 9 + 10 + 7 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 10 + 11 + 9 + 9 + 9 + 8 + 9 + 10 + 9 + 9 + 9 + 8 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 10 + 11 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 8 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 9 + 10 + 10 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 8 + 8 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 8 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + + + 12 + 12 + 12 + 12 + 12 + 12 + 12 + 12 + 12 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 9 + 10 + 9 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 10 + 9 + 9 + 9 + 9 + 9 + 10 + 9 + 9 + 9 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 12 + 12 + 12 + 12 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 10 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 9 + 10 + 10 + 10 + 10 + 10 + + + + + + + PRESALTTRK + + + +

Description IGCHDRS~HFFXA015~HFPLTPILOTINCHARGE:CHRIS RAZL~HFCM2CREW2: ~HFGTYGLIDERTYPE:LS 4~HFGIDGLIDERID:~HFDTM100GPSDATUM:WGS-1984~HFRFWFIRMWAREVERSION:1.60~HFRHWHARDWAREVERSION:1.00~HFFTYFRTYPE:LX Eos~HFGPS:uBLOX-LEA-6S,50ch,max50000m~HFPRSPRESSALTSENSOR:INTERSEMA,MS5607,max15000m~HFCIDCOMPETITIONID:~HFCCLCOMPETITIONCLASS:~
Distance 90.4 mi
Min Alt 1437.008 ft
Max Alt 7585.302 ft
Min Speed 0.8 mph
Max Speed 113.8 mph
Avg Speed 60.4 mph
Start Time 2022-07-16T19:41:31Z
End Time 2022-07-16T21:11:20Z
+]]> + + + 2022-07-16T19:41:31Z + 2022-07-16T21:11:20Z + + + Path + #lineStyle + + 1 + absolute + +-80.443083,43.840333,438.00 +-80.443083,43.840333,438.00 +-80.443083,43.840333,438.00 +-80.442617,43.839933,438.00 +-80.441667,43.839200,439.00 +-80.440567,43.838433,439.00 +-80.439233,43.837517,442.00 +-80.437850,43.836533,460.00 +-80.436450,43.835600,476.00 +-80.435117,43.834700,498.00 +-80.433833,43.833833,515.00 +-80.432483,43.833000,527.00 +-80.431400,43.832050,543.00 +-80.430767,43.830933,551.00 +-80.430767,43.829700,558.00 +-80.431133,43.828533,569.00 +-80.431967,43.827483,572.00 +-80.433300,43.826650,587.00 +-80.434950,43.826117,598.00 +-80.436800,43.825667,613.00 +-80.438317,43.825250,630.00 +-80.440050,43.825017,645.00 +-80.441817,43.825250,653.00 +-80.443417,43.825967,658.00 +-80.444700,43.827117,664.00 +-80.445300,43.828633,674.00 +-80.445100,43.830217,693.00 +-80.444250,43.831683,701.00 +-80.442550,43.832883,707.00 +-80.440667,43.833500,716.00 +-80.438600,43.833683,723.00 +-80.436650,43.833267,731.00 +-80.435117,43.832383,738.00 +-80.434150,43.831200,747.00 +-80.433833,43.829900,760.00 +-80.434267,43.828650,770.00 +-80.435350,43.827617,784.00 +-80.436817,43.826950,810.00 +-80.438400,43.826483,822.00 +-80.439983,43.826083,832.00 +-80.441567,43.825700,842.00 +-80.443217,43.825317,850.00 +-80.444850,43.824883,870.00 +-80.446267,43.824200,887.00 +-80.447117,43.823100,905.00 +-80.447167,43.821850,922.00 +-80.446417,43.820617,924.00 +-80.444900,43.819717,929.00 +-80.442883,43.819250,938.00 +-80.440683,43.819350,953.00 +-80.438333,43.820033,962.00 +-80.436700,43.821067,973.00 +-80.434900,43.822217,992.00 +-80.432783,43.822983,1004.00 +-80.430450,43.823183,1014.00 +-80.428217,43.822950,1027.00 +-80.426083,43.822233,1042.00 +-80.424683,43.821150,1058.00 +-80.423833,43.819800,1067.00 +-80.423767,43.818350,1077.00 +-80.424400,43.817033,1096.00 +-80.425667,43.816033,1102.00 +-80.427400,43.815400,1110.00 +-80.429400,43.815200,1120.00 +-80.431450,43.815367,1136.00 +-80.433483,43.815633,1154.00 +-80.435483,43.815517,1174.00 +-80.437300,43.814950,1194.00 +-80.438550,43.813850,1217.00 +-80.438850,43.812467,1236.00 +-80.438283,43.811150,1262.00 +-80.437033,43.810083,1288.00 +-80.435283,43.809367,1316.00 +-80.432900,43.809350,1327.00 +-80.430750,43.809950,1342.00 +-80.429117,43.809300,1347.00 +-80.427983,43.808300,1348.00 +-80.427067,43.807283,1346.00 +-80.425767,43.806633,1341.00 +-80.424533,43.807233,1336.00 +-80.424433,43.808267,1333.00 +-80.425217,43.809133,1330.00 +-80.426517,43.809633,1328.00 +-80.428017,43.809800,1328.00 +-80.429567,43.809767,1320.00 +-80.431083,43.809567,1319.00 +-80.432583,43.809317,1325.00 +-80.434083,43.808967,1336.00 +-80.434733,43.808067,1349.00 +-80.433900,43.807333,1358.00 +-80.432517,43.807600,1373.00 +-80.431917,43.808567,1383.00 +-80.432533,43.809533,1390.00 +-80.433900,43.809750,1400.00 +-80.434967,43.809000,1408.00 +-80.434883,43.808033,1423.00 +-80.433683,43.807633,1437.00 +-80.432600,43.808233,1454.00 +-80.432683,43.809283,1459.00 +-80.433933,43.809817,1471.00 +-80.435117,43.809400,1485.00 +-80.435283,43.808483,1490.00 +-80.434300,43.807800,1503.00 +-80.432933,43.807950,1522.00 +-80.432150,43.808833,1535.00 +-80.432667,43.809950,1540.00 +-80.434017,43.810300,1555.00 +-80.435250,43.809933,1567.00 +-80.436217,43.809083,1582.00 +-80.435717,43.808200,1591.00 +-80.434367,43.808000,1597.00 +-80.433183,43.808700,1613.00 +-80.433233,43.809800,1632.00 +-80.434617,43.810167,1643.00 +-80.435617,43.809400,1656.00 +-80.435033,43.808533,1666.00 +-80.433600,43.808583,1670.00 +-80.432950,43.809700,1689.00 +-80.433483,43.810800,1703.00 +-80.435017,43.811067,1717.00 +-80.436033,43.810283,1729.00 +-80.435650,43.809317,1738.00 +-80.434000,43.809100,1744.00 +-80.432850,43.809933,1761.00 +-80.432517,43.811067,1777.00 +-80.433733,43.811683,1786.00 +-80.434950,43.811167,1797.00 +-80.434833,43.810183,1809.00 +-80.433483,43.809817,1815.00 +-80.432267,43.810533,1833.00 +-80.432500,43.811567,1848.00 +-80.433817,43.811933,1856.00 +-80.434867,43.811283,1869.00 +-80.434717,43.810367,1881.00 +-80.433517,43.809850,1892.00 +-80.432033,43.810100,1906.00 +-80.431267,43.811050,1910.00 +-80.431600,43.812083,1912.00 +-80.432783,43.812750,1912.00 +-80.434267,43.812533,1919.00 +-80.434917,43.811567,1931.00 +-80.434283,43.810550,1941.00 +-80.432750,43.810283,1961.00 +-80.431500,43.810967,1973.00 +-80.431317,43.812017,1980.00 +-80.432133,43.812850,1981.00 +-80.433450,43.813300,1989.00 +-80.434850,43.813383,2002.00 +-80.435733,43.812700,2004.00 +-80.435333,43.811700,2000.00 +-80.433933,43.811300,2007.00 +-80.432483,43.811700,2024.00 +-80.432167,43.812750,2029.00 +-80.433300,43.813467,2039.00 +-80.434483,43.813100,2049.00 +-80.434733,43.812217,2055.00 +-80.433833,43.811417,2056.00 +-80.432450,43.811633,2076.00 +-80.431950,43.812650,2075.00 +-80.432867,43.813567,2085.00 +-80.434233,43.813417,2100.00 +-80.434767,43.812550,2104.00 +-80.434017,43.811700,2113.00 +-80.432517,43.811800,2125.00 +-80.431917,43.812883,2131.00 +-80.432817,43.813767,2140.00 +-80.434117,43.813517,2152.00 +-80.434300,43.812600,2155.00 +-80.433133,43.812000,2172.00 +-80.431817,43.812517,2176.00 +-80.431600,43.813667,2184.00 +-80.432667,43.814417,2193.00 +-80.433900,43.814017,2200.00 +-80.434000,43.813067,2202.00 +-80.432650,43.812833,2214.00 +-80.431700,43.813650,2213.00 +-80.432317,43.814683,2213.00 +-80.433767,43.815017,2218.00 +-80.435250,43.814850,2216.00 +-80.436467,43.814283,2210.00 +-80.436550,43.813300,2206.00 +-80.435483,43.812550,2216.00 +-80.434117,43.812117,2213.00 +-80.432633,43.812583,2211.00 +-80.432300,43.813750,2220.00 +-80.433433,43.814467,2222.00 +-80.434767,43.814050,2225.00 +-80.434717,43.813033,2234.00 +-80.433383,43.812633,2236.00 +-80.432083,43.813150,2227.00 +-80.432117,43.814433,2226.00 +-80.432550,43.815750,2222.00 +-80.433067,43.817150,2219.00 +-80.433650,43.818650,2219.00 +-80.434467,43.820100,2231.00 +-80.435967,43.820100,2247.00 +-80.436100,43.819167,2243.00 +-80.435233,43.818217,2221.00 +-80.433733,43.817283,2213.00 +-80.432033,43.816450,2211.00 +-80.430167,43.815717,2208.00 +-80.428183,43.815050,2203.00 +-80.426133,43.814483,2197.00 +-80.424017,43.813967,2190.00 +-80.421867,43.813417,2193.00 +-80.420200,43.812900,2222.00 +-80.418750,43.812450,2214.00 +-80.417233,43.811883,2212.00 +-80.415567,43.811367,2201.00 +-80.413683,43.810767,2191.00 +-80.411750,43.810050,2182.00 +-80.409733,43.809367,2173.00 +-80.407667,43.808667,2162.00 +-80.405600,43.807817,2153.00 +-80.403567,43.806883,2148.00 +-80.401533,43.805983,2143.00 +-80.399700,43.805167,2155.00 +-80.397983,43.804483,2148.00 +-80.396000,43.803917,2126.00 +-80.393850,43.803217,2116.00 +-80.391833,43.802383,2112.00 +-80.390033,43.801517,2109.00 +-80.388400,43.800600,2107.00 +-80.386883,43.799633,2101.00 +-80.385317,43.798533,2096.00 +-80.383900,43.797517,2090.00 +-80.382517,43.796450,2089.00 +-80.381283,43.795317,2091.00 +-80.380267,43.794083,2106.00 +-80.379533,43.792983,2118.00 +-80.378967,43.791983,2118.00 +-80.378450,43.790883,2104.00 +-80.377833,43.789633,2092.00 +-80.377183,43.788300,2083.00 +-80.376517,43.786900,2076.00 +-80.375850,43.785467,2060.00 +-80.375217,43.783933,2050.00 +-80.374633,43.782500,2051.00 +-80.374117,43.781100,2044.00 +-80.373717,43.779650,2032.00 +-80.373333,43.778150,2018.00 +-80.373000,43.776583,2004.00 +-80.372633,43.774950,1992.00 +-80.372267,43.773317,1985.00 +-80.371933,43.771733,1985.00 +-80.371617,43.770217,1985.00 +-80.371150,43.768733,1982.00 +-80.370617,43.767300,1978.00 +-80.370033,43.765850,1966.00 +-80.369367,43.764333,1955.00 +-80.368717,43.762750,1942.00 +-80.368050,43.761083,1932.00 +-80.367367,43.759417,1921.00 +-80.366800,43.757733,1917.00 +-80.366283,43.756100,1909.00 +-80.365783,43.754467,1903.00 +-80.365367,43.752833,1895.00 +-80.364917,43.751200,1880.00 +-80.364450,43.749517,1875.00 +-80.363883,43.747783,1870.00 +-80.363350,43.746083,1873.00 +-80.362750,43.744417,1873.00 +-80.362200,43.742750,1873.00 +-80.361567,43.741083,1868.00 +-80.360983,43.739400,1853.00 +-80.360383,43.737667,1845.00 +-80.359733,43.735950,1839.00 +-80.359050,43.734200,1824.00 +-80.358317,43.732417,1815.00 +-80.357617,43.730483,1816.00 +-80.357033,43.728850,1818.00 +-80.356500,43.727217,1811.00 +-80.355983,43.725550,1801.00 +-80.355350,43.723833,1787.00 +-80.354700,43.722133,1773.00 +-80.354083,43.720483,1764.00 +-80.353583,43.718900,1757.00 +-80.353150,43.717333,1749.00 +-80.352650,43.715750,1736.00 +-80.352000,43.714067,1721.00 +-80.351183,43.712400,1717.00 +-80.350367,43.710750,1714.00 +-80.349417,43.709217,1716.00 +-80.348567,43.707833,1730.00 +-80.347850,43.706617,1737.00 +-80.346983,43.705567,1733.00 +-80.346517,43.704450,1729.00 +-80.347133,43.703383,1725.00 +-80.348217,43.702467,1733.00 +-80.349300,43.701550,1732.00 +-80.350450,43.700683,1726.00 +-80.351683,43.699867,1716.00 +-80.352967,43.699033,1704.00 +-80.354367,43.698200,1695.00 +-80.355867,43.697400,1686.00 +-80.357267,43.696533,1684.00 +-80.358633,43.695717,1676.00 +-80.359983,43.694967,1668.00 +-80.361317,43.694167,1660.00 +-80.362583,43.693250,1655.00 +-80.363833,43.692283,1654.00 +-80.365100,43.691367,1659.00 +-80.366250,43.690450,1666.00 +-80.367400,43.689550,1671.00 +-80.368283,43.688550,1681.00 +-80.367300,43.687633,1691.00 +-80.365600,43.687550,1703.00 +-80.364500,43.688450,1714.00 +-80.364900,43.689467,1719.00 +-80.366100,43.689900,1724.00 +-80.367183,43.689550,1727.00 +-80.367983,43.688800,1724.00 +-80.368633,43.687900,1721.00 +-80.369267,43.686917,1729.00 +-80.369983,43.685883,1734.00 +-80.369617,43.684767,1748.00 +-80.368050,43.684667,1753.00 +-80.367250,43.685667,1754.00 +-80.368033,43.686633,1769.00 +-80.369367,43.686833,1786.00 +-80.369500,43.685817,1794.00 +-80.368050,43.685450,1802.00 +-80.366983,43.686317,1807.00 +-80.367450,43.687450,1826.00 +-80.368683,43.687833,1841.00 +-80.369167,43.686833,1849.00 +-80.368133,43.685917,1865.00 +-80.366500,43.685933,1876.00 +-80.365517,43.686883,1891.00 +-80.366150,43.687817,1907.00 +-80.367383,43.687667,1923.00 +-80.367483,43.686750,1938.00 +-80.366167,43.686217,1939.00 +-80.365267,43.687250,1942.00 +-80.366250,43.688050,1961.00 +-80.367550,43.687867,1976.00 +-80.367517,43.686917,1987.00 +-80.366083,43.686533,1992.00 +-80.364700,43.687183,1998.00 +-80.364267,43.688350,2009.00 +-80.364617,43.689517,2025.00 +-80.365867,43.690117,2039.00 +-80.366983,43.689567,2040.00 +-80.366717,43.688517,2055.00 +-80.365267,43.688317,2071.00 +-80.364017,43.689133,2070.00 +-80.364117,43.690333,2088.00 +-80.364917,43.691217,2090.00 +-80.366333,43.691267,2090.00 +-80.367100,43.690400,2093.00 +-80.367033,43.689267,2105.00 +-80.365683,43.688767,2118.00 +-80.364567,43.689583,2122.00 +-80.365217,43.690467,2133.00 +-80.366500,43.690333,2140.00 +-80.366967,43.689433,2155.00 +-80.366333,43.688550,2159.00 +-80.364783,43.688167,2167.00 +-80.363500,43.688717,2173.00 +-80.363200,43.689833,2160.00 +-80.363667,43.690933,2166.00 +-80.364467,43.691900,2175.00 +-80.365433,43.692750,2176.00 +-80.366800,43.692783,2170.00 +-80.367183,43.691783,2174.00 +-80.366267,43.690900,2186.00 +-80.364750,43.690600,2191.00 +-80.363100,43.690967,2204.00 +-80.361700,43.691650,2215.00 +-80.360750,43.692650,2219.00 +-80.361067,43.693750,2220.00 +-80.362450,43.694067,2217.00 +-80.363417,43.693350,2215.00 +-80.363200,43.692317,2217.00 +-80.361917,43.691600,2227.00 +-80.360317,43.691600,2234.00 +-80.358933,43.692300,2223.00 +-80.358833,43.693467,2230.00 +-80.360000,43.694067,2229.00 +-80.361533,43.694000,2225.00 +-80.362967,43.694000,2230.00 +-80.364383,43.693883,2232.00 +-80.365833,43.693700,2235.00 +-80.367333,43.693500,2247.00 +-80.368850,43.693317,2248.00 +-80.370533,43.693117,2248.00 +-80.372367,43.692817,2248.00 +-80.374183,43.692600,2253.00 +-80.375767,43.692517,2248.00 +-80.377450,43.692317,2229.00 +-80.379383,43.692017,2217.00 +-80.381383,43.691617,2213.00 +-80.383067,43.691167,2222.00 +-80.384517,43.690900,2224.00 +-80.385933,43.690600,2217.00 +-80.387383,43.690300,2211.00 +-80.388767,43.689917,2205.00 +-80.390167,43.689417,2196.00 +-80.391733,43.688967,2189.00 +-80.393350,43.688550,2188.00 +-80.394967,43.688200,2188.00 +-80.396533,43.687967,2185.00 +-80.398150,43.687783,2177.00 +-80.399833,43.687933,2173.00 +-80.401533,43.688150,2162.00 +-80.403333,43.688333,2151.00 +-80.405200,43.688550,2146.00 +-80.407017,43.688750,2144.00 +-80.408817,43.688933,2128.00 +-80.410733,43.689050,2128.00 +-80.412700,43.689217,2113.00 +-80.414783,43.689383,2100.00 +-80.416933,43.689467,2094.00 +-80.419050,43.689550,2085.00 +-80.421250,43.689633,2078.00 +-80.423350,43.689733,2078.00 +-80.425350,43.689800,2074.00 +-80.427233,43.689767,2074.00 +-80.429050,43.689750,2071.00 +-80.430717,43.689817,2072.00 +-80.432267,43.689700,2068.00 +-80.433717,43.689300,2060.00 +-80.435117,43.688617,2059.00 +-80.436383,43.687783,2067.00 +-80.437567,43.686700,2080.00 +-80.437483,43.685500,2099.00 +-80.436067,43.685533,2091.00 +-80.435817,43.686817,2076.00 +-80.436817,43.687933,2096.00 +-80.438267,43.688700,2109.00 +-80.439383,43.688033,2120.00 +-80.438317,43.687400,2122.00 +-80.437967,43.688667,2130.00 +-80.439433,43.689267,2151.00 +-80.440600,43.688600,2154.00 +-80.440100,43.687650,2159.00 +-80.438650,43.687383,2167.00 +-80.437233,43.687717,2188.00 +-80.436233,43.688467,2201.00 +-80.436633,43.689533,2212.00 +-80.437950,43.689933,2220.00 +-80.439050,43.689333,2222.00 +-80.439017,43.688250,2225.00 +-80.438000,43.687433,2237.00 +-80.436633,43.687017,2251.00 +-80.435417,43.687550,2252.00 +-80.435683,43.688650,2257.00 +-80.437017,43.689217,2271.00 +-80.438483,43.689117,2280.00 +-80.439583,43.688383,2283.00 +-80.438783,43.687517,2280.00 +-80.437600,43.688267,2286.00 +-80.437433,43.689500,2293.00 +-80.437600,43.690850,2293.00 +-80.437917,43.692167,2304.00 +-80.438350,43.693350,2312.00 +-80.438733,43.694550,2312.00 +-80.439133,43.695983,2303.00 +-80.439617,43.697583,2285.00 +-80.440233,43.699150,2282.00 +-80.440617,43.700883,2262.00 +-80.440817,43.702817,2240.00 +-80.440933,43.704917,2214.00 +-80.441017,43.707200,2186.00 +-80.441067,43.709483,2184.00 +-80.441067,43.711700,2175.00 +-80.441067,43.713883,2171.00 +-80.441083,43.715967,2173.00 +-80.441100,43.717900,2176.00 +-80.441067,43.719767,2174.00 +-80.441067,43.721600,2164.00 +-80.441033,43.723433,2156.00 +-80.441083,43.725267,2150.00 +-80.441150,43.727050,2152.00 +-80.441150,43.728750,2155.00 +-80.441067,43.730500,2143.00 +-80.441017,43.732283,2128.00 +-80.441083,43.734167,2118.00 +-80.441117,43.736100,2106.00 +-80.441000,43.738000,2096.00 +-80.440817,43.739817,2098.00 +-80.440683,43.741550,2093.00 +-80.440533,43.743333,2085.00 +-80.440433,43.745150,2091.00 +-80.440317,43.746883,2093.00 +-80.440217,43.748583,2089.00 +-80.440150,43.750267,2082.00 +-80.440150,43.752033,2070.00 +-80.440217,43.753917,2061.00 +-80.440117,43.755850,2054.00 +-80.439900,43.757817,2043.00 +-80.439650,43.759833,2029.00 +-80.439483,43.761867,2027.00 +-80.439367,43.763800,2027.00 +-80.439350,43.765900,2019.00 +-80.439267,43.767783,2011.00 +-80.439100,43.769617,2006.00 +-80.438983,43.771417,1993.00 +-80.438883,43.773233,1979.00 +-80.438717,43.775067,1966.00 +-80.438533,43.776933,1955.00 +-80.438350,43.778783,1949.00 +-80.438133,43.780583,1940.00 +-80.437867,43.782433,1926.00 +-80.437667,43.784350,1914.00 +-80.437583,43.786317,1903.00 +-80.437483,43.788283,1902.00 +-80.437350,43.790150,1906.00 +-80.437183,43.791950,1900.00 +-80.437017,43.793750,1893.00 +-80.436817,43.795533,1889.00 +-80.436533,43.797350,1869.00 +-80.435583,43.799100,1863.00 +-80.434467,43.800683,1862.00 +-80.433400,43.802300,1856.00 +-80.432333,43.803950,1849.00 +-80.431200,43.805617,1848.00 +-80.430017,43.807233,1855.00 +-80.428983,43.808717,1865.00 +-80.428033,43.810167,1871.00 +-80.427150,43.811550,1881.00 +-80.426250,43.812900,1889.00 +-80.425233,43.814183,1896.00 +-80.424300,43.815550,1900.00 +-80.423450,43.817000,1897.00 +-80.422700,43.818500,1887.00 +-80.421950,43.820067,1881.00 +-80.421167,43.821667,1879.00 +-80.420417,43.823317,1877.00 +-80.419767,43.825017,1874.00 +-80.418883,43.826717,1866.00 +-80.417900,43.828383,1863.00 +-80.417000,43.830017,1860.00 +-80.416100,43.831617,1852.00 +-80.415233,43.833283,1845.00 +-80.414467,43.835017,1840.00 +-80.414550,43.836550,1870.00 +-80.415967,43.836833,1884.00 +-80.416833,43.836150,1897.00 +-80.416800,43.835167,1899.00 +-80.415950,43.834283,1903.00 +-80.414400,43.833917,1903.00 +-80.412667,43.834267,1902.00 +-80.411367,43.835167,1902.00 +-80.410733,43.836367,1900.00 +-80.410783,43.837583,1902.00 +-80.411483,43.838650,1904.00 +-80.412783,43.839367,1902.00 +-80.414433,43.839783,1898.00 +-80.416150,43.840133,1911.00 +-80.417733,43.840467,1921.00 +-80.419267,43.840283,1936.00 +-80.419700,43.839367,1946.00 +-80.418933,43.838533,1957.00 +-80.417517,43.838117,1967.00 +-80.415950,43.838217,1978.00 +-80.414600,43.838883,1979.00 +-80.414333,43.840017,1983.00 +-80.415367,43.840783,1988.00 +-80.416800,43.840517,1993.00 +-80.417183,43.839533,2008.00 +-80.416300,43.838717,2018.00 +-80.414833,43.838500,2028.00 +-80.413467,43.838967,2031.00 +-80.412833,43.840000,2027.00 +-80.413317,43.841067,2029.00 +-80.414550,43.841783,2037.00 +-80.416017,43.841867,2044.00 +-80.417183,43.841333,2051.00 +-80.417700,43.840383,2059.00 +-80.417550,43.839333,2070.00 +-80.417000,43.838400,2078.00 +-80.415767,43.837800,2078.00 +-80.414150,43.837833,2077.00 +-80.412750,43.838483,2080.00 +-80.412167,43.839567,2083.00 +-80.412483,43.840667,2083.00 +-80.413417,43.841567,2087.00 +-80.414600,43.842400,2087.00 +-80.415950,43.843150,2087.00 +-80.417483,43.844000,2096.00 +-80.418817,43.844833,2112.00 +-80.420317,43.845233,2114.00 +-80.420533,43.844383,2119.00 +-80.419033,43.844117,2124.00 +-80.417350,43.844500,2136.00 +-80.416183,43.845350,2156.00 +-80.416550,43.846433,2165.00 +-80.417950,43.846567,2169.00 +-80.418200,43.845750,2171.00 +-80.416733,43.845333,2184.00 +-80.415317,43.845733,2200.00 +-80.414767,43.846767,2204.00 +-80.415017,43.848000,2206.00 +-80.415400,43.849250,2209.00 +-80.415917,43.850467,2212.00 +-80.416417,43.851667,2212.00 +-80.416967,43.852933,2199.00 +-80.417667,43.854317,2192.00 +-80.418367,43.855717,2196.00 +-80.419183,43.857000,2198.00 +-80.419883,43.858267,2193.00 +-80.420600,43.859600,2188.00 +-80.421333,43.860967,2181.00 +-80.421983,43.862367,2175.00 +-80.422467,43.863733,2177.00 +-80.422983,43.865000,2170.00 +-80.423650,43.866317,2155.00 +-80.424283,43.867767,2140.00 +-80.424950,43.869250,2135.00 +-80.425617,43.870733,2130.00 +-80.426183,43.872350,2123.00 +-80.426633,43.873817,2123.00 +-80.427167,43.875233,2119.00 +-80.427683,43.876683,2116.00 +-80.428050,43.878067,2117.00 +-80.428467,43.879417,2110.00 +-80.428933,43.880800,2102.00 +-80.429400,43.882233,2097.00 +-80.429883,43.883633,2095.00 +-80.430400,43.885017,2090.00 +-80.430900,43.886417,2087.00 +-80.431433,43.887800,2081.00 +-80.432117,43.889183,2071.00 +-80.432817,43.890633,2067.00 +-80.433500,43.892083,2065.00 +-80.434017,43.893567,2069.00 +-80.434433,43.895050,2064.00 +-80.434867,43.896517,2060.00 +-80.435383,43.897967,2050.00 +-80.435917,43.899450,2039.00 +-80.436367,43.900967,2033.00 +-80.436633,43.902383,2057.00 +-80.436700,43.903517,2075.00 +-80.436883,43.904767,2074.00 +-80.437083,43.906000,2081.00 +-80.437267,43.907083,2081.00 +-80.437550,43.908483,2081.00 +-80.437767,43.909767,2078.00 +-80.438000,43.911100,2061.00 +-80.438300,43.912567,2047.00 +-80.438567,43.914083,2039.00 +-80.438867,43.915617,2029.00 +-80.439233,43.917167,2021.00 +-80.439500,43.918733,2009.00 +-80.439800,43.920300,2006.00 +-80.440050,43.921750,2008.00 +-80.440233,43.923150,2004.00 +-80.440367,43.924550,1993.00 +-80.440500,43.926033,1982.00 +-80.440733,43.927533,1972.00 +-80.441083,43.929067,1960.00 +-80.441250,43.930633,1957.00 +-80.440950,43.932067,1968.00 +-80.440467,43.933383,1978.00 +-80.439800,43.934633,1981.00 +-80.439833,43.935900,1996.00 +-80.440867,43.936750,2008.00 +-80.441933,43.936400,2017.00 +-80.441417,43.935550,2021.00 +-80.439950,43.935333,2035.00 +-80.438650,43.935967,2045.00 +-80.438267,43.937133,2049.00 +-80.439083,43.938083,2052.00 +-80.440433,43.938050,2060.00 +-80.441050,43.937250,2066.00 +-80.440567,43.936333,2075.00 +-80.439300,43.935817,2085.00 +-80.437800,43.935650,2092.00 +-80.436283,43.936100,2090.00 +-80.435650,43.937250,2097.00 +-80.435917,43.938383,2101.00 +-80.437033,43.939000,2106.00 +-80.438350,43.939050,2111.00 +-80.439300,43.938517,2120.00 +-80.439433,43.937667,2122.00 +-80.438433,43.936900,2124.00 +-80.436917,43.936967,2137.00 +-80.435867,43.937783,2136.00 +-80.435567,43.939033,2129.00 +-80.435600,43.940333,2131.00 +-80.435900,43.941600,2131.00 +-80.436367,43.942883,2129.00 +-80.436917,43.944183,2128.00 +-80.437550,43.945450,2128.00 +-80.438183,43.946750,2124.00 +-80.438850,43.948033,2122.00 +-80.439650,43.949283,2125.00 +-80.440567,43.950633,2129.00 +-80.441450,43.951867,2132.00 +-80.442367,43.953133,2129.00 +-80.443217,43.954417,2125.00 +-80.443933,43.955667,2120.00 +-80.444650,43.956933,2108.00 +-80.445417,43.958217,2106.00 +-80.446150,43.959533,2096.00 +-80.446917,43.960833,2095.00 +-80.447400,43.962133,2095.00 +-80.447767,43.963417,2083.00 +-80.448250,43.964783,2070.00 +-80.448750,43.966200,2066.00 +-80.449233,43.967533,2069.00 +-80.449750,43.968817,2067.00 +-80.450267,43.970033,2061.00 +-80.450833,43.971333,2044.00 +-80.451617,43.972683,2034.00 +-80.452317,43.974100,2029.00 +-80.453133,43.975500,2022.00 +-80.453967,43.976867,2022.00 +-80.454783,43.978217,2022.00 +-80.455600,43.979500,2022.00 +-80.456467,43.980683,2021.00 +-80.457317,43.981900,2009.00 +-80.458150,43.983133,2005.00 +-80.458950,43.984350,2000.00 +-80.459767,43.985583,1989.00 +-80.460617,43.986867,1977.00 +-80.461417,43.988150,1970.00 +-80.462217,43.989317,1969.00 +-80.463150,43.990433,1956.00 +-80.464183,43.991567,1952.00 +-80.465217,43.992717,1948.00 +-80.466183,43.993883,1943.00 +-80.467200,43.995050,1928.00 +-80.468267,43.996267,1910.00 +-80.469367,43.997617,1895.00 +-80.470500,43.999000,1880.00 +-80.471600,44.000433,1869.00 +-80.472633,44.001883,1858.00 +-80.473717,44.003317,1850.00 +-80.474700,44.004767,1843.00 +-80.475683,44.006233,1834.00 +-80.476600,44.007700,1826.00 +-80.477517,44.009133,1817.00 +-80.478483,44.010517,1820.00 +-80.479333,44.011733,1831.00 +-80.480283,44.012867,1831.00 +-80.481350,44.014033,1834.00 +-80.482483,44.015183,1843.00 +-80.483600,44.016367,1855.00 +-80.483317,44.017867,1868.00 +-80.481683,44.018667,1877.00 +-80.480350,44.018050,1886.00 +-80.481067,44.017133,1892.00 +-80.482917,44.017283,1907.00 +-80.484033,44.018467,1929.00 +-80.483567,44.019867,1942.00 +-80.482067,44.020433,1952.00 +-80.481000,44.019783,1961.00 +-80.481600,44.018800,1967.00 +-80.483317,44.018867,1982.00 +-80.483833,44.020167,2004.00 +-80.482533,44.021067,2009.00 +-80.481183,44.020733,2015.00 +-80.481417,44.019850,2027.00 +-80.482783,44.019450,2034.00 +-80.484267,44.020300,2038.00 +-80.484067,44.021917,2036.00 +-80.482267,44.022700,2043.00 +-80.480933,44.022317,2068.00 +-80.480133,44.021600,2075.00 +-80.479417,44.020783,2087.00 +-80.479017,44.019917,2091.00 +-80.479917,44.019183,2087.00 +-80.481550,44.019483,2094.00 +-80.482700,44.020600,2103.00 +-80.483233,44.021967,2111.00 +-80.482517,44.023283,2117.00 +-80.480950,44.023783,2120.00 +-80.480100,44.023200,2134.00 +-80.481017,44.022600,2131.00 +-80.482667,44.022750,2136.00 +-80.484150,44.023533,2146.00 +-80.485333,44.024600,2148.00 +-80.486433,44.025783,2145.00 +-80.487517,44.026917,2138.00 +-80.488650,44.027950,2136.00 +-80.489733,44.029000,2129.00 +-80.490867,44.030117,2116.00 +-80.490700,44.031483,2108.00 +-80.489133,44.031717,2099.00 +-80.488350,44.030783,2088.00 +-80.487733,44.029650,2071.00 +-80.487133,44.028383,2062.00 +-80.486533,44.026967,2040.00 +-80.485917,44.025367,2022.00 +-80.485350,44.023717,2027.00 +-80.484900,44.022083,2028.00 +-80.484417,44.020517,2030.00 +-80.483933,44.018950,2029.00 +-80.483433,44.017433,2035.00 +-80.482917,44.015867,2037.00 +-80.482483,44.014250,2031.00 +-80.482000,44.012600,2019.00 +-80.481433,44.010950,2009.00 +-80.480783,44.009300,2001.00 +-80.480117,44.007650,1991.00 +-80.479450,44.005950,1977.00 +-80.478833,44.004217,1967.00 +-80.478217,44.002467,1956.00 +-80.477567,44.000683,1948.00 +-80.476900,43.998933,1946.00 +-80.476217,43.997183,1935.00 +-80.475617,43.995433,1929.00 +-80.475100,43.993717,1922.00 +-80.474567,43.992017,1911.00 +-80.473983,43.990317,1900.00 +-80.473483,43.988600,1892.00 +-80.473067,43.986883,1880.00 +-80.472633,43.985133,1866.00 +-80.472217,43.983417,1857.00 +-80.471883,43.981717,1845.00 +-80.471550,43.980033,1827.00 +-80.471183,43.978350,1813.00 +-80.470867,43.976633,1793.00 +-80.470417,43.974950,1786.00 +-80.469833,43.973117,1779.00 +-80.469183,43.971483,1775.00 +-80.468600,43.969833,1774.00 +-80.468067,43.968183,1771.00 +-80.467483,43.966483,1758.00 +-80.466867,43.964767,1749.00 +-80.466267,43.963100,1736.00 +-80.465717,43.961433,1722.00 +-80.465183,43.959783,1703.00 +-80.464617,43.958100,1685.00 +-80.464133,43.956400,1674.00 +-80.463783,43.954700,1664.00 +-80.463417,43.952983,1650.00 +-80.463033,43.951233,1642.00 +-80.462667,43.949483,1639.00 +-80.462250,43.947767,1634.00 +-80.461850,43.945983,1632.00 +-80.461467,43.944217,1639.00 +-80.461133,43.942483,1644.00 +-80.460783,43.940750,1642.00 +-80.460483,43.939017,1633.00 +-80.460200,43.937283,1628.00 +-80.459933,43.935550,1620.00 +-80.459633,43.933767,1606.00 +-80.459317,43.931950,1598.00 +-80.458950,43.930117,1590.00 +-80.458567,43.928283,1583.00 +-80.458133,43.926467,1587.00 +-80.457683,43.924733,1581.00 +-80.457267,43.923017,1575.00 +-80.456917,43.921317,1565.00 +-80.456533,43.919633,1551.00 +-80.456183,43.917933,1538.00 +-80.455817,43.916267,1520.00 +-80.455400,43.914567,1509.00 +-80.455067,43.912900,1497.00 +-80.454900,43.911283,1486.00 +-80.454733,43.909650,1464.00 +-80.454517,43.908017,1453.00 +-80.454383,43.906383,1447.00 +-80.454233,43.904767,1430.00 +-80.454033,43.902933,1408.00 +-80.453783,43.900950,1383.00 +-80.453517,43.898933,1370.00 +-80.453217,43.896983,1357.00 +-80.452867,43.895083,1349.00 +-80.452533,43.893200,1332.00 +-80.452217,43.891300,1319.00 +-80.451983,43.889383,1310.00 +-80.451767,43.887483,1300.00 +-80.451567,43.885533,1300.00 +-80.451367,43.883650,1303.00 +-80.451150,43.881833,1303.00 +-80.450833,43.880033,1295.00 +-80.450400,43.878250,1282.00 +-80.449850,43.876450,1271.00 +-80.449300,43.874617,1254.00 +-80.448950,43.872667,1241.00 +-80.448750,43.870633,1235.00 +-80.448717,43.868600,1232.00 +-80.448750,43.866567,1230.00 +-80.448800,43.864583,1226.00 +-80.448883,43.862600,1217.00 +-80.449067,43.860683,1213.00 +-80.449450,43.858883,1210.00 +-80.450083,43.857167,1202.00 +-80.450900,43.855517,1197.00 +-80.451850,43.853967,1191.00 +-80.452817,43.852467,1184.00 +-80.453533,43.850983,1180.00 +-80.454167,43.849367,1177.00 +-80.454617,43.847900,1167.00 +-80.455050,43.846350,1156.00 +-80.455317,43.844733,1145.00 +-80.455333,43.843067,1138.00 +-80.455217,43.841450,1142.00 +-80.455067,43.839950,1145.00 +-80.454850,43.838517,1149.00 +-80.454583,43.837267,1153.00 +-80.454167,43.836083,1138.00 +-80.453483,43.834967,1132.00 +-80.452700,43.833900,1119.00 +-80.451717,43.832800,1107.00 +-80.450633,43.831667,1099.00 +-80.449400,43.830550,1081.00 +-80.448217,43.829417,1065.00 +-80.447017,43.828350,1049.00 +-80.445867,43.827350,1043.00 +-80.444683,43.826433,1021.00 +-80.443350,43.825600,997.00 +-80.441833,43.824883,972.00 +-80.440083,43.824383,952.00 +-80.438200,43.824050,933.00 +-80.436283,43.823900,915.00 +-80.434350,43.824083,900.00 +-80.432483,43.824517,885.00 +-80.430700,43.825133,867.00 +-80.428983,43.825817,846.00 +-80.427300,43.826550,830.00 +-80.425733,43.827333,814.00 +-80.424217,43.828167,799.00 +-80.422750,43.829083,783.00 +-80.421333,43.830050,762.00 +-80.420200,43.831217,746.00 +-80.419800,43.832567,736.00 +-80.420200,43.833850,723.00 +-80.421250,43.834967,711.00 +-80.422550,43.835967,699.00 +-80.423917,43.836917,691.00 +-80.425367,43.837883,680.00 +-80.426800,43.838917,662.00 +-80.428100,43.840067,648.00 +-80.429167,43.841300,636.00 +-80.430033,43.842617,629.00 +-80.430733,43.844033,623.00 +-80.431250,43.845567,622.00 +-80.431583,43.847067,618.00 +-80.431950,43.848550,609.00 +-80.432533,43.849917,603.00 +-80.433750,43.850917,596.00 +-80.435317,43.851267,586.00 +-80.436950,43.851283,574.00 +-80.438617,43.851017,558.00 +-80.440267,43.850617,543.00 +-80.441800,43.850050,529.00 +-80.443267,43.849383,511.00 +-80.444617,43.848583,496.00 +-80.445483,43.847517,484.00 +-80.445250,43.846283,472.00 +-80.444717,43.845050,459.00 +-80.444150,43.843833,451.00 +-80.443633,43.842650,444.00 +-80.443167,43.841567,443.00 +-80.442850,43.840800,443.00 +-80.442750,43.840550,443.00 +-80.442750,43.840550,443.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840567,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442750,43.840550,444.00 +-80.442733,43.840533,444.00 +-80.442700,43.840483,444.00 +-80.442650,43.840433,445.00 +-80.442583,43.840383,444.00 +-80.442517,43.840317,444.00 +-80.442450,43.840267,444.00 +-80.442383,43.840200,444.00 +-80.442300,43.840150,444.00 +-80.442233,43.840117,444.00 +-80.442200,43.840067,444.00 +-80.442167,43.840017,444.00 +-80.442117,43.839983,444.00 +-80.442067,43.839933,444.00 +-80.442033,43.839900,444.00 +-80.441983,43.839850,444.00 +-80.441933,43.839817,444.00 +-80.441883,43.839767,444.00 +-80.441833,43.839733,444.00 +-80.441767,43.839683,444.00 +-80.441717,43.839650,444.00 +-80.441650,43.839617,444.00 +-80.441600,43.839567,444.00 +-80.441533,43.839533,444.00 +-80.441500,43.839483,444.00 +-80.441433,43.839450,444.00 +-80.441350,43.839400,444.00 +-80.441317,43.839367,444.00 +-80.441250,43.839317,444.00 +-80.441200,43.839283,444.00 +-80.441150,43.839250,444.00 +-80.441100,43.839200,444.00 +-80.441067,43.839167,443.00 +-80.441017,43.839133,443.00 +-80.440967,43.839083,444.00 +-80.440933,43.839050,443.00 +-80.440883,43.839017,443.00 +-80.440817,43.838983,443.00 +-80.440767,43.838933,443.00 +-80.440700,43.838900,443.00 +-80.440667,43.838867,443.00 +-80.440617,43.838817,444.00 +-80.440533,43.838767,444.00 +-80.440483,43.838733,444.00 +-80.440433,43.838700,443.00 +-80.440383,43.838650,444.00 +-80.440333,43.838600,444.00 +-80.440267,43.838567,443.00 +-80.440233,43.838533,443.00 +-80.440183,43.838483,444.00 +-80.440117,43.838450,444.00 +-80.440083,43.838417,443.00 +-80.440033,43.838383,443.00 +-80.439983,43.838350,444.00 +-80.439950,43.838300,443.00 +-80.439883,43.838267,444.00 +-80.439850,43.838233,444.00 +-80.439800,43.838183,444.00 +-80.439750,43.838150,444.00 +-80.439717,43.838117,444.00 +-80.439683,43.838083,444.00 +-80.439617,43.838050,443.00 +-80.439567,43.838000,443.00 +-80.439517,43.837967,444.00 +-80.439483,43.837933,443.00 +-80.439433,43.837900,443.00 +-80.439367,43.837867,444.00 +-80.439317,43.837817,444.00 +-80.439250,43.837783,443.00 +-80.439200,43.837733,443.00 +-80.439150,43.837700,443.00 +-80.439100,43.837667,443.00 +-80.439050,43.837633,443.00 +-80.439000,43.837600,443.00 +-80.438950,43.837550,443.00 +-80.438900,43.837517,443.00 +-80.438833,43.837483,443.00 +-80.438783,43.837450,443.00 + + + + + + GNSSALTTRK + + + +Description IGCHDRS~HFFXA015~HFPLTPILOTINCHARGE:CHRIS RAZL~HFCM2CREW2: ~HFGTYGLIDERTYPE:LS 4~HFGIDGLIDERID:~HFDTM100GPSDATUM:WGS-1984~HFRFWFIRMWAREVERSION:1.60~HFRHWHARDWAREVERSION:1.00~HFFTYFRTYPE:LX Eos~HFGPS:uBLOX-LEA-6S,50ch,max50000m~HFPRSPRESSALTSENSOR:INTERSEMA,MS5607,max15000m~HFCIDCOMPETITIONID:~HFCCLCOMPETITIONCLASS:~ +Distance 90.4 mi +Min Alt 1519.029 ft +Max Alt 7903.543 ft +Min Speed 0.8 mph +Max Speed 113.8 mph +Avg Speed 60.4 mph +Start Time 2022-07-16T19:41:31Z +End Time 2022-07-16T21:11:20Z + +]]> + + + 2022-07-16T19:41:31Z + 2022-07-16T21:11:20Z + + + Path + #lineStyle + + 1 + absolute + +-80.443083,43.840333,463.00 +-80.443083,43.840333,463.00 +-80.443083,43.840333,463.00 +-80.442617,43.839933,463.00 +-80.441667,43.839200,463.00 +-80.440567,43.838433,464.00 +-80.439233,43.837517,466.00 +-80.437850,43.836533,484.00 +-80.436450,43.835600,503.00 +-80.435117,43.834700,524.00 +-80.433833,43.833833,543.00 +-80.432483,43.833000,557.00 +-80.431400,43.832050,574.00 +-80.430767,43.830933,584.00 +-80.430767,43.829700,590.00 +-80.431133,43.828533,601.00 +-80.431967,43.827483,611.00 +-80.433300,43.826650,626.00 +-80.434950,43.826117,638.00 +-80.436800,43.825667,656.00 +-80.438317,43.825250,672.00 +-80.440050,43.825017,687.00 +-80.441817,43.825250,697.00 +-80.443417,43.825967,702.00 +-80.444700,43.827117,709.00 +-80.445300,43.828633,719.00 +-80.445100,43.830217,738.00 +-80.444250,43.831683,748.00 +-80.442550,43.832883,755.00 +-80.440667,43.833500,765.00 +-80.438600,43.833683,773.00 +-80.436650,43.833267,782.00 +-80.435117,43.832383,790.00 +-80.434150,43.831200,799.00 +-80.433833,43.829900,811.00 +-80.434267,43.828650,820.00 +-80.435350,43.827617,834.00 +-80.436817,43.826950,856.00 +-80.438400,43.826483,869.00 +-80.439983,43.826083,879.00 +-80.441567,43.825700,888.00 +-80.443217,43.825317,895.00 +-80.444850,43.824883,917.00 +-80.446267,43.824200,936.00 +-80.447117,43.823100,952.00 +-80.447167,43.821850,970.00 +-80.446417,43.820617,972.00 +-80.444900,43.819717,978.00 +-80.442883,43.819250,986.00 +-80.440683,43.819350,1000.00 +-80.438333,43.820033,1011.00 +-80.436700,43.821067,1024.00 +-80.434900,43.822217,1045.00 +-80.432783,43.822983,1057.00 +-80.430450,43.823183,1068.00 +-80.428217,43.822950,1082.00 +-80.426083,43.822233,1099.00 +-80.424683,43.821150,1116.00 +-80.423833,43.819800,1124.00 +-80.423767,43.818350,1135.00 +-80.424400,43.817033,1155.00 +-80.425667,43.816033,1160.00 +-80.427400,43.815400,1168.00 +-80.429400,43.815200,1177.00 +-80.431450,43.815367,1194.00 +-80.433483,43.815633,1213.00 +-80.435483,43.815517,1233.00 +-80.437300,43.814950,1252.00 +-80.438550,43.813850,1276.00 +-80.438850,43.812467,1296.00 +-80.438283,43.811150,1323.00 +-80.437033,43.810083,1349.00 +-80.435283,43.809367,1375.00 +-80.432900,43.809350,1391.00 +-80.430750,43.809950,1410.00 +-80.429117,43.809300,1414.00 +-80.427983,43.808300,1417.00 +-80.427067,43.807283,1412.00 +-80.425767,43.806633,1407.00 +-80.424533,43.807233,1402.00 +-80.424433,43.808267,1400.00 +-80.425217,43.809133,1395.00 +-80.426517,43.809633,1394.00 +-80.428017,43.809800,1393.00 +-80.429567,43.809767,1384.00 +-80.431083,43.809567,1383.00 +-80.432583,43.809317,1389.00 +-80.434083,43.808967,1400.00 +-80.434733,43.808067,1415.00 +-80.433900,43.807333,1425.00 +-80.432517,43.807600,1440.00 +-80.431917,43.808567,1451.00 +-80.432533,43.809533,1459.00 +-80.433900,43.809750,1470.00 +-80.434967,43.809000,1479.00 +-80.434883,43.808033,1494.00 +-80.433683,43.807633,1508.00 +-80.432600,43.808233,1527.00 +-80.432683,43.809283,1533.00 +-80.433933,43.809817,1545.00 +-80.435117,43.809400,1560.00 +-80.435283,43.808483,1565.00 +-80.434300,43.807800,1577.00 +-80.432933,43.807950,1596.00 +-80.432150,43.808833,1612.00 +-80.432667,43.809950,1617.00 +-80.434017,43.810300,1631.00 +-80.435250,43.809933,1643.00 +-80.436217,43.809083,1659.00 +-80.435717,43.808200,1670.00 +-80.434367,43.808000,1676.00 +-80.433183,43.808700,1693.00 +-80.433233,43.809800,1712.00 +-80.434617,43.810167,1724.00 +-80.435617,43.809400,1738.00 +-80.435033,43.808533,1750.00 +-80.433600,43.808583,1753.00 +-80.432950,43.809700,1773.00 +-80.433483,43.810800,1787.00 +-80.435017,43.811067,1800.00 +-80.436033,43.810283,1813.00 +-80.435650,43.809317,1822.00 +-80.434000,43.809100,1829.00 +-80.432850,43.809933,1847.00 +-80.432517,43.811067,1862.00 +-80.433733,43.811683,1872.00 +-80.434950,43.811167,1883.00 +-80.434833,43.810183,1896.00 +-80.433483,43.809817,1900.00 +-80.432267,43.810533,1919.00 +-80.432500,43.811567,1935.00 +-80.433817,43.811933,1943.00 +-80.434867,43.811283,1955.00 +-80.434717,43.810367,1968.00 +-80.433517,43.809850,1978.00 +-80.432033,43.810100,1993.00 +-80.431267,43.811050,2001.00 +-80.431600,43.812083,2002.00 +-80.432783,43.812750,2000.00 +-80.434267,43.812533,2007.00 +-80.434917,43.811567,2019.00 +-80.434283,43.810550,2029.00 +-80.432750,43.810283,2051.00 +-80.431500,43.810967,2065.00 +-80.431317,43.812017,2072.00 +-80.432133,43.812850,2071.00 +-80.433450,43.813300,2079.00 +-80.434850,43.813383,2092.00 +-80.435733,43.812700,2093.00 +-80.435333,43.811700,2090.00 +-80.433933,43.811300,2098.00 +-80.432483,43.811700,2117.00 +-80.432167,43.812750,2122.00 +-80.433300,43.813467,2133.00 +-80.434483,43.813100,2144.00 +-80.434733,43.812217,2149.00 +-80.433833,43.811417,2150.00 +-80.432450,43.811633,2172.00 +-80.431950,43.812650,2170.00 +-80.432867,43.813567,2183.00 +-80.434233,43.813417,2198.00 +-80.434767,43.812550,2200.00 +-80.434017,43.811700,2211.00 +-80.432517,43.811800,2223.00 +-80.431917,43.812883,2230.00 +-80.432817,43.813767,2239.00 +-80.434117,43.813517,2253.00 +-80.434300,43.812600,2254.00 +-80.433133,43.812000,2271.00 +-80.431817,43.812517,2277.00 +-80.431600,43.813667,2284.00 +-80.432667,43.814417,2292.00 +-80.433900,43.814017,2300.00 +-80.434000,43.813067,2300.00 +-80.432650,43.812833,2315.00 +-80.431700,43.813650,2312.00 +-80.432317,43.814683,2314.00 +-80.433767,43.815017,2319.00 +-80.435250,43.814850,2316.00 +-80.436467,43.814283,2307.00 +-80.436550,43.813300,2304.00 +-80.435483,43.812550,2315.00 +-80.434117,43.812117,2311.00 +-80.432633,43.812583,2310.00 +-80.432300,43.813750,2320.00 +-80.433433,43.814467,2322.00 +-80.434767,43.814050,2324.00 +-80.434717,43.813033,2335.00 +-80.433383,43.812633,2337.00 +-80.432083,43.813150,2328.00 +-80.432117,43.814433,2329.00 +-80.432550,43.815750,2321.00 +-80.433067,43.817150,2315.00 +-80.433650,43.818650,2314.00 +-80.434467,43.820100,2322.00 +-80.435967,43.820100,2343.00 +-80.436100,43.819167,2341.00 +-80.435233,43.818217,2318.00 +-80.433733,43.817283,2307.00 +-80.432033,43.816450,2305.00 +-80.430167,43.815717,2301.00 +-80.428183,43.815050,2297.00 +-80.426133,43.814483,2292.00 +-80.424017,43.813967,2284.00 +-80.421867,43.813417,2286.00 +-80.420200,43.812900,2322.00 +-80.418750,43.812450,2311.00 +-80.417233,43.811883,2310.00 +-80.415567,43.811367,2300.00 +-80.413683,43.810767,2287.00 +-80.411750,43.810050,2278.00 +-80.409733,43.809367,2269.00 +-80.407667,43.808667,2258.00 +-80.405600,43.807817,2246.00 +-80.403567,43.806883,2240.00 +-80.401533,43.805983,2235.00 +-80.399700,43.805167,2251.00 +-80.397983,43.804483,2246.00 +-80.396000,43.803917,2223.00 +-80.393850,43.803217,2208.00 +-80.391833,43.802383,2204.00 +-80.390033,43.801517,2200.00 +-80.388400,43.800600,2197.00 +-80.386883,43.799633,2192.00 +-80.385317,43.798533,2186.00 +-80.383900,43.797517,2178.00 +-80.382517,43.796450,2178.00 +-80.381283,43.795317,2180.00 +-80.380267,43.794083,2197.00 +-80.379533,43.792983,2210.00 +-80.378967,43.791983,2208.00 +-80.378450,43.790883,2193.00 +-80.377833,43.789633,2181.00 +-80.377183,43.788300,2171.00 +-80.376517,43.786900,2163.00 +-80.375850,43.785467,2147.00 +-80.375217,43.783933,2138.00 +-80.374633,43.782500,2140.00 +-80.374117,43.781100,2132.00 +-80.373717,43.779650,2120.00 +-80.373333,43.778150,2106.00 +-80.373000,43.776583,2090.00 +-80.372633,43.774950,2078.00 +-80.372267,43.773317,2069.00 +-80.371933,43.771733,2073.00 +-80.371617,43.770217,2071.00 +-80.371150,43.768733,2068.00 +-80.370617,43.767300,2064.00 +-80.370033,43.765850,2052.00 +-80.369367,43.764333,2039.00 +-80.368717,43.762750,2025.00 +-80.368050,43.761083,2014.00 +-80.367367,43.759417,2004.00 +-80.366800,43.757733,2000.00 +-80.366283,43.756100,1992.00 +-80.365783,43.754467,1985.00 +-80.365367,43.752833,1978.00 +-80.364917,43.751200,1961.00 +-80.364450,43.749517,1957.00 +-80.363883,43.747783,1951.00 +-80.363350,43.746083,1955.00 +-80.362750,43.744417,1955.00 +-80.362200,43.742750,1956.00 +-80.361567,43.741083,1950.00 +-80.360983,43.739400,1936.00 +-80.360383,43.737667,1926.00 +-80.359733,43.735950,1919.00 +-80.359050,43.734200,1904.00 +-80.358317,43.732417,1893.00 +-80.357617,43.730483,1899.00 +-80.357033,43.728850,1899.00 +-80.356500,43.727217,1891.00 +-80.355983,43.725550,1880.00 +-80.355350,43.723833,1865.00 +-80.354700,43.722133,1851.00 +-80.354083,43.720483,1842.00 +-80.353583,43.718900,1836.00 +-80.353150,43.717333,1828.00 +-80.352650,43.715750,1813.00 +-80.352000,43.714067,1798.00 +-80.351183,43.712400,1792.00 +-80.350367,43.710750,1788.00 +-80.349417,43.709217,1793.00 +-80.348567,43.707833,1809.00 +-80.347850,43.706617,1816.00 +-80.346983,43.705567,1810.00 +-80.346517,43.704450,1807.00 +-80.347133,43.703383,1804.00 +-80.348217,43.702467,1814.00 +-80.349300,43.701550,1812.00 +-80.350450,43.700683,1805.00 +-80.351683,43.699867,1795.00 +-80.352967,43.699033,1782.00 +-80.354367,43.698200,1772.00 +-80.355867,43.697400,1764.00 +-80.357267,43.696533,1762.00 +-80.358633,43.695717,1753.00 +-80.359983,43.694967,1747.00 +-80.361317,43.694167,1738.00 +-80.362583,43.693250,1732.00 +-80.363833,43.692283,1732.00 +-80.365100,43.691367,1738.00 +-80.366250,43.690450,1744.00 +-80.367400,43.689550,1749.00 +-80.368283,43.688550,1758.00 +-80.367300,43.687633,1771.00 +-80.365600,43.687550,1784.00 +-80.364500,43.688450,1796.00 +-80.364900,43.689467,1802.00 +-80.366100,43.689900,1806.00 +-80.367183,43.689550,1808.00 +-80.367983,43.688800,1804.00 +-80.368633,43.687900,1801.00 +-80.369267,43.686917,1809.00 +-80.369983,43.685883,1814.00 +-80.369617,43.684767,1829.00 +-80.368050,43.684667,1834.00 +-80.367250,43.685667,1838.00 +-80.368033,43.686633,1853.00 +-80.369367,43.686833,1870.00 +-80.369500,43.685817,1880.00 +-80.368050,43.685450,1888.00 +-80.366983,43.686317,1893.00 +-80.367450,43.687450,1914.00 +-80.368683,43.687833,1927.00 +-80.369167,43.686833,1936.00 +-80.368133,43.685917,1955.00 +-80.366500,43.685933,1967.00 +-80.365517,43.686883,1981.00 +-80.366150,43.687817,1999.00 +-80.367383,43.687667,2015.00 +-80.367483,43.686750,2032.00 +-80.366167,43.686217,2031.00 +-80.365267,43.687250,2035.00 +-80.366250,43.688050,2055.00 +-80.367550,43.687867,2069.00 +-80.367517,43.686917,2081.00 +-80.366083,43.686533,2088.00 +-80.364700,43.687183,2094.00 +-80.364267,43.688350,2104.00 +-80.364617,43.689517,2118.00 +-80.365867,43.690117,2135.00 +-80.366983,43.689567,2132.00 +-80.366717,43.688517,2150.00 +-80.365267,43.688317,2167.00 +-80.364017,43.689133,2165.00 +-80.364117,43.690333,2186.00 +-80.364917,43.691217,2185.00 +-80.366333,43.691267,2187.00 +-80.367100,43.690400,2188.00 +-80.367033,43.689267,2201.00 +-80.365683,43.688767,2214.00 +-80.364567,43.689583,2218.00 +-80.365217,43.690467,2231.00 +-80.366500,43.690333,2238.00 +-80.366967,43.689433,2255.00 +-80.366333,43.688550,2257.00 +-80.364783,43.688167,2267.00 +-80.363500,43.688717,2274.00 +-80.363200,43.689833,2258.00 +-80.363667,43.690933,2267.00 +-80.364467,43.691900,2273.00 +-80.365433,43.692750,2272.00 +-80.366800,43.692783,2265.00 +-80.367183,43.691783,2271.00 +-80.366267,43.690900,2285.00 +-80.364750,43.690600,2290.00 +-80.363100,43.690967,2303.00 +-80.361700,43.691650,2315.00 +-80.360750,43.692650,2319.00 +-80.361067,43.693750,2320.00 +-80.362450,43.694067,2314.00 +-80.363417,43.693350,2315.00 +-80.363200,43.692317,2317.00 +-80.361917,43.691600,2328.00 +-80.360317,43.691600,2336.00 +-80.358933,43.692300,2323.00 +-80.358833,43.693467,2332.00 +-80.360000,43.694067,2330.00 +-80.361533,43.694000,2325.00 +-80.362967,43.694000,2331.00 +-80.364383,43.693883,2331.00 +-80.365833,43.693700,2333.00 +-80.367333,43.693500,2346.00 +-80.368850,43.693317,2345.00 +-80.370533,43.693117,2345.00 +-80.372367,43.692817,2346.00 +-80.374183,43.692600,2352.00 +-80.375767,43.692517,2346.00 +-80.377450,43.692317,2326.00 +-80.379383,43.692017,2313.00 +-80.381383,43.691617,2308.00 +-80.383067,43.691167,2321.00 +-80.384517,43.690900,2322.00 +-80.385933,43.690600,2315.00 +-80.387383,43.690300,2308.00 +-80.388767,43.689917,2303.00 +-80.390167,43.689417,2293.00 +-80.391733,43.688967,2285.00 +-80.393350,43.688550,2285.00 +-80.394967,43.688200,2286.00 +-80.396533,43.687967,2283.00 +-80.398150,43.687783,2274.00 +-80.399833,43.687933,2270.00 +-80.401533,43.688150,2257.00 +-80.403333,43.688333,2245.00 +-80.405200,43.688550,2238.00 +-80.407017,43.688750,2236.00 +-80.408817,43.688933,2229.00 +-80.410733,43.689050,2218.00 +-80.412700,43.689217,2200.00 +-80.414783,43.689383,2185.00 +-80.416933,43.689467,2179.00 +-80.419050,43.689550,2168.00 +-80.421250,43.689633,2160.00 +-80.423350,43.689733,2161.00 +-80.425350,43.689800,2158.00 +-80.427233,43.689767,2157.00 +-80.429050,43.689750,2154.00 +-80.430717,43.689817,2157.00 +-80.432267,43.689700,2152.00 +-80.433717,43.689300,2146.00 +-80.435117,43.688617,2145.00 +-80.436383,43.687783,2152.00 +-80.437567,43.686700,2164.00 +-80.437483,43.685500,2187.00 +-80.436067,43.685533,2180.00 +-80.435817,43.686817,2164.00 +-80.436817,43.687933,2185.00 +-80.438267,43.688700,2200.00 +-80.439383,43.688033,2210.00 +-80.438317,43.687400,2211.00 +-80.437967,43.688667,2224.00 +-80.439433,43.689267,2248.00 +-80.440600,43.688600,2250.00 +-80.440100,43.687650,2256.00 +-80.438650,43.687383,2264.00 +-80.437233,43.687717,2286.00 +-80.436233,43.688467,2298.00 +-80.436633,43.689533,2311.00 +-80.437950,43.689933,2321.00 +-80.439050,43.689333,2321.00 +-80.439017,43.688250,2323.00 +-80.438000,43.687433,2335.00 +-80.436633,43.687017,2350.00 +-80.435417,43.687550,2351.00 +-80.435683,43.688650,2359.00 +-80.437017,43.689217,2373.00 +-80.438483,43.689117,2381.00 +-80.439583,43.688383,2380.00 +-80.438783,43.687517,2376.00 +-80.437600,43.688267,2385.00 +-80.437433,43.689500,2391.00 +-80.437600,43.690850,2390.00 +-80.437917,43.692167,2400.00 +-80.438350,43.693350,2409.00 +-80.438733,43.694550,2405.00 +-80.439133,43.695983,2395.00 +-80.439617,43.697583,2393.00 +-80.440233,43.699150,2384.00 +-80.440617,43.700883,2365.00 +-80.440817,43.702817,2342.00 +-80.440933,43.704917,2315.00 +-80.441017,43.707200,2286.00 +-80.441067,43.709483,2283.00 +-80.441067,43.711700,2273.00 +-80.441067,43.713883,2268.00 +-80.441083,43.715967,2270.00 +-80.441100,43.717900,2271.00 +-80.441067,43.719767,2268.00 +-80.441067,43.721600,2257.00 +-80.441033,43.723433,2250.00 +-80.441083,43.725267,2243.00 +-80.441150,43.727050,2246.00 +-80.441150,43.728750,2248.00 +-80.441067,43.730500,2236.00 +-80.441017,43.732283,2221.00 +-80.441083,43.734167,2210.00 +-80.441117,43.736100,2198.00 +-80.441000,43.738000,2188.00 +-80.440817,43.739817,2190.00 +-80.440683,43.741550,2183.00 +-80.440533,43.743333,2174.00 +-80.440433,43.745150,2179.00 +-80.440317,43.746883,2182.00 +-80.440217,43.748583,2178.00 +-80.440150,43.750267,2171.00 +-80.440150,43.752033,2159.00 +-80.440217,43.753917,2149.00 +-80.440117,43.755850,2143.00 +-80.439900,43.757817,2131.00 +-80.439650,43.759833,2119.00 +-80.439483,43.761867,2116.00 +-80.439367,43.763800,2114.00 +-80.439350,43.765900,2105.00 +-80.439267,43.767783,2096.00 +-80.439100,43.769617,2092.00 +-80.438983,43.771417,2078.00 +-80.438883,43.773233,2063.00 +-80.438717,43.775067,2050.00 +-80.438533,43.776933,2039.00 +-80.438350,43.778783,2032.00 +-80.438133,43.780583,2022.00 +-80.437867,43.782433,2009.00 +-80.437667,43.784350,1996.00 +-80.437583,43.786317,1986.00 +-80.437483,43.788283,1986.00 +-80.437350,43.790150,1990.00 +-80.437183,43.791950,1982.00 +-80.437017,43.793750,1975.00 +-80.436817,43.795533,1970.00 +-80.436533,43.797350,1951.00 +-80.435583,43.799100,1948.00 +-80.434467,43.800683,1946.00 +-80.433400,43.802300,1940.00 +-80.432333,43.803950,1934.00 +-80.431200,43.805617,1934.00 +-80.430017,43.807233,1942.00 +-80.428983,43.808717,1953.00 +-80.428033,43.810167,1959.00 +-80.427150,43.811550,1968.00 +-80.426250,43.812900,1975.00 +-80.425233,43.814183,1983.00 +-80.424300,43.815550,1988.00 +-80.423450,43.817000,1984.00 +-80.422700,43.818500,1973.00 +-80.421950,43.820067,1967.00 +-80.421167,43.821667,1965.00 +-80.420417,43.823317,1963.00 +-80.419767,43.825017,1961.00 +-80.418883,43.826717,1952.00 +-80.417900,43.828383,1949.00 +-80.417000,43.830017,1945.00 +-80.416100,43.831617,1937.00 +-80.415233,43.833283,1930.00 +-80.414467,43.835017,1926.00 +-80.414550,43.836550,1954.00 +-80.415967,43.836833,1971.00 +-80.416833,43.836150,1983.00 +-80.416800,43.835167,1987.00 +-80.415950,43.834283,1990.00 +-80.414400,43.833917,1990.00 +-80.412667,43.834267,1991.00 +-80.411367,43.835167,1992.00 +-80.410733,43.836367,1990.00 +-80.410783,43.837583,1992.00 +-80.411483,43.838650,1992.00 +-80.412783,43.839367,1992.00 +-80.414433,43.839783,1987.00 +-80.416150,43.840133,2000.00 +-80.417733,43.840467,2009.00 +-80.419267,43.840283,2024.00 +-80.419700,43.839367,2035.00 +-80.418933,43.838533,2046.00 +-80.417517,43.838117,2056.00 +-80.415950,43.838217,2068.00 +-80.414600,43.838883,2072.00 +-80.414333,43.840017,2078.00 +-80.415367,43.840783,2084.00 +-80.416800,43.840517,2088.00 +-80.417183,43.839533,2103.00 +-80.416300,43.838717,2113.00 +-80.414833,43.838500,2123.00 +-80.413467,43.838967,2126.00 +-80.412833,43.840000,2122.00 +-80.413317,43.841067,2125.00 +-80.414550,43.841783,2134.00 +-80.416017,43.841867,2140.00 +-80.417183,43.841333,2147.00 +-80.417700,43.840383,2155.00 +-80.417550,43.839333,2166.00 +-80.417000,43.838400,2175.00 +-80.415767,43.837800,2174.00 +-80.414150,43.837833,2173.00 +-80.412750,43.838483,2177.00 +-80.412167,43.839567,2182.00 +-80.412483,43.840667,2179.00 +-80.413417,43.841567,2184.00 +-80.414600,43.842400,2184.00 +-80.415950,43.843150,2183.00 +-80.417483,43.844000,2192.00 +-80.418817,43.844833,2208.00 +-80.420317,43.845233,2212.00 +-80.420533,43.844383,2216.00 +-80.419033,43.844117,2220.00 +-80.417350,43.844500,2235.00 +-80.416183,43.845350,2256.00 +-80.416550,43.846433,2266.00 +-80.417950,43.846567,2271.00 +-80.418200,43.845750,2270.00 +-80.416733,43.845333,2286.00 +-80.415317,43.845733,2303.00 +-80.414767,43.846767,2309.00 +-80.415017,43.848000,2309.00 +-80.415400,43.849250,2312.00 +-80.415917,43.850467,2314.00 +-80.416417,43.851667,2311.00 +-80.416967,43.852933,2297.00 +-80.417667,43.854317,2291.00 +-80.418367,43.855717,2295.00 +-80.419183,43.857000,2297.00 +-80.419883,43.858267,2289.00 +-80.420600,43.859600,2284.00 +-80.421333,43.860967,2276.00 +-80.421983,43.862367,2269.00 +-80.422467,43.863733,2273.00 +-80.422983,43.865000,2265.00 +-80.423650,43.866317,2249.00 +-80.424283,43.867767,2234.00 +-80.424950,43.869250,2228.00 +-80.425617,43.870733,2223.00 +-80.426183,43.872350,2216.00 +-80.426633,43.873817,2216.00 +-80.427167,43.875233,2210.00 +-80.427683,43.876683,2207.00 +-80.428050,43.878067,2208.00 +-80.428467,43.879417,2201.00 +-80.428933,43.880800,2192.00 +-80.429400,43.882233,2188.00 +-80.429883,43.883633,2186.00 +-80.430400,43.885017,2179.00 +-80.430900,43.886417,2176.00 +-80.431433,43.887800,2171.00 +-80.432117,43.889183,2161.00 +-80.432817,43.890633,2156.00 +-80.433500,43.892083,2155.00 +-80.434017,43.893567,2159.00 +-80.434433,43.895050,2153.00 +-80.434867,43.896517,2148.00 +-80.435383,43.897967,2138.00 +-80.435917,43.899450,2126.00 +-80.436367,43.900967,2120.00 +-80.436633,43.902383,2144.00 +-80.436700,43.903517,2162.00 +-80.436883,43.904767,2160.00 +-80.437083,43.906000,2168.00 +-80.437267,43.907083,2168.00 +-80.437550,43.908483,2167.00 +-80.437767,43.909767,2164.00 +-80.438000,43.911100,2148.00 +-80.438300,43.912567,2134.00 +-80.438567,43.914083,2125.00 +-80.438867,43.915617,2116.00 +-80.439233,43.917167,2107.00 +-80.439500,43.918733,2096.00 +-80.439800,43.920300,2092.00 +-80.440050,43.921750,2094.00 +-80.440233,43.923150,2089.00 +-80.440367,43.924550,2078.00 +-80.440500,43.926033,2067.00 +-80.440733,43.927533,2057.00 +-80.441083,43.929067,2045.00 +-80.441250,43.930633,2044.00 +-80.440950,43.932067,2055.00 +-80.440467,43.933383,2062.00 +-80.439800,43.934633,2066.00 +-80.439833,43.935900,2082.00 +-80.440867,43.936750,2095.00 +-80.441933,43.936400,2106.00 +-80.441417,43.935550,2111.00 +-80.439950,43.935333,2126.00 +-80.438650,43.935967,2138.00 +-80.438267,43.937133,2143.00 +-80.439083,43.938083,2148.00 +-80.440433,43.938050,2155.00 +-80.441050,43.937250,2162.00 +-80.440567,43.936333,2171.00 +-80.439300,43.935817,2181.00 +-80.437800,43.935650,2187.00 +-80.436283,43.936100,2186.00 +-80.435650,43.937250,2194.00 +-80.435917,43.938383,2199.00 +-80.437033,43.939000,2205.00 +-80.438350,43.939050,2209.00 +-80.439300,43.938517,2217.00 +-80.439433,43.937667,2219.00 +-80.438433,43.936900,2221.00 +-80.436917,43.936967,2235.00 +-80.435867,43.937783,2233.00 +-80.435567,43.939033,2227.00 +-80.435600,43.940333,2229.00 +-80.435900,43.941600,2227.00 +-80.436367,43.942883,2224.00 +-80.436917,43.944183,2224.00 +-80.437550,43.945450,2222.00 +-80.438183,43.946750,2218.00 +-80.438850,43.948033,2216.00 +-80.439650,43.949283,2220.00 +-80.440567,43.950633,2226.00 +-80.441450,43.951867,2226.00 +-80.442367,43.953133,2223.00 +-80.443217,43.954417,2219.00 +-80.443933,43.955667,2212.00 +-80.444650,43.956933,2201.00 +-80.445417,43.958217,2198.00 +-80.446150,43.959533,2189.00 +-80.446917,43.960833,2188.00 +-80.447400,43.962133,2188.00 +-80.447767,43.963417,2174.00 +-80.448250,43.964783,2160.00 +-80.448750,43.966200,2156.00 +-80.449233,43.967533,2158.00 +-80.449750,43.968817,2157.00 +-80.450267,43.970033,2149.00 +-80.450833,43.971333,2132.00 +-80.451617,43.972683,2123.00 +-80.452317,43.974100,2119.00 +-80.453133,43.975500,2111.00 +-80.453967,43.976867,2112.00 +-80.454783,43.978217,2112.00 +-80.455600,43.979500,2113.00 +-80.456467,43.980683,2111.00 +-80.457317,43.981900,2099.00 +-80.458150,43.983133,2095.00 +-80.458950,43.984350,2090.00 +-80.459767,43.985583,2079.00 +-80.460617,43.986867,2066.00 +-80.461417,43.988150,2059.00 +-80.462217,43.989317,2057.00 +-80.463150,43.990433,2045.00 +-80.464183,43.991567,2040.00 +-80.465217,43.992717,2037.00 +-80.466183,43.993883,2032.00 +-80.467200,43.995050,2018.00 +-80.468267,43.996267,2000.00 +-80.469367,43.997617,1985.00 +-80.470500,43.999000,1969.00 +-80.471600,44.000433,1957.00 +-80.472633,44.001883,1947.00 +-80.473717,44.003317,1937.00 +-80.474700,44.004767,1931.00 +-80.475683,44.006233,1921.00 +-80.476600,44.007700,1912.00 +-80.477517,44.009133,1903.00 +-80.478483,44.010517,1907.00 +-80.479333,44.011733,1917.00 +-80.480283,44.012867,1916.00 +-80.481350,44.014033,1921.00 +-80.482483,44.015183,1930.00 +-80.483600,44.016367,1941.00 +-80.483317,44.017867,1957.00 +-80.481683,44.018667,1966.00 +-80.480350,44.018050,1976.00 +-80.481067,44.017133,1982.00 +-80.482917,44.017283,1997.00 +-80.484033,44.018467,2020.00 +-80.483567,44.019867,2032.00 +-80.482067,44.020433,2042.00 +-80.481000,44.019783,2052.00 +-80.481600,44.018800,2058.00 +-80.483317,44.018867,2075.00 +-80.483833,44.020167,2096.00 +-80.482533,44.021067,2102.00 +-80.481183,44.020733,2107.00 +-80.481417,44.019850,2120.00 +-80.482783,44.019450,2129.00 +-80.484267,44.020300,2133.00 +-80.484067,44.021917,2130.00 +-80.482267,44.022700,2137.00 +-80.480933,44.022317,2161.00 +-80.480133,44.021600,2171.00 +-80.479417,44.020783,2183.00 +-80.479017,44.019917,2186.00 +-80.479917,44.019183,2183.00 +-80.481550,44.019483,2190.00 +-80.482700,44.020600,2199.00 +-80.483233,44.021967,2206.00 +-80.482517,44.023283,2212.00 +-80.480950,44.023783,2216.00 +-80.480100,44.023200,2230.00 +-80.481017,44.022600,2230.00 +-80.482667,44.022750,2235.00 +-80.484150,44.023533,2244.00 +-80.485333,44.024600,2245.00 +-80.486433,44.025783,2240.00 +-80.487517,44.026917,2234.00 +-80.488650,44.027950,2232.00 +-80.489733,44.029000,2224.00 +-80.490867,44.030117,2211.00 +-80.490700,44.031483,2204.00 +-80.489133,44.031717,2193.00 +-80.488350,44.030783,2184.00 +-80.487733,44.029650,2167.00 +-80.487133,44.028383,2153.00 +-80.486533,44.026967,2130.00 +-80.485917,44.025367,2110.00 +-80.485350,44.023717,2117.00 +-80.484900,44.022083,2119.00 +-80.484417,44.020517,2120.00 +-80.483933,44.018950,2119.00 +-80.483433,44.017433,2126.00 +-80.482917,44.015867,2127.00 +-80.482483,44.014250,2121.00 +-80.482000,44.012600,2110.00 +-80.481433,44.010950,2100.00 +-80.480783,44.009300,2091.00 +-80.480117,44.007650,2081.00 +-80.479450,44.005950,2067.00 +-80.478833,44.004217,2056.00 +-80.478217,44.002467,2046.00 +-80.477567,44.000683,2037.00 +-80.476900,43.998933,2035.00 +-80.476217,43.997183,2023.00 +-80.475617,43.995433,2017.00 +-80.475100,43.993717,2010.00 +-80.474567,43.992017,2000.00 +-80.473983,43.990317,1988.00 +-80.473483,43.988600,1980.00 +-80.473067,43.986883,1967.00 +-80.472633,43.985133,1953.00 +-80.472217,43.983417,1944.00 +-80.471883,43.981717,1932.00 +-80.471550,43.980033,1914.00 +-80.471183,43.978350,1899.00 +-80.470867,43.976633,1878.00 +-80.470417,43.974950,1869.00 +-80.469833,43.973117,1862.00 +-80.469183,43.971483,1859.00 +-80.468600,43.969833,1858.00 +-80.468067,43.968183,1853.00 +-80.467483,43.966483,1841.00 +-80.466867,43.964767,1831.00 +-80.466267,43.963100,1818.00 +-80.465717,43.961433,1804.00 +-80.465183,43.959783,1784.00 +-80.464617,43.958100,1767.00 +-80.464133,43.956400,1754.00 +-80.463783,43.954700,1744.00 +-80.463417,43.952983,1729.00 +-80.463033,43.951233,1722.00 +-80.462667,43.949483,1719.00 +-80.462250,43.947767,1713.00 +-80.461850,43.945983,1712.00 +-80.461467,43.944217,1720.00 +-80.461133,43.942483,1726.00 +-80.460783,43.940750,1721.00 +-80.460483,43.939017,1712.00 +-80.460200,43.937283,1708.00 +-80.459933,43.935550,1699.00 +-80.459633,43.933767,1684.00 +-80.459317,43.931950,1676.00 +-80.458950,43.930117,1668.00 +-80.458567,43.928283,1660.00 +-80.458133,43.926467,1666.00 +-80.457683,43.924733,1659.00 +-80.457267,43.923017,1652.00 +-80.456917,43.921317,1642.00 +-80.456533,43.919633,1628.00 +-80.456183,43.917933,1615.00 +-80.455817,43.916267,1596.00 +-80.455400,43.914567,1585.00 +-80.455067,43.912900,1571.00 +-80.454900,43.911283,1560.00 +-80.454733,43.909650,1538.00 +-80.454517,43.908017,1525.00 +-80.454383,43.906383,1521.00 +-80.454233,43.904767,1503.00 +-80.454033,43.902933,1479.00 +-80.453783,43.900950,1453.00 +-80.453517,43.898933,1441.00 +-80.453217,43.896983,1427.00 +-80.452867,43.895083,1418.00 +-80.452533,43.893200,1401.00 +-80.452217,43.891300,1387.00 +-80.451983,43.889383,1377.00 +-80.451767,43.887483,1367.00 +-80.451567,43.885533,1367.00 +-80.451367,43.883650,1371.00 +-80.451150,43.881833,1369.00 +-80.450833,43.880033,1362.00 +-80.450400,43.878250,1348.00 +-80.449850,43.876450,1336.00 +-80.449300,43.874617,1319.00 +-80.448950,43.872667,1305.00 +-80.448750,43.870633,1299.00 +-80.448717,43.868600,1295.00 +-80.448750,43.866567,1293.00 +-80.448800,43.864583,1290.00 +-80.448883,43.862600,1279.00 +-80.449067,43.860683,1276.00 +-80.449450,43.858883,1271.00 +-80.450083,43.857167,1263.00 +-80.450900,43.855517,1257.00 +-80.451850,43.853967,1251.00 +-80.452817,43.852467,1244.00 +-80.453533,43.850983,1239.00 +-80.454167,43.849367,1236.00 +-80.454617,43.847900,1225.00 +-80.455050,43.846350,1213.00 +-80.455317,43.844733,1201.00 +-80.455333,43.843067,1195.00 +-80.455217,43.841450,1200.00 +-80.455067,43.839950,1202.00 +-80.454850,43.838517,1207.00 +-80.454583,43.837267,1210.00 +-80.454167,43.836083,1196.00 +-80.453483,43.834967,1189.00 +-80.452700,43.833900,1177.00 +-80.451717,43.832800,1164.00 +-80.450633,43.831667,1155.00 +-80.449400,43.830550,1137.00 +-80.448217,43.829417,1118.00 +-80.447017,43.828350,1103.00 +-80.445867,43.827350,1096.00 +-80.444683,43.826433,1073.00 +-80.443350,43.825600,1048.00 +-80.441833,43.824883,1022.00 +-80.440083,43.824383,1000.00 +-80.438200,43.824050,980.00 +-80.436283,43.823900,962.00 +-80.434350,43.824083,947.00 +-80.432483,43.824517,932.00 +-80.430700,43.825133,913.00 +-80.428983,43.825817,891.00 +-80.427300,43.826550,873.00 +-80.425733,43.827333,857.00 +-80.424217,43.828167,840.00 +-80.422750,43.829083,823.00 +-80.421333,43.830050,801.00 +-80.420200,43.831217,784.00 +-80.419800,43.832567,773.00 +-80.420200,43.833850,761.00 +-80.421250,43.834967,750.00 +-80.422550,43.835967,737.00 +-80.423917,43.836917,729.00 +-80.425367,43.837883,717.00 +-80.426800,43.838917,699.00 +-80.428100,43.840067,684.00 +-80.429167,43.841300,671.00 +-80.430033,43.842617,664.00 +-80.430733,43.844033,658.00 +-80.431250,43.845567,657.00 +-80.431583,43.847067,651.00 +-80.431950,43.848550,642.00 +-80.432533,43.849917,634.00 +-80.433750,43.850917,626.00 +-80.435317,43.851267,618.00 +-80.436950,43.851283,604.00 +-80.438617,43.851017,588.00 +-80.440267,43.850617,571.00 +-80.441800,43.850050,556.00 +-80.443267,43.849383,538.00 +-80.444617,43.848583,521.00 +-80.445483,43.847517,507.00 +-80.445250,43.846283,497.00 +-80.444717,43.845050,483.00 +-80.444150,43.843833,474.00 +-80.443633,43.842650,468.00 +-80.443167,43.841567,467.00 +-80.442850,43.840800,468.00 +-80.442750,43.840550,468.00 +-80.442750,43.840550,469.00 +-80.442750,43.840550,469.00 +-80.442750,43.840550,469.00 +-80.442750,43.840550,469.00 +-80.442750,43.840550,469.00 +-80.442750,43.840567,468.00 +-80.442750,43.840567,468.00 +-80.442750,43.840567,468.00 +-80.442750,43.840567,467.00 +-80.442750,43.840567,467.00 +-80.442750,43.840567,467.00 +-80.442750,43.840567,467.00 +-80.442750,43.840567,466.00 +-80.442750,43.840567,466.00 +-80.442750,43.840567,466.00 +-80.442750,43.840567,466.00 +-80.442750,43.840567,466.00 +-80.442750,43.840567,465.00 +-80.442750,43.840567,465.00 +-80.442750,43.840567,465.00 +-80.442750,43.840567,465.00 +-80.442750,43.840567,466.00 +-80.442750,43.840567,467.00 +-80.442750,43.840567,468.00 +-80.442750,43.840567,469.00 +-80.442750,43.840567,469.00 +-80.442750,43.840567,470.00 +-80.442750,43.840550,471.00 +-80.442750,43.840550,471.00 +-80.442750,43.840550,472.00 +-80.442750,43.840550,472.00 +-80.442750,43.840550,472.00 +-80.442750,43.840550,473.00 +-80.442750,43.840550,473.00 +-80.442750,43.840550,473.00 +-80.442750,43.840550,474.00 +-80.442750,43.840550,474.00 +-80.442750,43.840550,474.00 +-80.442750,43.840550,473.00 +-80.442750,43.840550,473.00 +-80.442750,43.840550,473.00 +-80.442750,43.840550,473.00 +-80.442733,43.840533,473.00 +-80.442700,43.840483,473.00 +-80.442650,43.840433,473.00 +-80.442583,43.840383,473.00 +-80.442517,43.840317,473.00 +-80.442450,43.840267,473.00 +-80.442383,43.840200,473.00 +-80.442300,43.840150,473.00 +-80.442233,43.840117,473.00 +-80.442200,43.840067,473.00 +-80.442167,43.840017,473.00 +-80.442117,43.839983,473.00 +-80.442067,43.839933,473.00 +-80.442033,43.839900,474.00 +-80.441983,43.839850,473.00 +-80.441933,43.839817,473.00 +-80.441883,43.839767,473.00 +-80.441833,43.839733,473.00 +-80.441767,43.839683,473.00 +-80.441717,43.839650,473.00 +-80.441650,43.839617,473.00 +-80.441600,43.839567,474.00 +-80.441533,43.839533,474.00 +-80.441500,43.839483,474.00 +-80.441433,43.839450,474.00 +-80.441350,43.839400,473.00 +-80.441317,43.839367,473.00 +-80.441250,43.839317,473.00 +-80.441200,43.839283,473.00 +-80.441150,43.839250,473.00 +-80.441100,43.839200,473.00 +-80.441067,43.839167,473.00 +-80.441017,43.839133,473.00 +-80.440967,43.839083,473.00 +-80.440933,43.839050,473.00 +-80.440883,43.839017,473.00 +-80.440817,43.838983,473.00 +-80.440767,43.838933,473.00 +-80.440700,43.838900,473.00 +-80.440667,43.838867,473.00 +-80.440617,43.838817,473.00 +-80.440533,43.838767,473.00 +-80.440483,43.838733,473.00 +-80.440433,43.838700,472.00 +-80.440383,43.838650,473.00 +-80.440333,43.838600,473.00 +-80.440267,43.838567,473.00 +-80.440233,43.838533,473.00 +-80.440183,43.838483,474.00 +-80.440117,43.838450,474.00 +-80.440083,43.838417,473.00 +-80.440033,43.838383,474.00 +-80.439983,43.838350,474.00 +-80.439950,43.838300,474.00 +-80.439883,43.838267,474.00 +-80.439850,43.838233,474.00 +-80.439800,43.838183,475.00 +-80.439750,43.838150,475.00 +-80.439717,43.838117,475.00 +-80.439683,43.838083,476.00 +-80.439617,43.838050,476.00 +-80.439567,43.838000,476.00 +-80.439517,43.837967,477.00 +-80.439483,43.837933,477.00 +-80.439433,43.837900,477.00 +-80.439367,43.837867,478.00 +-80.439317,43.837817,478.00 +-80.439250,43.837783,478.00 +-80.439200,43.837733,478.00 +-80.439150,43.837700,478.00 +-80.439100,43.837667,478.00 +-80.439050,43.837633,478.00 +-80.439000,43.837600,478.00 +-80.438950,43.837550,478.00 +-80.438900,43.837517,478.00 +-80.438833,43.837483,478.00 +-80.438783,43.837450,478.00 + + + + + + + Routes + + 0001 + + Path + #lineStyle + + 1 + absolute + +-80.436650,43.835000 +-81.410550,43.163600 +-81.063033,44.156950 +-80.286667,43.874700 +-80.436650,43.835000 +-80.436650,43.835000 + + + + + + + diff --git a/testo.d/kml.test b/testo.d/kml.test index f92f3c4d7..7e0d6b7a6 100644 --- a/testo.d/kml.test +++ b/testo.d/kml.test @@ -100,6 +100,9 @@ gpsbabel -i igc -f ${REFERENCE}/track/92GV66G1.igc -o kml,floating=1,track=1,poi compare ${REFERENCE}/track/92GV66G1.igc.kml ${TMPDIR}/92GV66G1.igc.kml gpsbabel -i igc -f ${REFERENCE}/track/92HV66G1.igc -o kml,floating=1,track=1,points=0 -F ${TMPDIR}/92HV66G1.igc.kml compare ${REFERENCE}/track/92HV66G1.igc.kml ${TMPDIR}/92HV66G1.igc.kml +# Test the inclusion and exclusion of (non)default extensions +gpsbabel -i igc,SIU=1,GFO=1,FXA=0,ENL=0 -f ${REFERENCE}/track/27GLQKF3.igc -o kml,floating=1,track=1,points=0 -F ${TMPDIR}/27GLQKF3.igc.kml +compare ${REFERENCE}/track/27GLQKF3.igc.kml ${TMPDIR}/27GLQKF3.igc.kml # verify kml:dateTimeType parsing gpsbabel -i kml -f ${REFERENCE}/xsddatetime.kml -o unicsv,utc -F ${TMPDIR}/xsddatetime~kml.csv From ab788348a9ca8d63239c306921b0b1d51affea51 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sun, 29 Oct 2023 18:35:42 -0600 Subject: [PATCH 028/132] consolidate handling of extensions in gpx writer. (#1200) This is a user visible change. Previously if gARmIN sPECIAL dATA existed and both garminextensions and humminbirdextensions were false then the gpx writer would write a subset if it (and not passthrough any gpx -> gpx data.) If gARmIN sPECIAL dATA existed and either extension option was true, then a different subset would be written (and any gpx -> gpx data would not be passed through.) Now the garminextensions option must used to have any gARmIN sPECIAL dATA data written. Previously, when passing through extension data from the gpx reader to the gpx writer, some elements of the garmin and humminbird extensions were not included. Now, all foreign elements are included. As before, passthrough is only used when both extension options are false. --- garmin_fs.cc | 66 ------------ garmin_fs.h | 1 - gpx.cc | 72 ++++++++----- gpx.h | 48 +++++---- reference/basecamp~gpx.gpx | 10 +- reference/gdb-sample-v3-ilinks.gpx | 33 ++++++ reference/multiple-links.gpx | 5 - reference/umsonstdraussen.gpx | 162 ++++++++++++++--------------- testo.d/garmin_gpi.test | 2 +- 9 files changed, 197 insertions(+), 202 deletions(-) diff --git a/garmin_fs.cc b/garmin_fs.cc index c6846efce..d00f4a0c3 100644 --- a/garmin_fs.cc +++ b/garmin_fs.cc @@ -78,72 +78,6 @@ garmin_fs_t::~garmin_fs_t() /* GPX - out */ -void -garmin_fs_xml_fprint(const Waypoint* waypt, - gpsbabel::XmlStreamWriter* writer) -{ - garmin_fs_t* gmsd = garmin_fs_t::find(waypt); - - writer->stackOptionalStartElement(QStringLiteral("extensions")); - writer->stackOptionalStartElement(QStringLiteral("gpxx:WaypointExtension")); - writer->stackNamespace(QStringLiteral("http://www.garmin.com/xmlschemas/GpxExtensions/v3"), - "gpxx"); - - if (waypt->proximity_has_value()) { - writer->stackTextElement(QStringLiteral("gpxx:Proximity"), QString::number(waypt->proximity_value(), 'f', 6)); - } - - if (waypt->temperature_has_value()) { - writer->stackTextElement(QStringLiteral("gpxx:Temperature"), QString::number(waypt->temperature_value(), 'f', 6)); - } - - if (waypt->depth_has_value()) { - writer->stackTextElement(QStringLiteral("gpxx:Depth"), QString::number(waypt->depth_value(), 'f', 6)); - } - - if (garmin_fs_t::has_display(gmsd)) { - const char* cx; - switch (gmsd->display) { - case gt_display_mode_symbol: - cx = "SymbolOnly"; - break; - case gt_display_mode_symbol_and_comment: - cx = "SymbolAndDescription"; - break; - default: - cx = "SymbolAndName"; - break; - } - writer->stackTextElement(QStringLiteral("gpxx:DisplayMode"), cx); - } - - if (garmin_fs_t::has_category(gmsd)) { - uint16_t cx = gmsd->category; - writer->stackStartElement(QStringLiteral("gpxx:Categories")); - for (int i = 0; i < 16; i++) { - if (cx & 1) { - writer->stackTextElement(QStringLiteral("gpxx:Category"), QStringLiteral("Category %1").arg(i+1)); - } - cx = cx >> 1; - } - writer->stackEndElement(); // gpxx:Categories - } - - writer->stackOptionalStartElement(QStringLiteral("gpxx:Address")); - writer->stackOptionalTextElement(QStringLiteral("gpxx:StreetAddress"), garmin_fs_t::get_addr(gmsd, nullptr)); - writer->stackOptionalTextElement(QStringLiteral("gpxx:City"), garmin_fs_t::get_city(gmsd, nullptr)); - writer->stackOptionalTextElement(QStringLiteral("gpxx:State"), garmin_fs_t::get_state(gmsd, nullptr)); - writer->stackOptionalTextElement(QStringLiteral("gpxx:Country"), garmin_fs_t::get_country(gmsd, nullptr)); - writer->stackOptionalTextElement(QStringLiteral("gpxx:PostalCode"), garmin_fs_t::get_postal_code(gmsd, nullptr)); - writer->stackEndElement(); // gpxx:Address - - writer->stackOptionalTextElement(QStringLiteral("gpxx:PhoneNumber"), garmin_fs_t::get_phone_nr(gmsd, nullptr)); - - - writer->stackEndElement(); // gpxx:WaypointExtension - writer->stackEndElement(); // extensions -} - void garmin_fs_xml_convert(const int base_tag, int tag, const QString& qstr, Waypoint* waypt) { diff --git a/garmin_fs.h b/garmin_fs.h index d225339dc..fb39b5b90 100644 --- a/garmin_fs.h +++ b/garmin_fs.h @@ -221,7 +221,6 @@ void garmin_fs_copy(void** dest, const void* src); /* for GPX */ void garmin_fs_xml_convert(int base_tag, int tag, const QString& qstr, Waypoint* waypt); -void garmin_fs_xml_fprint(const Waypoint* waypt, gpsbabel::XmlStreamWriter*); /* common garmin_fs utilities */ diff --git a/gpx.cc b/gpx.cc index ad5bfcaaa..45c7606e5 100644 --- a/gpx.cc +++ b/gpx.cc @@ -47,7 +47,7 @@ #include // for qAsConst, QAddConst<>::Type #include "defs.h" -#include "garmin_fs.h" // for garmin_fs_xml_convert, garmin_fs_xml_fprint, GMSD_FIND +#include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t, garmin_fs_xml_convert #include "garmin_tables.h" // for gt_color_index_by_rgb, gt_color_name, gt_color_value_by_name #include "geocache.h" // for Geocache, Geocache::UtfSt... #include "mkshort.h" // for MakeShort @@ -1266,7 +1266,6 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin { assert(gpx_write_version >= gpx_1_1); - writer->stackOptionalStartElement(QStringLiteral("extensions")); if (opt_humminbirdext) { @@ -1283,6 +1282,7 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin // Although not required by the schema we assume that gpxx:RoutePointExtension must be a child of gpx:rtept. // Although not required by the schema we assume that gpxx:TrackPointExtension must be a child of gpx:trkpt. // Although not required by the schema we assume that gpxtpx:TrackPointExtension must be a child of gpx:trkpt. + garmin_fs_t* gmsd = garmin_fs_t::find(waypointp); switch (point_type) { case gpxpt_waypoint: writer->stackOptionalStartElement(QStringLiteral("gpxx:WaypointExtension")); @@ -1295,10 +1295,48 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin if (waypointp->depth_has_value()) { writer->stackTextElement(QStringLiteral("gpxx:Depth"), toString(waypointp->depth_value())); } + + if (garmin_fs_t::has_display(gmsd)) { + const char* cx; + switch (gmsd->display) { + case gt_display_mode_symbol: + cx = "SymbolOnly"; + break; + case gt_display_mode_symbol_and_comment: + cx = "SymbolAndDescription"; + break; + default: + cx = "SymbolAndName"; + break; + } + writer->stackTextElement(QStringLiteral("gpxx:DisplayMode"), cx); + } + + if (garmin_fs_t::has_category(gmsd)) { + uint16_t cx = gmsd->category; + writer->stackStartElement(QStringLiteral("gpxx:Categories")); + for (int i = 0; i < 16; i++) { + if (cx & 1) { + writer->stackTextElement(QStringLiteral("gpxx:Category"), QStringLiteral("Category %1").arg(i+1)); + } + cx = cx >> 1; + } + writer->stackEndElement(); // gpxx:Categories + } + + writer->stackOptionalStartElement(QStringLiteral("gpxx:Address")); + writer->stackOptionalTextElement(QStringLiteral("gpxx:StreetAddress"), garmin_fs_t::get_addr(gmsd, nullptr)); + writer->stackOptionalTextElement(QStringLiteral("gpxx:City"), garmin_fs_t::get_city(gmsd, nullptr)); + writer->stackOptionalTextElement(QStringLiteral("gpxx:State"), garmin_fs_t::get_state(gmsd, nullptr)); + writer->stackOptionalTextElement(QStringLiteral("gpxx:Country"), garmin_fs_t::get_country(gmsd, nullptr)); + writer->stackOptionalTextElement(QStringLiteral("gpxx:PostalCode"), garmin_fs_t::get_postal_code(gmsd, nullptr)); + writer->stackEndElement(); // gpxx:Address + + writer->stackOptionalTextElement(QStringLiteral("gpxx:PhoneNumber"), garmin_fs_t::get_phone_nr(gmsd, nullptr)); + writer->stackEndElement(); // gpxx:WaypointExtension break; - case gpxpt_route: { - garmin_fs_t* gmsd = garmin_fs_t::find(waypointp); + case gpxpt_route: if (gmsd != nullptr && gmsd->ilinks != nullptr) { writer->stackOptionalStartElement(QStringLiteral("gpxx:RoutePointExtension")); garmin_ilink_t* link = gmsd->ilinks; @@ -1315,8 +1353,7 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin } writer->stackEndElement(); // gpxx:RoutePointExtension } - } - break; + break; case gpxpt_track: // gpxtpx:TrackPointExtension is a replacement for gpxx:TrackPointExtension. writer->stackOptionalStartElement(QStringLiteral("gpxtpx:TrackPointExtension")); @@ -1387,23 +1424,8 @@ GpxFormat::gpx_waypt_pr(const Waypoint* waypointp) const if (!(opt_humminbirdext || opt_garminext)) { const auto* fs_gpx = reinterpret_cast(waypointp->fs.FsChainFind(kFsGpx)); - auto* gmsd = garmin_fs_t::find(waypointp); /* gARmIN sPECIAL dATA */ - if (fs_gpx) { - if (! gmsd) { - if (fs_gpx->tag) { - if (gpx_write_version > gpx_1_0) { - writer->writeStartElement("extensions"); - } - fprint_xml_chain(fs_gpx->tag); - if (gpx_write_version > gpx_1_0) { - writer->writeEndElement(); - } - } - } - } - if (gmsd && (gpx_write_version > gpx_1_0)) { - /* MapSource doesn't accepts extensions from 1.0 */ - garmin_fs_xml_fprint(waypointp, writer); + if (fs_gpx && fs_gpx->tag) { + fprint_xml_chain(fs_gpx->tag); } } else { gpx_write_common_extensions(waypointp, gpxpt_waypoint); @@ -1430,7 +1452,7 @@ GpxFormat::gpx_track_hdr(const route_head* rte) if (fs_gpx) { fprint_xml_chain(fs_gpx->tag); } - } else if (opt_garminext && (gpx_write_version > gpx_1_0)) { + } else if (opt_garminext) { if (rte->line_color.bbggrr > unknown_color) { int ci = gt_color_index_by_rgb(rte->line_color.bbggrr); if (ci > 0) { @@ -1518,7 +1540,7 @@ GpxFormat::gpx_route_hdr(const route_head* rte) const if (fs_gpx) { fprint_xml_chain(fs_gpx->tag); } - } else if (opt_garminext && (gpx_write_version > gpx_1_0)) { + } else if (opt_garminext) { if (rte->line_color.bbggrr > unknown_color) { int ci = gt_color_index_by_rgb(rte->line_color.bbggrr); if (ci > 0) { diff --git a/gpx.h b/gpx.h index 0fee9ae46..a658404ba 100644 --- a/gpx.h +++ b/gpx.h @@ -76,12 +76,12 @@ class GpxFormat : public Format */ struct gpx_wpt_fsdata : FormatSpecificData { gpx_wpt_fsdata() : FormatSpecificData(kFsGpxWpt) {} - + gpx_wpt_fsdata* clone() const override { return new gpx_wpt_fsdata(*this); } - + QString magvar; QString src; QString type; @@ -200,8 +200,14 @@ class GpxFormat : public Format }; struct tag_mapping { - tag_type type{tt_unknown}; /* enum from above for this tag */ - bool passthrough{true}; /* true if we don't generate this */ + tag_type type{tt_unknown}; /* enum from above for this tag */ + /* + * passthrough should be true for + * 1) The gpx 1.1 extensions element and any descendents. + * 2) Any element from a foreign (non gpx) namespace and any descendents. + * This rule is necessary for gpx 1.0. + */ + bool passthrough{true}; }; @@ -373,29 +379,29 @@ class GpxFormat : public Format {"/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:type", {tt_cache_log_type, true}}, {"/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:date", {tt_cache_log_date, true}}, - {"/gpx/wpt/extensions", {tt_wpt_extensions, false}}, + {"/gpx/wpt/extensions", {tt_wpt_extensions, true}}, - {GARMIN_WPT_EXT, {tt_garmin_wpt_extensions, false}}, - {GARMIN_WPT_EXT "/gpxx:Proximity", {tt_garmin_wpt_proximity, false}}, - {GARMIN_WPT_EXT "/gpxx:Temperature", {tt_garmin_wpt_temperature, false}}, + {GARMIN_WPT_EXT, {tt_garmin_wpt_extensions, true}}, + {GARMIN_WPT_EXT "/gpxx:Proximity", {tt_garmin_wpt_proximity, true}}, + {GARMIN_WPT_EXT "/gpxx:Temperature", {tt_garmin_wpt_temperature, true}}, {GARMIN_TRKPT_EXT "/gpxtpx:atemp", {tt_garmin_wpt_temperature, true}}, - {GARMIN_WPT_EXT "/gpxx:Depth", {tt_garmin_wpt_depth, false}}, - {GARMIN_WPT_EXT "/gpxx:DisplayMode", {tt_garmin_wpt_display_mode, false}}, - {GARMIN_WPT_EXT "/gpxx:Categories", {tt_garmin_wpt_categories, false}}, - {GARMIN_WPT_EXT "/gpxx:Categories/gpxx:Category", {tt_garmin_wpt_category, false}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:StreetAddress", {tt_garmin_wpt_addr, false}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:City", {tt_garmin_wpt_city, false}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:State", {tt_garmin_wpt_state, false}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:Country", {tt_garmin_wpt_country, false}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:PostalCode", {tt_garmin_wpt_postal_code, false}}, - {GARMIN_WPT_EXT "/gpxx:PhoneNumber", {tt_garmin_wpt_phone_nr, false}}, + {GARMIN_WPT_EXT "/gpxx:Depth", {tt_garmin_wpt_depth, true}}, + {GARMIN_WPT_EXT "/gpxx:DisplayMode", {tt_garmin_wpt_display_mode, true}}, + {GARMIN_WPT_EXT "/gpxx:Categories", {tt_garmin_wpt_categories, true}}, + {GARMIN_WPT_EXT "/gpxx:Categories/gpxx:Category", {tt_garmin_wpt_category, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:StreetAddress", {tt_garmin_wpt_addr, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:City", {tt_garmin_wpt_city, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:State", {tt_garmin_wpt_state, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:Country", {tt_garmin_wpt_country, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:PostalCode", {tt_garmin_wpt_postal_code, true}}, + {GARMIN_WPT_EXT "/gpxx:PhoneNumber", {tt_garmin_wpt_phone_nr, true}}, // In Garmin space, but in core of waypoint. {GARMIN_TRKPT_EXT "/gpxtpx:hr", {tt_trk_trkseg_trkpt_heartrate, true}}, {GARMIN_TRKPT_EXT "/gpxtpx:cad", {tt_trk_trkseg_trkpt_cadence, true}}, - {"/gpx/wpt/extensions/h:depth", {tt_humminbird_wpt_depth, false}}, // in centimeters. - {"/gpx/wpt/extensions/h:status", {tt_humminbird_wpt_status, false}}, + {"/gpx/wpt/extensions/h:depth", {tt_humminbird_wpt_depth, true}}, // in centimeters. + {"/gpx/wpt/extensions/h:status", {tt_humminbird_wpt_status, true}}, {"/gpx/rte", {tt_rte, false}}, {"/gpx/rte/name", {tt_rte_name, false}}, @@ -426,7 +432,7 @@ class GpxFormat : public Format {"/gpx/trk/trkseg/trkpt/course", {tt_trk_trkseg_trkpt_course, false}}, {"/gpx/trk/trkseg/trkpt/speed", {tt_trk_trkseg_trkpt_speed, false}}, - {"/gpx/trk/trkseg/trkpt/extensions/h:depth", {tt_humminbird_trk_trkseg_trkpt_depth, false}}, // in centimeters. + {"/gpx/trk/trkseg/trkpt/extensions/h:depth", {tt_humminbird_trk_trkseg_trkpt_depth, true}}, // in centimeters. /* Common to tracks, routes, and waypts */ GPXWPTTYPETAG("ele", tt_wpttype_ele, false), diff --git a/reference/basecamp~gpx.gpx b/reference/basecamp~gpx.gpx index fe07c4a21..a40ffecca 100644 --- a/reference/basecamp~gpx.gpx +++ b/reference/basecamp~gpx.gpx @@ -15,8 +15,11 @@ Flag, Blue user - + SymbolAndName + + Unlisted Data + @@ -28,8 +31,11 @@ Flag, Blue user - + SymbolAndName + + Unlisted Data + diff --git a/reference/gdb-sample-v3-ilinks.gpx b/reference/gdb-sample-v3-ilinks.gpx index eb81cd6c7..618c987ed 100644 --- a/reference/gdb-sample-v3-ilinks.gpx +++ b/reference/gdb-sample-v3-ilinks.gpx @@ -10,6 +10,11 @@ Birch Harbor Birch Harbor City (Small) + + + SymbolAndName + + @@ -17,6 +22,11 @@ Gouldsboro Gouldsboro City (Small) + + + SymbolAndName + + @@ -24,6 +34,11 @@ Prospect Harbor Prospect Harbor City (Small) + + + SymbolAndName + + @@ -37,6 +52,19 @@ Schoodic Loop Rd Winter Harbor Twn, Maine, 04693, United States 207-288-1300 Campground + + + SymbolAndName + + Schoodic Loop Rd + Winter Harbor Twn + Maine + United States + 04693 + + 207-288-1300 + + @@ -44,6 +72,11 @@ Winter Harbor Twn, Maine, 04693, United States Sullivan Twn Sullivan Twn City (Small) + + + SymbolAndName + + Trip to Schoodic Woods Campground - Day 1 diff --git a/reference/multiple-links.gpx b/reference/multiple-links.gpx index fcc2159d6..e76b718ec 100644 --- a/reference/multiple-links.gpx +++ b/reference/multiple-links.gpx @@ -20,10 +20,5 @@ three dots Waypoint - - - SymbolAndDescription - - diff --git a/reference/umsonstdraussen.gpx b/reference/umsonstdraussen.gpx index 2361b770c..096bfdd8d 100644 --- a/reference/umsonstdraussen.gpx +++ b/reference/umsonstdraussen.gpx @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@ Waypoint - + Luitpoldstrasse Freising @@ -32,7 +32,7 @@ Waypoint - + Zeughausstrasse Darmstadt @@ -51,7 +51,7 @@ Waypoint - + Bretten / Grillplatz / B 35 Bretten @@ -69,7 +69,7 @@ Waypoint - + Alter Elbtunnel / St. Pauli Landungsbrücken Hamburg @@ -88,7 +88,7 @@ Waypoint - + Heubergpark / Alte Roßmühlstraße Wesel @@ -106,7 +106,7 @@ Waypoint - + Prinzipalmarkt Münster @@ -125,7 +125,7 @@ Waypoint - + Frönsberg Hemer @@ -136,14 +136,14 @@ Umsonst + Draußen Würzburg - Line Up: Aeon of Decay, Aloha From Hell, Benni Hemm Hemm, Better Ones, Blocking Element, Bons Balls, Boppin B, Breakfast Killers, Brut Boogaloo, Diego, Enuff, Faint, Falling to Dust, Fiatonic, Frittenbude, Fuck your Shadow from behind, Fuenf, Ghost Rockets, Gold Minor, Guitar Challenge Spectacle, Hank Cash, Jamaze, Jane Doe, Jerry Lain, JZ James Trio, Karlsson, Kashiwa Daisuke, Mama Boom, Mama s Gun, Markus Rill, Melomania, Other Generations Anthem, Palpitation, Sam Isaac Acoustic Trio, Schöne Schaisse, Senore Matze Rossi, Signals to Airkraft, Sorrow Remains, Spaceship Bismark, Steffi-Mira-Band, Superpunk, Surfing Hundekuchen, Tequila Terminators, The Robocop Kraus, Unter Tagen, Vladiwoodstok, Worst Thoughts. Datum: 19.06. - 21.06.2009, Beginn: 17:00 Uhr. - Line Up: Aeon of Decay, Aloha From Hell, Benni Hemm Hemm, Better Ones, Blocking Element, Bons Balls, Boppin B, Breakfast Killers, Brut Boogaloo, Diego, Enuff, Faint, Falling to Dust, Fiatonic, Frittenbude, Fuck your Shadow from behind, Fuenf, Ghost Rockets, Gold Minor, Guitar Challenge Spectacle, Hank Cash, Jamaze, Jane Doe, Jerry Lain, JZ James Trio, Karlsson, Kashiwa Daisuke, Mama Boom, Mama s Gun, Markus Rill, Melomania, Other Generations Anthem, Palpitation, Sam Isaac Acoustic Trio, Schöne Schaisse, Senore Matze Rossi, Signals to Airkraft, Sorrow Remains, Spaceship Bismark, Steffi-Mira-Band, Superpunk, Surfing Hundekuchen, Tequila Terminators, The Robocop Kraus, Unter Tagen, Vladiwoodstok, Worst Thoughts. Datum: 19.06. - 21.06.2009, Beginn: 17:00 Uhr. + Line Up: Aeon of Decay, Aloha From Hell, Benni Hemm Hemm, Better Ones, Blocking Element, Bons Balls, Boppin B, Breakfast Killers, Brut Boogaloo, Diego, Enuff, Faint, Falling to Dust, Fiatonic, Frittenbude, Fuck your Shadow from behind, Fuenf, Ghost Rockets, Gold Minor, Guitar Challenge Spectacle, Hank Cash, Jamaze, Jane Doe, Jerry Lain, JZ James Trio, Karlsson, Kashiwa Daisuke, Mama Boom, Mamas Gun, Markus Rill, Melomania, Other Generations Anthem, Palpitation, Sam Isaac Acoustic Trio, Schöne Schaisse, Senore Matze Rossi, Signals to Airkraft, Sorrow Remains, Spaceship Bismark, Steffi-Mira-Band, Superpunk, Surfing Hundekuchen, Tequila Terminators, The Robocop Kraus, Unter Tagen, Vladiwoodstok, Worst Thoughts. Datum: 19.06. - 21.06.2009, Beginn: 17:00 Uhr. + Line Up: Aeon of Decay, Aloha From Hell, Benni Hemm Hemm, Better Ones, Blocking Element, Bons Balls, Boppin B, Breakfast Killers, Brut Boogaloo, Diego, Enuff, Faint, Falling to Dust, Fiatonic, Frittenbude, Fuck your Shadow from behind, Fuenf, Ghost Rockets, Gold Minor, Guitar Challenge Spectacle, Hank Cash, Jamaze, Jane Doe, Jerry Lain, JZ James Trio, Karlsson, Kashiwa Daisuke, Mama Boom, Mamas Gun, Markus Rill, Melomania, Other Generations Anthem, Palpitation, Sam Isaac Acoustic Trio, Schöne Schaisse, Senore Matze Rossi, Signals to Airkraft, Sorrow Remains, Spaceship Bismark, Steffi-Mira-Band, Superpunk, Surfing Hundekuchen, Tequila Terminators, The Robocop Kraus, Unter Tagen, Vladiwoodstok, Worst Thoughts. Datum: 19.06. - 21.06.2009, Beginn: 17:00 Uhr. www.umsonst-und-draussen.de Waypoint - + Talavera Würzburg @@ -162,7 +162,7 @@ Waypoint - + Kasernenstrasse Bad Kissingen @@ -180,7 +180,7 @@ Waypoint - + Solebadstrasse Bad Salzdetfurth @@ -198,7 +198,7 @@ Waypoint - + Zwischen Potsdamer und Berliner Ufer Hamburg @@ -216,7 +216,7 @@ Waypoint - + Parkanlage Stuttgart-Rohr Stuttgart @@ -235,7 +235,7 @@ Waypoint - + Himmelreichgelände bei den Hessenhöfen Blaubeuren @@ -253,7 +253,7 @@ Waypoint - + Ossenbergweg Hünxe @@ -271,7 +271,7 @@ Waypoint - + Rappenberghalde Tübingen @@ -290,7 +290,7 @@ Waypoint - + Ginsterweg Bad Wildbad @@ -308,7 +308,7 @@ Waypoint - + Zuiderpark Den Haag @@ -326,7 +326,7 @@ Waypoint - + Im Löwental Essen @@ -345,7 +345,7 @@ Waypoint - + Neu-Isenburg Neu-Isenburg @@ -363,7 +363,7 @@ Waypoint - + Straubenhardt 75334 @@ -380,7 +380,7 @@ Waypoint - + Hafenstraße Hamm @@ -399,7 +399,7 @@ Waypoint - + Heidjerstraße Weener @@ -418,7 +418,7 @@ Waypoint - + Altstadt Iserlohn @@ -436,7 +436,7 @@ Waypoint - + Günther-Klutz-Anlage Karlsruhe @@ -455,7 +455,7 @@ Waypoint - + Donauinsel Wien @@ -474,7 +474,7 @@ Waypoint - + Obstmarkt Backnang @@ -493,7 +493,7 @@ Waypoint - + Am Kohschultenhof Lingen @@ -511,7 +511,7 @@ Waypoint - + Falkenstein Donnersdorf-Falkenstein @@ -530,7 +530,7 @@ Waypoint - + Schloßberg Pegnitz @@ -548,7 +548,7 @@ Waypoint - + Firstwaldstrasse Mössingen @@ -566,7 +566,7 @@ Waypoint - + Weserwiese Veltheim Vlotho @@ -584,7 +584,7 @@ Waypoint - + Hintere Insel Lindau @@ -602,7 +602,7 @@ Waypoint - + Am Saupurzl Karlstadt @@ -620,7 +620,7 @@ Waypoint - + Heubach 73540 @@ -637,7 +637,7 @@ Waypoint - + Volksfestplatz am Stadion Erding @@ -656,7 +656,7 @@ Waypoint - + Südwinsen 29308 @@ -673,7 +673,7 @@ Waypoint - + Andlauer Weg Berlin @@ -691,7 +691,7 @@ Waypoint - + Freizeitpark Rheinaue Bonn @@ -710,7 +710,7 @@ Waypoint - + Stadionweg Garching @@ -728,7 +728,7 @@ Waypoint - + im Lerchenfeld Dornstadt bei Ulm @@ -746,7 +746,7 @@ Waypoint - + Riedweg Hausen am Andelsbach @@ -765,7 +765,7 @@ Waypoint - + Karlsstraße Reutlingen @@ -783,7 +783,7 @@ Waypoint - + Noch nicht bekannt Mönchengladbach @@ -801,7 +801,7 @@ Waypoint - + Am Werratalsee Schwebda @@ -820,7 +820,7 @@ Waypoint - + Liebigstraße Flörsheim @@ -839,7 +839,7 @@ Waypoint - + Rathausplatz Meldorf @@ -857,7 +857,7 @@ Waypoint - + Innenstadt Nürnberg Nürnberg @@ -876,7 +876,7 @@ Waypoint - + Innenstadt Regensburg Regensburg @@ -894,7 +894,7 @@ Waypoint - + Innenstadt Bochum Bochum @@ -913,7 +913,7 @@ Waypoint - + Schießmauer Herrenberg @@ -931,7 +931,7 @@ Waypoint - + Firstwaldstrasse Mössingen @@ -949,7 +949,7 @@ Waypoint - + Weserwiese Veltheim Vlotho @@ -967,7 +967,7 @@ Waypoint - + Volksfestplatz am Stadion Erding @@ -986,7 +986,7 @@ Waypoint - + Moorfleeter Deich Hamburg @@ -1004,7 +1004,7 @@ Waypoint - + Geinsheimer Straße Riedstadt-Leeheim @@ -1023,7 +1023,7 @@ Waypoint - + An den St Pauli Landungsbrücken Hamburg @@ -1041,7 +1041,7 @@ Waypoint - + Pfaffenwaldring Stuttgart @@ -1059,7 +1059,7 @@ Waypoint - + Koppelbergstrasse Teterow @@ -1077,7 +1077,7 @@ Waypoint - + Ilweder Strasse Stemwede-Haldem @@ -1095,7 +1095,7 @@ Waypoint - + Festivalgelände Bakum (Büschel) @@ -1113,7 +1113,7 @@ Waypoint - + Schlossstraße Hofheim @@ -1131,7 +1131,7 @@ Waypoint - + Oberransbach Feuchtwangen @@ -1149,7 +1149,7 @@ Waypoint - + Am Rheinufer/In der Reduit Mainz-Kastel @@ -1167,7 +1167,7 @@ Waypoint - + Römersee Bad Rappenau-Zimmerhof @@ -1185,7 +1185,7 @@ Waypoint - + Vestische Straße Oberhausen @@ -1203,7 +1203,7 @@ Waypoint - + Thomasstrasse Halver @@ -1221,7 +1221,7 @@ Waypoint - + Werdensteinstrasse Dellmensingen bei Ulm @@ -1239,7 +1239,7 @@ Waypoint - + Holter Straße Schloß Holte-Stukenbrock @@ -1257,7 +1257,7 @@ Waypoint - + Am Gogenkrog Neustadt in Holstein @@ -1276,7 +1276,7 @@ Waypoint - + Höllchenstrasse Dörnberg @@ -1295,7 +1295,7 @@ Waypoint - + An der alten Kirche Krefeld @@ -1314,7 +1314,7 @@ Waypoint - + Kennedyplatz Essen @@ -1333,7 +1333,7 @@ Waypoint - + Peschmannstrasse Duisburg @@ -1351,7 +1351,7 @@ Waypoint - + Am Steinchen Neu-Anspach @@ -1369,7 +1369,7 @@ Waypoint - + Grindelhof/Siemersallee/Allendeplatz Hamburg @@ -1387,7 +1387,7 @@ Waypoint - + Flögger Strand Fehmarn @@ -1406,7 +1406,7 @@ Waypoint - + Treuchtlingen Ri. Möhren, links Ri. Haag Treuchtlingen @@ -1425,7 +1425,7 @@ Waypoint - + An den Klärteichen Emsdetten diff --git a/testo.d/garmin_gpi.test b/testo.d/garmin_gpi.test index a58c3b175..57faa0936 100644 --- a/testo.d/garmin_gpi.test +++ b/testo.d/garmin_gpi.test @@ -17,7 +17,7 @@ compare ${REFERENCE}/gpi_ext-sample.csv ${TMPDIR}/gpi_ext-sample.csv # Don't test writing this sample file from garminonline.de/extras/poi, but # prove we can read it -gpsbabel -i garmin_gpi -f ${REFERENCE}/umsonstdraussen.gpi -o gpx,gpxver=1.1 -F ${TMPDIR}/umsonstdraussen.gpx +gpsbabel -i garmin_gpi -f ${REFERENCE}/umsonstdraussen.gpi -o gpx,garminextensions -F ${TMPDIR}/umsonstdraussen.gpx compare ${REFERENCE}/umsonstdraussen.gpx ${TMPDIR}/umsonstdraussen.gpx # look for differences between latin1 and windows-1252 From 1fcdf28b9b5deeea8beb4f7a38377cc8ee19639e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:46:07 -0600 Subject: [PATCH 029/132] convert garmin_fs functions from char* -> QString (#1202) * convert garmin_fs functions from char* -> QString. * update comment * make tag_type a class enum * update garmin_fs includes --- garmin_fs.cc | 138 +++-------------- garmin_fs.h | 20 +-- garmin_txt.cc | 2 +- gpx.cc | 274 ++++++++++++++++++++------------- gpx.h | 415 +++++++++++++++++++++++++------------------------- 5 files changed, 407 insertions(+), 442 deletions(-) diff --git a/garmin_fs.cc b/garmin_fs.cc index d00f4a0c3..148db9169 100644 --- a/garmin_fs.cc +++ b/garmin_fs.cc @@ -20,17 +20,13 @@ */ -#include // for snprintf, sscanf -#include // for strtod +#include "garmin_fs.h" -#include // for QString, QStringLiteral -#include // for CaseInsensitive +#include // for QString +#include // for CaseInsensitive #include "defs.h" -#include "garmin_fs.h" -#include "garmin_tables.h" // for gt_switch_display_mode_value, gt_display_mode_symbol, gt_display_mode_symbol_and_comment, gt_display_mode_symbol_and_name -#include "inifile.h" // for inifile_readstr -#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter +#include "inifile.h" // for inifile_readstr #define MYNAME "garmin_fs" @@ -76,130 +72,40 @@ garmin_fs_t::~garmin_fs_t() } } -/* GPX - out */ - -void -garmin_fs_xml_convert(const int base_tag, int tag, const QString& qstr, Waypoint* waypt) +bool +garmin_fs_convert_category(const QString& category_name, uint16_t* category) { - // FIXME: eliminate C string copy/use here: - const char* cdatastr = xstrdup(qstr); - garmin_fs_t* gmsd = garmin_fs_t::find(waypt); - if (gmsd == nullptr) { - gmsd = garmin_fs_alloc(-1); - waypt->fs.FsChainAdd(gmsd); - } - - tag -= base_tag; - /* - tt_garmin_waypt_extension, -> 0 - tt_garmin_proximity, -> 1 - tt_garmin_temperature,-> 2 - tt_garmin_depth, -> 3 - tt_garmin_display_mode, -> 4 - tt_garmin_categories, -> 5 - tt_garmin_category, -> 6 - tt_garmin_addr, -> 7 - tt_garmin_city, -> 8 - tt_garmin_state, -> 9 - tt_garmin_country, -> 10 - tt_garmin_postal_code, -> 11 - tt_garmin_phone_nr, -> 12 - */ - switch (tag) { - case 1: - if (*cdatastr) { - waypt->set_proximity(strtod(cdatastr, nullptr)); - } - break; - case 2: - if (*cdatastr) { - waypt->set_temperature(strtod(cdatastr, nullptr)); - } - break; - case 3: - if (*cdatastr) { - waypt->set_depth(strtod(cdatastr, nullptr)); - } - break; - case 4: - if (case_ignore_strcmp(cdatastr, "SymbolOnly") == 0) { - garmin_fs_t::set_display(gmsd, gt_display_mode_symbol); - } else if (case_ignore_strcmp(cdatastr, "SymbolAndDescription") == 0) { - garmin_fs_t::set_display(gmsd, gt_display_mode_symbol_and_comment); - } else { - garmin_fs_t::set_display(gmsd, gt_display_mode_symbol_and_name); - } - break; - case 6: - if (! garmin_fs_merge_category(cdatastr, waypt)) { - // There's nothing a user can really do about this (well, they could - // create a gpsbabel.ini that mapped them to garmin category numbers - // but that feature is so obscure and used in so few outputs that - // there's no reason to alarm the user. Just silently disregard - // category names that don't map cleanly. - // warning(MYNAME ": Unable to convert category \"%s\"!\n", cdatastr); + // Is the name "Category" followed by a number? Use that number. + if (category_name.startsWith(u"Category ", Qt::CaseInsensitive)) { + bool ok; + int i = category_name.mid(9).toInt(&ok); + if (ok && (i >= 1) && (i <= 16)) { + *category = (1 << --i); + return true; } - break; - case 7: - garmin_fs_t::set_addr(gmsd, cdatastr); - break; - case 8: - garmin_fs_t::set_city(gmsd, cdatastr); - break; - case 9: - garmin_fs_t::set_state(gmsd, cdatastr); - break; - case 10: - garmin_fs_t::set_country(gmsd, cdatastr); - break; - case 11: - garmin_fs_t::set_postal_code(gmsd, cdatastr); - break; - case 12: - garmin_fs_t::set_phone_nr(gmsd, cdatastr); - break; } - xfree(cdatastr); -} - -unsigned char -garmin_fs_convert_category(const char* category_name, uint16_t* category) -{ - int i; - int cat = 0; - - // Is the name "Category" followed by a number? Use that number. - if ((case_ignore_strncmp(category_name, "Category ", 9) == 0) && - (1 == sscanf(category_name + 9, "%d", &i)) && - (i >= 1) && (i <= 16)) { - cat = (1 << --i); - } else if (global_opts.inifile != nullptr) { + if (global_opts.inifile != nullptr) { // Do we have a gpsbabel.ini that maps category names to category #'s? - for (i = 0; i < 16; i++) { + for (int i = 0; i < 16; i++) { QString key = QString::number(i + 1); QString c = inifile_readstr(global_opts.inifile, GMSD_SECTION_CATEGORIES, key); if (c.compare(category_name, Qt::CaseInsensitive) == 0) { - cat = (1 << i); - break; + *category = (1 << i); + return true; } } } - if (cat == 0) { - return 0; - } else { - *category = cat; - return 1; - } + return false; } -unsigned char -garmin_fs_merge_category(const char* category_name, Waypoint* waypt) +bool +garmin_fs_merge_category(const QString& category_name, Waypoint* waypt) { uint16_t cat; // Attempt to get a textual category name to a category number. if (!garmin_fs_convert_category(category_name, &cat)) { - return 0; + return false; } garmin_fs_t* gmsd = garmin_fs_t::find(waypt); @@ -210,5 +116,5 @@ garmin_fs_merge_category(const char* category_name, Waypoint* waypt) waypt->fs.FsChainAdd(gmsd); } garmin_fs_t::set_category(gmsd, cat); - return 1; + return true; } diff --git a/garmin_fs.h b/garmin_fs.h index fb39b5b90..0535d85ac 100644 --- a/garmin_fs.h +++ b/garmin_fs.h @@ -24,13 +24,12 @@ #ifndef GARMIN_FS_H #define GARMIN_FS_H -#include // for int32_t, int16_t, uint16_t +#include // for int32_t, int16_t, uint16_t -#include // for QString +#include // for QString #include "defs.h" -#include "formspec.h" // for FsChainFind, kFsGmsd, FormatSpecificData -#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter +#include "formspec.h" // for FormatSpecificData, kFsGmsd, FormatSpecificDataList /* this order is used by most devices */ @@ -219,16 +218,11 @@ garmin_fs_t* garmin_fs_alloc(int protocol); void garmin_fs_destroy(void* fs); void garmin_fs_copy(void** dest, const void* src); -/* for GPX */ -void garmin_fs_xml_convert(int base_tag, int tag, const QString& qstr, Waypoint* waypt); +/* ..convert_category: returns true=OK; false=Unable to convert category */ +bool garmin_fs_convert_category(const QString& category_name, uint16_t* category); -/* common garmin_fs utilities */ - -/* ..convert_category: returns 1=OK; 0=Unable to convert category */ -unsigned char garmin_fs_convert_category(const char* category_name, uint16_t* category); - -/* ..merge_category: returns 1=OK; 0=Unable to convert category */ -unsigned char garmin_fs_merge_category(const char* category_name, Waypoint* waypt); +/* ..merge_category: returns true=OK; false=Unable to convert category */ +bool garmin_fs_merge_category(const QString& category_name, Waypoint* waypt); #define GMSD_SECTION_CATEGORIES "Garmin Categories" diff --git a/garmin_txt.cc b/garmin_txt.cc index 8720621a1..c49569445 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -965,7 +965,7 @@ parse_categories(const QString& str) QString cin = catstring.trimmed(); if (!cin.isEmpty()) { uint16_t val; - if (!garmin_fs_convert_category(CSTR(cin), &val)) { + if (!garmin_fs_convert_category(cin, &val)) { warning(MYNAME ": Unable to convert category \"%s\" at line %d!\n", qPrintable(cin), current_line); } else { res = res | val; diff --git a/gpx.cc b/gpx.cc index 45c7606e5..de176e454 100644 --- a/gpx.cc +++ b/gpx.cc @@ -47,7 +47,7 @@ #include // for qAsConst, QAddConst<>::Type #include "defs.h" -#include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t, garmin_fs_xml_convert +#include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t, garmin_fs_alloc, garmin_fs_merge_category #include "garmin_tables.h" // for gt_color_index_by_rgb, gt_color_name, gt_color_value_by_name #include "geocache.h" // for Geocache, Geocache::UtfSt... #include "mkshort.h" // for MakeShort @@ -213,6 +213,69 @@ GpxFormat::tag_gs_cache(const QXmlStreamAttributes& attr) const } } +void +GpxFormat::tag_garmin_fs(tag_type tag, const QString& text, Waypoint* waypt) +{ + garmin_fs_t* gmsd = garmin_fs_t::find(waypt); + if (gmsd == nullptr) { + gmsd = garmin_fs_alloc(-1); + waypt->fs.FsChainAdd(gmsd); + } + + switch (tag) { + case tag_type::garmin_wpt_proximity: + waypt->set_proximity(text.toDouble()); + break; + case tag_type::garmin_wpt_temperature: + waypt->set_temperature(text.toFloat()); + break; + case tag_type::garmin_wpt_depth: + waypt->set_depth(text.toDouble()); + break; + case tag_type::garmin_wpt_display_mode: + // element DispalyMode value is case sensitive. + if (text == u"SymbolOnly") { + garmin_fs_t::set_display(gmsd, gt_display_mode_symbol); + } else if (text == u"SymbolAndDescription") { + garmin_fs_t::set_display(gmsd, gt_display_mode_symbol_and_comment); + } else { + garmin_fs_t::set_display(gmsd, gt_display_mode_symbol_and_name); + } + break; + case tag_type::garmin_wpt_category: + if (!garmin_fs_merge_category(text, waypt)) { + // There's nothing a user can really do about this (well, they could + // create a gpsbabel.ini that mapped them to garmin category numbers + // but that feature is so obscure and used in so few outputs that + // there's no reason to alarm the user. Just silently disregard + // category names that don't map cleanly. + // warning(MYNAME ": Unable to convert category \"%s\"!\n", CSTR(text)); + } + break; + case tag_type::garmin_wpt_addr: + garmin_fs_t::set_addr(gmsd, text); + break; + case tag_type::garmin_wpt_city: + garmin_fs_t::set_city(gmsd, text); + break; + case tag_type::garmin_wpt_state: + garmin_fs_t::set_state(gmsd, text); + break; + case tag_type::garmin_wpt_country: + garmin_fs_t::set_country(gmsd, text); + break; + case tag_type::garmin_wpt_postal_code: + garmin_fs_t::set_postal_code(gmsd, text); + break; + case tag_type::garmin_wpt_phone_nr: + garmin_fs_t::set_phone_nr(gmsd, text); + break; + default: + // do nothing + break; + } +} + void GpxFormat::start_something_else(QStringView el, const QXmlStreamAttributes& attr) { @@ -318,69 +381,70 @@ GpxFormat::gpx_start(QStringView el, const QXmlStreamAttributes& attr) tag_mapping tag = get_tag(current_tag); switch (tag.type) { - case tt_gpx: + case tag_type::gpx: tag_gpx(attr); break; - case tt_link: + case tag_type::link: if (attr.hasAttribute(QLatin1String("href"))) { link_url = attr.value(QLatin1String("href")).toString(); } break; - case tt_wpt: + case tag_type::wpt: tag_wpt(attr); break; - case tt_wpttype_link: + case tag_type::wpttype_link: if (attr.hasAttribute(QLatin1String("href"))) { link_url = attr.value(QLatin1String("href")).toString(); } break; - case tt_rte: + case tag_type::rte: rte_head = new route_head; route_add_head(rte_head); rh_link_ = new UrlLink; fs_ptr = &rte_head->fs; break; - case tt_rte_rtept: + case tag_type::rte_rtept: tag_wpt(attr); break; - case tt_trk: + case tag_type::trk: trk_head = new route_head; track_add_head(trk_head); rh_link_ = new UrlLink; fs_ptr = &trk_head->fs; break; - case tt_trk_trkseg_trkpt: + case tag_type::trk_trkseg_trkpt: tag_wpt(attr); if (next_trkpt_is_new_seg) { wpt_tmp->wpt_flags.new_trkseg = 1; next_trkpt_is_new_seg = 0; } break; - case tt_rte_link: - case tt_trk_link: + case tag_type::rte_link: + case tag_type::trk_link: if (attr.hasAttribute(QLatin1String("href"))) { link_url = attr.value(QLatin1String("href")).toString(); } break; - case tt_unknown: + case tag_type::unknown: start_something_else(el, attr); return; - case tt_cache: + case tag_type::cache: tag_gs_cache(attr); break; - case tt_cache_log_wpt: + case tag_type::cache_log_wpt: if (opt_logpoint) { tag_log_wpt(attr); } break; - case tt_cache_desc_long: - case tt_cache_desc_short: + case tag_type::cache_desc_long: + case tag_type::cache_desc_short: tag_cache_desc(attr); break; - case tt_cache_placer: + case tag_type::cache_placer: if (attr.hasAttribute(QLatin1String("id"))) { wpt_tmp->AllocGCData()->placer_id = attr.value(QLatin1String("id")).toInt(); } + break; default: break; } @@ -470,44 +534,44 @@ GpxFormat::gpx_end(QStringView /*unused*/) /* * First, the tags that are file-global. */ - case tt_name: + case tag_type::name: gpx_add_to_global(gpx_global->name, cdatastr); break; - case tt_desc: + case tag_type::desc: gpx_add_to_global(gpx_global->desc, cdatastr); break; - case tt_author: + case tag_type::author: gpx_add_to_global(gpx_global->author, cdatastr); break; - case tt_email: + case tag_type::email: gpx_add_to_global(gpx_global->email, cdatastr); break; - case tt_url: + case tag_type::url: gpx_add_to_global(gpx_global->url, cdatastr); break; - case tt_urlname: + case tag_type::urlname: gpx_add_to_global(gpx_global->urlname, cdatastr); break; - case tt_keywords: + case tag_type::keywords: gpx_add_to_global(gpx_global->keywords, cdatastr); break; - case tt_link: + case tag_type::link: (gpx_global->link).AddUrlLink(UrlLink(link_url, link_text, link_type)); link_type.clear(); link_text.clear(); link_url.clear(); break; - case tt_link_text: + case tag_type::link_text: link_text = cdatastr; break; - case tt_link_type: + case tag_type::link_type: link_type = cdatastr; break; /* * Waypoint-specific tags. */ - case tt_wpt: + case tag_type::wpt: if (link_) { if (!link_->url_.isEmpty()) { wpt_tmp->AddUrlLink(*link_); @@ -525,40 +589,40 @@ GpxFormat::gpx_end(QStringView /*unused*/) wpt_tmp = nullptr; fs_ptr = nullptr; break; - case tt_cache_name: + case tag_type::cache_name: wpt_tmp->notes = cdatastr; break; - case tt_cache_container: + case tag_type::cache_container: wpt_tmp->AllocGCData()->set_container(cdatastr); break; - case tt_cache_type: + case tag_type::cache_type: wpt_tmp->AllocGCData()->set_type(cdatastr); break; - case tt_cache_difficulty: + case tag_type::cache_difficulty: wpt_tmp->AllocGCData()->diff = cdatastr.toFloat() * 10; break; - case tt_cache_hint: + case tag_type::cache_hint: wpt_tmp->AllocGCData()->hint = cdatastr; break; - case tt_cache_desc_long: { + case tag_type::cache_desc_long: { Geocache* gc_data = wpt_tmp->AllocGCData(); gc_data->desc_long.is_html = cache_descr_is_html; gc_data->desc_long.utf_string = cdatastr; } break; - case tt_cache_desc_short: { + case tag_type::cache_desc_short: { Geocache* gc_data = wpt_tmp->AllocGCData(); gc_data->desc_short.is_html = cache_descr_is_html; gc_data->desc_short.utf_string = cdatastr; } break; - case tt_cache_terrain: + case tag_type::cache_terrain: wpt_tmp->AllocGCData()->terr = cdatastr.toFloat() * 10; break; - case tt_cache_placer: + case tag_type::cache_placer: wpt_tmp->AllocGCData()->placer = cdatastr; break; - case tt_cache_log_date: + case tag_type::cache_log_date: gc_log_date = xml_parse_time(cdatastr); break; /* @@ -566,51 +630,51 @@ GpxFormat::gpx_end(QStringView /*unused*/) * if this is the first "found it" for this waypt, just use the * last date we saw in this log. */ - case tt_cache_log_type: + case tag_type::cache_log_type: if ((cdatastr.compare(u"Found it") == 0) && (!wpt_tmp->gc_data->last_found.isValid())) { wpt_tmp->AllocGCData()->last_found = gc_log_date; } gc_log_date = gpsbabel::DateTime(); break; - case tt_cache_favorite_points: + case tag_type::cache_favorite_points: wpt_tmp->AllocGCData()->favorite_points = cdatastr.toInt(); break; - case tt_cache_personal_note: + case tag_type::cache_personal_note: wpt_tmp->AllocGCData()->personal_note = cdatastr; break; /* * Garmin-waypoint-specific tags. */ - case tt_garmin_wpt_proximity: - case tt_garmin_wpt_temperature: - case tt_garmin_wpt_depth: - case tt_garmin_wpt_display_mode: - case tt_garmin_wpt_category: - case tt_garmin_wpt_addr: - case tt_garmin_wpt_city: - case tt_garmin_wpt_state: - case tt_garmin_wpt_country: - case tt_garmin_wpt_postal_code: - case tt_garmin_wpt_phone_nr: - garmin_fs_xml_convert(tt_garmin_wpt_extensions, tag.type, cdatastr, wpt_tmp); + case tag_type::garmin_wpt_proximity: + case tag_type::garmin_wpt_temperature: + case tag_type::garmin_wpt_depth: + case tag_type::garmin_wpt_display_mode: + case tag_type::garmin_wpt_category: + case tag_type::garmin_wpt_addr: + case tag_type::garmin_wpt_city: + case tag_type::garmin_wpt_state: + case tag_type::garmin_wpt_country: + case tag_type::garmin_wpt_postal_code: + case tag_type::garmin_wpt_phone_nr: + tag_garmin_fs(tag.type, cdatastr, wpt_tmp); break; /* * Humminbird-waypoint-specific tags. */ - case tt_humminbird_wpt_depth: - case tt_humminbird_trk_trkseg_trkpt_depth: + case tag_type::humminbird_wpt_depth: + case tag_type::humminbird_trk_trkseg_trkpt_depth: wpt_tmp->set_depth(cdatastr.toDouble() / 100.0); break; /* * Route-specific tags. */ - case tt_rte_name: + case tag_type::rte_name: rte_head->rte_name = cdatastr; break; - case tt_rte: + case tag_type::rte: if (rh_link_) { if (!rh_link_->url_.isEmpty()) { rte_head->rte_urls.AddUrlLink(*rh_link_); @@ -620,7 +684,7 @@ GpxFormat::gpx_end(QStringView /*unused*/) } fs_ptr = nullptr; break; - case tt_rte_rtept: + case tag_type::rte_rtept: if (link_) { if (!link_->url_.isEmpty()) { wpt_tmp->AddUrlLink(*link_); @@ -636,28 +700,28 @@ GpxFormat::gpx_end(QStringView /*unused*/) wpt_tmp = nullptr; fs_ptr = nullptr; break; - case tt_rte_desc: + case tag_type::rte_desc: rte_head->rte_desc = cdatastr; break; - case tt_garmin_rte_display_color: + case tag_type::garmin_rte_display_color: rte_head->line_color.bbggrr = gt_color_value_by_name(cdatastr); break; - case tt_rte_link: + case tag_type::rte_link: rte_head->rte_urls.AddUrlLink(UrlLink(link_url, link_text, link_type)); link_type.clear(); link_text.clear(); link_url.clear(); break; - case tt_rte_number: + case tag_type::rte_number: rte_head->rte_num = cdatastr.toInt(); break; /* * Track-specific tags. */ - case tt_trk_name: + case tag_type::trk_name: trk_head->rte_name = cdatastr; break; - case tt_trk: + case tag_type::trk: if (rh_link_) { if (!rh_link_->url_.isEmpty()) { trk_head->rte_urls.AddUrlLink(*rh_link_); @@ -667,11 +731,11 @@ GpxFormat::gpx_end(QStringView /*unused*/) } fs_ptr = nullptr; break; - case tt_trk_trkseg: + case tag_type::trk_trkseg: next_trkpt_is_new_seg = 1; fs_ptr = nullptr; break; - case tt_trk_trkseg_trkpt: + case tag_type::trk_trkseg_trkpt: if (link_) { if (!link_->url_.isEmpty()) { wpt_tmp->AddUrlLink(*link_); @@ -687,117 +751,117 @@ GpxFormat::gpx_end(QStringView /*unused*/) wpt_tmp = nullptr; fs_ptr = nullptr; break; - case tt_trk_desc: + case tag_type::trk_desc: trk_head->rte_desc = cdatastr; break; - case tt_garmin_trk_display_color: + case tag_type::garmin_trk_display_color: trk_head->line_color.bbggrr = gt_color_value_by_name(cdatastr); break; - case tt_trk_link: + case tag_type::trk_link: trk_head->rte_urls.AddUrlLink(UrlLink(link_url, link_text, link_type)); link_type.clear(); link_text.clear(); link_url.clear(); break; - case tt_trk_number: + case tag_type::trk_number: trk_head->rte_num = cdatastr.toInt(); break; - case tt_trk_trkseg_trkpt_course: + case tag_type::trk_trkseg_trkpt_course: wpt_tmp->set_course(cdatastr.toDouble()); break; - case tt_trk_trkseg_trkpt_speed: + case tag_type::trk_trkseg_trkpt_speed: wpt_tmp->set_speed(cdatastr.toDouble()); break; - case tt_trk_trkseg_trkpt_heartrate: + case tag_type::trk_trkseg_trkpt_heartrate: wpt_tmp->heartrate = cdatastr.toDouble(); break; - case tt_trk_trkseg_trkpt_cadence: + case tag_type::trk_trkseg_trkpt_cadence: wpt_tmp->cadence = cdatastr.toDouble(); break; /* * Items that are actually in multiple categories. */ - case tt_rte_url: - case tt_trk_url: + case tag_type::rte_url: + case tag_type::trk_url: rh_link_->url_ = cdatastr; break; - case tt_rte_urlname: - case tt_trk_urlname: + case tag_type::rte_urlname: + case tag_type::trk_urlname: rh_link_->url_link_text_ = cdatastr; break; - case tt_rte_link_text: - case tt_trk_link_text: + case tag_type::rte_link_text: + case tag_type::trk_link_text: link_text = cdatastr; break; - case tt_rte_link_type: - case tt_trk_link_type: + case tag_type::rte_link_type: + case tag_type::trk_link_type: link_type = cdatastr; break; - case tt_wpttype_ele: + case tag_type::wpttype_ele: wpt_tmp->altitude = cdatastr.toDouble(); break; - case tt_wpttype_name: + case tag_type::wpttype_name: wpt_tmp->shortname = cdatastr; break; - case tt_wpttype_sym: + case tag_type::wpttype_sym: wpt_tmp->icon_descr = cdatastr; break; - case tt_wpttype_time: + case tag_type::wpttype_time: wpt_tmp->SetCreationTime(xml_parse_time(cdatastr)); break; - case tt_wpttype_magvar: + case tag_type::wpttype_magvar: if (wpt_fsdata == nullptr) { wpt_fsdata = new gpx_wpt_fsdata; } wpt_fsdata->magvar = cdatastr; break; - case tt_wpttype_geoidheight: + case tag_type::wpttype_geoidheight: wpt_tmp->set_geoidheight(cdatastr.toDouble()); break; - case tt_wpttype_cmt: + case tag_type::wpttype_cmt: wpt_tmp->description = cdatastr; break; - case tt_wpttype_desc: + case tag_type::wpttype_desc: wpt_tmp->notes = cdatastr; break; - case tt_wpttype_src: + case tag_type::wpttype_src: if (wpt_fsdata == nullptr) { wpt_fsdata = new gpx_wpt_fsdata; } wpt_fsdata->src = cdatastr; break; - case tt_wpttype_type: + case tag_type::wpttype_type: if (wpt_fsdata == nullptr) { wpt_fsdata = new gpx_wpt_fsdata; } wpt_fsdata->type = cdatastr; break; - case tt_wpttype_pdop: + case tag_type::wpttype_pdop: wpt_tmp->pdop = cdatastr.toFloat(); break; - case tt_wpttype_hdop: + case tag_type::wpttype_hdop: wpt_tmp->hdop = cdatastr.toFloat(); break; - case tt_wpttype_vdop: + case tag_type::wpttype_vdop: wpt_tmp->vdop = cdatastr.toFloat(); break; - case tt_wpttype_ageofdgpsdata: + case tag_type::wpttype_ageofdgpsdata: if (wpt_fsdata == nullptr) { wpt_fsdata = new gpx_wpt_fsdata; } wpt_fsdata->ageofdgpsdata = cdatastr; break; - case tt_wpttype_dgpsid: + case tag_type::wpttype_dgpsid: if (wpt_fsdata == nullptr) { wpt_fsdata = new gpx_wpt_fsdata; } wpt_fsdata->dgpsid = cdatastr; break; - case tt_wpttype_sat: + case tag_type::wpttype_sat: wpt_tmp->sat = cdatastr.toInt(); break; - case tt_wpttype_fix: + case tag_type::wpttype_fix: if (cdatastr == QLatin1String("none")) { wpt_tmp->fix = fix_none; } else if (cdatastr == QLatin1String("2d")) { @@ -812,25 +876,25 @@ GpxFormat::gpx_end(QStringView /*unused*/) wpt_tmp->fix = fix_unknown; } break; - case tt_wpttype_url: + case tag_type::wpttype_url: link_->url_ = cdatastr; break; - case tt_wpttype_urlname: + case tag_type::wpttype_urlname: link_->url_link_text_ = cdatastr; break; - case tt_wpttype_link: + case tag_type::wpttype_link: waypt_add_url(wpt_tmp, link_url, link_text, link_type); link_type.clear(); link_text.clear(); link_url.clear(); break; - case tt_wpttype_link_text: + case tag_type::wpttype_link_text: link_text = cdatastr; break; - case tt_wpttype_link_type: + case tag_type::wpttype_link_type: link_type = cdatastr; break; - case tt_unknown: + case tag_type::unknown: end_something_else(); return; default: diff --git a/gpx.h b/gpx.h index a658404ba..c0d0218ac 100644 --- a/gpx.h +++ b/gpx.h @@ -95,112 +95,112 @@ class GpxFormat : public Format gpxpt_route }; - enum tag_type { - tt_unknown = 0, - tt_gpx, - - tt_name, /* Optional file-level info */ - tt_desc, - tt_author, - tt_email, - tt_url, - tt_urlname, - tt_keywords, - tt_link, - tt_link_text, - tt_link_type, - - tt_wpt, - tt_wpttype_ele, - tt_wpttype_time, - tt_wpttype_magvar, - tt_wpttype_geoidheight, - tt_wpttype_name, - tt_wpttype_cmt, - tt_wpttype_desc, - tt_wpttype_src, - tt_wpttype_url, /* Not in GPX 1.1 */ - tt_wpttype_urlname, /* Not in GPX 1.1 */ - tt_wpttype_link, /* New in GPX 1.1 */ - tt_wpttype_link_text, /* New in GPX 1.1 */ - tt_wpttype_link_type, /* New in GPX 1.1 */ - tt_wpttype_sym, - tt_wpttype_type, - tt_wpttype_fix, - tt_wpttype_sat, - tt_wpttype_hdop, /* HDOPS are common for all three */ - tt_wpttype_vdop, /* VDOPS are common for all three */ - tt_wpttype_pdop, /* PDOPS are common for all three */ - tt_wpttype_ageofdgpsdata, - tt_wpttype_dgpsid, - tt_cache, - tt_cache_name, - tt_cache_container, - tt_cache_type, - tt_cache_difficulty, - tt_cache_terrain, - tt_cache_hint, - tt_cache_desc_short, - tt_cache_desc_long, - tt_cache_log_wpt, - tt_cache_log_type, - tt_cache_log_date, - tt_cache_placer, - tt_cache_favorite_points, - tt_cache_personal_note, - - tt_wpt_extensions, - - tt_garmin_wpt_extensions, /* don't change this order */ - tt_garmin_wpt_proximity, - tt_garmin_wpt_temperature, - tt_garmin_wpt_depth, - tt_garmin_wpt_display_mode, - tt_garmin_wpt_categories, - tt_garmin_wpt_category, - tt_garmin_wpt_addr, - tt_garmin_wpt_city, - tt_garmin_wpt_state, - tt_garmin_wpt_country, - tt_garmin_wpt_postal_code, - tt_garmin_wpt_phone_nr, /* don't change this order */ - - tt_rte, - tt_rte_name, - tt_rte_desc, - tt_rte_cmt, - tt_rte_url, /* Not in GPX 1.1 */ - tt_rte_urlname, /* Not in GPX 1.1 */ - tt_rte_link, /* New in GPX 1.1 */ - tt_rte_link_text, /* New in GPX 1.1 */ - tt_rte_link_type, /* New in GPX 1.1 */ - tt_rte_number, - tt_garmin_rte_display_color, - tt_rte_rtept, - tt_trk, - tt_trk_desc, - tt_trk_name, - tt_trk_trkseg, - tt_trk_url, /* Not in GPX 1.1 */ - tt_trk_urlname, /* Not in GPX 1.1 */ - tt_trk_link, /* New in GPX 1.1 */ - tt_trk_link_text, /* New in GPX 1.1 */ - tt_trk_link_type, /* New in GPX 1.1 */ - tt_trk_number, - tt_garmin_trk_display_color, - tt_trk_trkseg_trkpt, - tt_trk_trkseg_trkpt_course, /* Not in GPX 1.1 */ - tt_trk_trkseg_trkpt_speed, /* Not in GPX 1.1 */ - tt_trk_trkseg_trkpt_heartrate, - tt_trk_trkseg_trkpt_cadence, - - tt_humminbird_wpt_depth, - tt_humminbird_wpt_status, - tt_humminbird_trk_trkseg_trkpt_depth, + enum class tag_type { + unknown = 0, + gpx, + + name, /* Optional file-level info */ + desc, + author, + email, + url, + urlname, + keywords, + link, + link_text, + link_type, + + wpt, + wpttype_ele, + wpttype_time, + wpttype_magvar, + wpttype_geoidheight, + wpttype_name, + wpttype_cmt, + wpttype_desc, + wpttype_src, + wpttype_url, /* Not in GPX 1.1 */ + wpttype_urlname, /* Not in GPX 1.1 */ + wpttype_link, /* New in GPX 1.1 */ + wpttype_link_text, /* New in GPX 1.1 */ + wpttype_link_type, /* New in GPX 1.1 */ + wpttype_sym, + wpttype_type, + wpttype_fix, + wpttype_sat, + wpttype_hdop, /* HDOPS are common for all three */ + wpttype_vdop, /* VDOPS are common for all three */ + wpttype_pdop, /* PDOPS are common for all three */ + wpttype_ageofdgpsdata, + wpttype_dgpsid, + cache, + cache_name, + cache_container, + cache_type, + cache_difficulty, + cache_terrain, + cache_hint, + cache_desc_short, + cache_desc_long, + cache_log_wpt, + cache_log_type, + cache_log_date, + cache_placer, + cache_favorite_points, + cache_personal_note, + + wpt_extensions, + + garmin_wpt_extensions, + garmin_wpt_proximity, + garmin_wpt_temperature, + garmin_wpt_depth, + garmin_wpt_display_mode, + garmin_wpt_categories, + garmin_wpt_category, + garmin_wpt_addr, + garmin_wpt_city, + garmin_wpt_state, + garmin_wpt_country, + garmin_wpt_postal_code, + garmin_wpt_phone_nr, + + rte, + rte_name, + rte_desc, + rte_cmt, + rte_url, /* Not in GPX 1.1 */ + rte_urlname, /* Not in GPX 1.1 */ + rte_link, /* New in GPX 1.1 */ + rte_link_text, /* New in GPX 1.1 */ + rte_link_type, /* New in GPX 1.1 */ + rte_number, + garmin_rte_display_color, + rte_rtept, + trk, + trk_desc, + trk_name, + trk_trkseg, + trk_url, /* Not in GPX 1.1 */ + trk_urlname, /* Not in GPX 1.1 */ + trk_link, /* New in GPX 1.1 */ + trk_link_text, /* New in GPX 1.1 */ + trk_link_type, /* New in GPX 1.1 */ + trk_number, + garmin_trk_display_color, + trk_trkseg_trkpt, + trk_trkseg_trkpt_course, /* Not in GPX 1.1 */ + trk_trkseg_trkpt_speed, /* Not in GPX 1.1 */ + trk_trkseg_trkpt_heartrate, + trk_trkseg_trkpt_cadence, + + humminbird_wpt_depth, + humminbird_wpt_status, + humminbird_trk_trkseg_trkpt_depth, }; struct tag_mapping { - tag_type type{tt_unknown}; /* enum from above for this tag */ + tag_type type{tag_type::unknown}; /* enum from above for this tag */ /* * passthrough should be true for * 1) The gpx 1.1 extensions element and any descendents. @@ -221,6 +221,7 @@ class GpxFormat : public Format void tag_wpt(const QXmlStreamAttributes& attr); void tag_cache_desc(const QXmlStreamAttributes& attr); void tag_gs_cache(const QXmlStreamAttributes& attr) const; + void tag_garmin_fs(tag_type tag, const QString& text, Waypoint* waypt); void start_something_else(QStringView el, const QXmlStreamAttributes& attr); void end_something_else(); void tag_log_wpt(const QXmlStreamAttributes& attr) const; @@ -346,117 +347,117 @@ class GpxFormat : public Format // Maintain a fast mapping from full tag names to the struct above. const QHash hash = { - {"/gpx", {tt_gpx, false}}, - METATAG(tt_name, "name"), - METATAG(tt_desc, "desc"), - {"/gpx/author", {tt_author, false}}, - {"/gpx/email", {tt_email, false}}, - {"/gpx/url", {tt_url, false}}, - {"/gpx/urlname", {tt_urlname, false}}, - METATAG(tt_keywords, "keywords"), - {"/gpx/metadata/link", {tt_link, false}}, - {"/gpx/metadata/link/text", {tt_link_text, false}}, - {"/gpx/metadata/link/type", {tt_link_type, false}}, - - {"/gpx/wpt", {tt_wpt, false}}, + {"/gpx", {tag_type::gpx, false}}, + METATAG(tag_type::name, "name"), + METATAG(tag_type::desc, "desc"), + {"/gpx/author", {tag_type::author, false}}, + {"/gpx/email", {tag_type::email, false}}, + {"/gpx/url", {tag_type::url, false}}, + {"/gpx/urlname", {tag_type::urlname, false}}, + METATAG(tag_type::keywords, "keywords"), + {"/gpx/metadata/link", {tag_type::link, false}}, + {"/gpx/metadata/link/text", {tag_type::link_text, false}}, + {"/gpx/metadata/link/type", {tag_type::link_type, false}}, + + {"/gpx/wpt", {tag_type::wpt, false}}, /* Double up the GPX 1.0 and GPX 1.1 styles */ // GEOTAG(tt_cache, "cache"), - {"/gpx/wpt/groundspeak:cache", {tt_cache, true}}, - - GEOTAG(tt_cache_name, "name"), - GEOTAG(tt_cache_container, "container"), - GEOTAG(tt_cache_type, "type"), - GEOTAG(tt_cache_difficulty, "difficulty"), - GEOTAG(tt_cache_terrain, "terrain"), - GEOTAG(tt_cache_hint, "encoded_hints"), - GEOTAG(tt_cache_desc_short, "short_description"), - GEOTAG(tt_cache_desc_long, "long_description"), - GEOTAG(tt_cache_placer, "owner"), - GEOTAG(tt_cache_favorite_points, "favorite_points"), - GEOTAG(tt_cache_personal_note, "personal_note"), - {"/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:log_wpt", {tt_cache_log_wpt, true}}, - {"/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:type", {tt_cache_log_type, true}}, - {"/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:date", {tt_cache_log_date, true}}, - - {"/gpx/wpt/extensions", {tt_wpt_extensions, true}}, - - {GARMIN_WPT_EXT, {tt_garmin_wpt_extensions, true}}, - {GARMIN_WPT_EXT "/gpxx:Proximity", {tt_garmin_wpt_proximity, true}}, - {GARMIN_WPT_EXT "/gpxx:Temperature", {tt_garmin_wpt_temperature, true}}, - {GARMIN_TRKPT_EXT "/gpxtpx:atemp", {tt_garmin_wpt_temperature, true}}, - {GARMIN_WPT_EXT "/gpxx:Depth", {tt_garmin_wpt_depth, true}}, - {GARMIN_WPT_EXT "/gpxx:DisplayMode", {tt_garmin_wpt_display_mode, true}}, - {GARMIN_WPT_EXT "/gpxx:Categories", {tt_garmin_wpt_categories, true}}, - {GARMIN_WPT_EXT "/gpxx:Categories/gpxx:Category", {tt_garmin_wpt_category, true}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:StreetAddress", {tt_garmin_wpt_addr, true}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:City", {tt_garmin_wpt_city, true}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:State", {tt_garmin_wpt_state, true}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:Country", {tt_garmin_wpt_country, true}}, - {GARMIN_WPT_EXT "/gpxx:Address/gpxx:PostalCode", {tt_garmin_wpt_postal_code, true}}, - {GARMIN_WPT_EXT "/gpxx:PhoneNumber", {tt_garmin_wpt_phone_nr, true}}, + {"/gpx/wpt/groundspeak:cache", {tag_type::cache, true}}, + + GEOTAG(tag_type::cache_name, "name"), + GEOTAG(tag_type::cache_container, "container"), + GEOTAG(tag_type::cache_type, "type"), + GEOTAG(tag_type::cache_difficulty, "difficulty"), + GEOTAG(tag_type::cache_terrain, "terrain"), + GEOTAG(tag_type::cache_hint, "encoded_hints"), + GEOTAG(tag_type::cache_desc_short, "short_description"), + GEOTAG(tag_type::cache_desc_long, "long_description"), + GEOTAG(tag_type::cache_placer, "owner"), + GEOTAG(tag_type::cache_favorite_points, "favorite_points"), + GEOTAG(tag_type::cache_personal_note, "personal_note"), + {"/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:log_wpt", {tag_type::cache_log_wpt, true}}, + {"/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:type", {tag_type::cache_log_type, true}}, + {"/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:date", {tag_type::cache_log_date, true}}, + + {"/gpx/wpt/extensions", {tag_type::wpt_extensions, true}}, + + {GARMIN_WPT_EXT, {tag_type::garmin_wpt_extensions, true}}, + {GARMIN_WPT_EXT "/gpxx:Proximity", {tag_type::garmin_wpt_proximity, true}}, + {GARMIN_WPT_EXT "/gpxx:Temperature", {tag_type::garmin_wpt_temperature, true}}, + {GARMIN_TRKPT_EXT "/gpxtpx:atemp", {tag_type::garmin_wpt_temperature, true}}, + {GARMIN_WPT_EXT "/gpxx:Depth", {tag_type::garmin_wpt_depth, true}}, + {GARMIN_WPT_EXT "/gpxx:DisplayMode", {tag_type::garmin_wpt_display_mode, true}}, + {GARMIN_WPT_EXT "/gpxx:Categories", {tag_type::garmin_wpt_categories, true}}, + {GARMIN_WPT_EXT "/gpxx:Categories/gpxx:Category", {tag_type::garmin_wpt_category, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:StreetAddress", {tag_type::garmin_wpt_addr, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:City", {tag_type::garmin_wpt_city, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:State", {tag_type::garmin_wpt_state, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:Country", {tag_type::garmin_wpt_country, true}}, + {GARMIN_WPT_EXT "/gpxx:Address/gpxx:PostalCode", {tag_type::garmin_wpt_postal_code, true}}, + {GARMIN_WPT_EXT "/gpxx:PhoneNumber", {tag_type::garmin_wpt_phone_nr, true}}, // In Garmin space, but in core of waypoint. - {GARMIN_TRKPT_EXT "/gpxtpx:hr", {tt_trk_trkseg_trkpt_heartrate, true}}, - {GARMIN_TRKPT_EXT "/gpxtpx:cad", {tt_trk_trkseg_trkpt_cadence, true}}, - - {"/gpx/wpt/extensions/h:depth", {tt_humminbird_wpt_depth, true}}, // in centimeters. - {"/gpx/wpt/extensions/h:status", {tt_humminbird_wpt_status, true}}, - - {"/gpx/rte", {tt_rte, false}}, - {"/gpx/rte/name", {tt_rte_name, false}}, - {"/gpx/rte/desc", {tt_rte_desc, false}}, - {"/gpx/rte/url", {tt_rte_url, false}}, /* GPX 1.0 */ - {"/gpx/rte/urlname", {tt_rte_urlname, false}}, /* GPX 1.0 */ - {"/gpx/rte/link", {tt_rte_link, false}}, /* GPX 1.1 */ - {"/gpx/rte/link/text", {tt_rte_link_text, false}}, /* GPX 1.1 */ - {"/gpx/rte/link/type", {tt_rte_link_type, false}}, /* GPX 1.1 */ - {"/gpx/rte/number", {tt_rte_number, false}}, - {GARMIN_RTE_EXT "/gpxx:DisplayColor", {tt_garmin_rte_display_color, true}}, - - {"/gpx/rte/rtept", {tt_rte_rtept, false}}, - - {"/gpx/trk", {tt_trk, false}}, - {"/gpx/trk/name", {tt_trk_name, false}}, - {"/gpx/trk/desc", {tt_trk_desc, false}}, - {"/gpx/trk/trkseg", {tt_trk_trkseg, false}}, - {"/gpx/trk/url", {tt_trk_url, false}}, /* GPX 1.0 */ - {"/gpx/trk/urlname", {tt_trk_urlname, false}}, /* GPX 1.0 */ - {"/gpx/trk/link", {tt_trk_link, false}}, /* GPX 1.1 */ - {"/gpx/trk/link/text", {tt_trk_link_text, false}}, /* GPX 1.1 */ - {"/gpx/trk/link/type", {tt_trk_link_type, false}}, /* GPX 1.1 */ - {"/gpx/trk/number", {tt_trk_number, false}}, - {GARMIN_TRK_EXT "/gpxx:DisplayColor", {tt_garmin_trk_display_color, true}}, - - {"/gpx/trk/trkseg/trkpt", {tt_trk_trkseg_trkpt, false}}, - {"/gpx/trk/trkseg/trkpt/course", {tt_trk_trkseg_trkpt_course, false}}, - {"/gpx/trk/trkseg/trkpt/speed", {tt_trk_trkseg_trkpt_speed, false}}, - - {"/gpx/trk/trkseg/trkpt/extensions/h:depth", {tt_humminbird_trk_trkseg_trkpt_depth, true}}, // in centimeters. + {GARMIN_TRKPT_EXT "/gpxtpx:hr", {tag_type::trk_trkseg_trkpt_heartrate, true}}, + {GARMIN_TRKPT_EXT "/gpxtpx:cad", {tag_type::trk_trkseg_trkpt_cadence, true}}, + + {"/gpx/wpt/extensions/h:depth", {tag_type::humminbird_wpt_depth, true}}, // in centimeters. + {"/gpx/wpt/extensions/h:status", {tag_type::humminbird_wpt_status, true}}, + + {"/gpx/rte", {tag_type::rte, false}}, + {"/gpx/rte/name", {tag_type::rte_name, false}}, + {"/gpx/rte/desc", {tag_type::rte_desc, false}}, + {"/gpx/rte/url", {tag_type::rte_url, false}}, /* GPX 1.0 */ + {"/gpx/rte/urlname", {tag_type::rte_urlname, false}}, /* GPX 1.0 */ + {"/gpx/rte/link", {tag_type::rte_link, false}}, /* GPX 1.1 */ + {"/gpx/rte/link/text", {tag_type::rte_link_text, false}}, /* GPX 1.1 */ + {"/gpx/rte/link/type", {tag_type::rte_link_type, false}}, /* GPX 1.1 */ + {"/gpx/rte/number", {tag_type::rte_number, false}}, + {GARMIN_RTE_EXT "/gpxx:DisplayColor", {tag_type::garmin_rte_display_color, true}}, + + {"/gpx/rte/rtept", {tag_type::rte_rtept, false}}, + + {"/gpx/trk", {tag_type::trk, false}}, + {"/gpx/trk/name", {tag_type::trk_name, false}}, + {"/gpx/trk/desc", {tag_type::trk_desc, false}}, + {"/gpx/trk/trkseg", {tag_type::trk_trkseg, false}}, + {"/gpx/trk/url", {tag_type::trk_url, false}}, /* GPX 1.0 */ + {"/gpx/trk/urlname", {tag_type::trk_urlname, false}}, /* GPX 1.0 */ + {"/gpx/trk/link", {tag_type::trk_link, false}}, /* GPX 1.1 */ + {"/gpx/trk/link/text", {tag_type::trk_link_text, false}}, /* GPX 1.1 */ + {"/gpx/trk/link/type", {tag_type::trk_link_type, false}}, /* GPX 1.1 */ + {"/gpx/trk/number", {tag_type::trk_number, false}}, + {GARMIN_TRK_EXT "/gpxx:DisplayColor", {tag_type::garmin_trk_display_color, true}}, + + {"/gpx/trk/trkseg/trkpt", {tag_type::trk_trkseg_trkpt, false}}, + {"/gpx/trk/trkseg/trkpt/course", {tag_type::trk_trkseg_trkpt_course, false}}, + {"/gpx/trk/trkseg/trkpt/speed", {tag_type::trk_trkseg_trkpt_speed, false}}, + + {"/gpx/trk/trkseg/trkpt/extensions/h:depth", {tag_type::humminbird_trk_trkseg_trkpt_depth, true}}, // in centimeters. /* Common to tracks, routes, and waypts */ - GPXWPTTYPETAG("ele", tt_wpttype_ele, false), - GPXWPTTYPETAG("time", tt_wpttype_time, false), - GPXWPTTYPETAG("magvar", tt_wpttype_magvar, false), - GPXWPTTYPETAG("geoidheight", tt_wpttype_geoidheight, false), - GPXWPTTYPETAG("name", tt_wpttype_name, false), - GPXWPTTYPETAG("cmt", tt_wpttype_cmt, false), - GPXWPTTYPETAG("desc", tt_wpttype_desc, false), - GPXWPTTYPETAG("src", tt_wpttype_src, false), - GPXWPTTYPETAG("url", tt_wpttype_url, false), /* GPX 1.0 */ - GPXWPTTYPETAG("urlname", tt_wpttype_urlname, false), /* GPX 1.0 */ - GPXWPTTYPETAG("link", tt_wpttype_link, false), /* GPX 1.1 */ - GPXWPTTYPETAG("link/text", tt_wpttype_link_text, false), /* GPX 1.1 */ - GPXWPTTYPETAG("link/type", tt_wpttype_link_type, false), /* GPX 1.1 */ - GPXWPTTYPETAG("sym", tt_wpttype_sym, false), - GPXWPTTYPETAG("type", tt_wpttype_type, false), - GPXWPTTYPETAG("fix", tt_wpttype_fix, false), - GPXWPTTYPETAG("sat", tt_wpttype_sat, false), - GPXWPTTYPETAG("hdop", tt_wpttype_hdop, false), - GPXWPTTYPETAG("vdop", tt_wpttype_vdop, false), - GPXWPTTYPETAG("pdop", tt_wpttype_pdop, false), - GPXWPTTYPETAG("ageofdgpsdata", tt_wpttype_ageofdgpsdata, false), - GPXWPTTYPETAG("dgpsid", tt_wpttype_dgpsid, false), + GPXWPTTYPETAG("ele", tag_type::wpttype_ele, false), + GPXWPTTYPETAG("time", tag_type::wpttype_time, false), + GPXWPTTYPETAG("magvar", tag_type::wpttype_magvar, false), + GPXWPTTYPETAG("geoidheight", tag_type::wpttype_geoidheight, false), + GPXWPTTYPETAG("name", tag_type::wpttype_name, false), + GPXWPTTYPETAG("cmt", tag_type::wpttype_cmt, false), + GPXWPTTYPETAG("desc", tag_type::wpttype_desc, false), + GPXWPTTYPETAG("src", tag_type::wpttype_src, false), + GPXWPTTYPETAG("url", tag_type::wpttype_url, false), /* GPX 1.0 */ + GPXWPTTYPETAG("urlname", tag_type::wpttype_urlname, false), /* GPX 1.0 */ + GPXWPTTYPETAG("link", tag_type::wpttype_link, false), /* GPX 1.1 */ + GPXWPTTYPETAG("link/text", tag_type::wpttype_link_text, false), /* GPX 1.1 */ + GPXWPTTYPETAG("link/type", tag_type::wpttype_link_type, false), /* GPX 1.1 */ + GPXWPTTYPETAG("sym", tag_type::wpttype_sym, false), + GPXWPTTYPETAG("type", tag_type::wpttype_type, false), + GPXWPTTYPETAG("fix", tag_type::wpttype_fix, false), + GPXWPTTYPETAG("sat", tag_type::wpttype_sat, false), + GPXWPTTYPETAG("hdop", tag_type::wpttype_hdop, false), + GPXWPTTYPETAG("vdop", tag_type::wpttype_vdop, false), + GPXWPTTYPETAG("pdop", tag_type::wpttype_pdop, false), + GPXWPTTYPETAG("ageofdgpsdata", tag_type::wpttype_ageofdgpsdata, false), + GPXWPTTYPETAG("dgpsid", tag_type::wpttype_dgpsid, false), }; QVector gpx_args = { From bc0e8b94c30f2bf3b8927e9837deba0400da6efc Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 1 Nov 2023 07:16:44 -0600 Subject: [PATCH 030/132] refactor garmin_fs class (#1203) * use container for garmin_fs ilinks. and leave memory management up to the copy on write container. * make gmsd const for read only usage. this prevents the possiblity of detachment of the ilinks list. * incorporate some variables and functions into garmin_fs_t * unify garmin category conversions. * fiddle with test time zone sensitivity. * add utc option for garmin_txt reader. * correct sign of adjustment * update garmin_txt includes. --- garmin.cc | 4 +- garmin_fs.cc | 95 ++++++++++++---------------------- garmin_fs.h | 50 +++++++++--------- garmin_gpi.cc | 6 +-- garmin_txt.cc | 84 +++++++++++++++--------------- gdb.cc | 53 +++++++------------ gdb.h | 2 +- gpx.cc | 39 +++++++------- random.cc | 4 +- reference/garmincategories.gpx | 35 +++++++++++++ reference/garmincategories.txt | 7 +++ testo.d/gpx.test | 7 +++ unicsv.cc | 8 +-- util.cc | 4 +- waypt.cc | 18 +++---- xcsv.cc | 20 +++---- 16 files changed, 219 insertions(+), 217 deletions(-) create mode 100644 reference/garmincategories.gpx create mode 100644 reference/garmincategories.txt diff --git a/garmin.cc b/garmin.cc index 1382f9ead..dd04edc42 100644 --- a/garmin.cc +++ b/garmin.cc @@ -1241,7 +1241,7 @@ d103_icon_number_from_symbol(const QString& s) static void garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid) { - garmin_fs_t* gmsd = garmin_fs_alloc(protoid); + auto* gmsd = new garmin_fs_t(protoid); wpt->fs.FsChainAdd(gmsd); /* nothing happens until gmsd is allocated some lines above */ @@ -1275,7 +1275,7 @@ garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid static void garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, const int protoid) { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); (void)protoid; // unused for now. diff --git a/garmin_fs.cc b/garmin_fs.cc index 148db9169..525523005 100644 --- a/garmin_fs.cc +++ b/garmin_fs.cc @@ -29,92 +29,61 @@ #include "inifile.h" // for inifile_readstr -#define MYNAME "garmin_fs" - -garmin_fs_t* -garmin_fs_alloc(const int protocol) -{ - auto* result = new garmin_fs_t; - - result->protocol = protocol; - - return result; -} - -garmin_fs_t* garmin_fs_t::clone() const +std::optional +garmin_fs_t::convert_category(const QString& category_name) { - auto* copy = new garmin_fs_t(*this); + std::optional category; - /* do not deep copy interlinks, only increment the reference counter */ - if (ilinks != nullptr) { - ilinks->ref_count++; - } - -#ifdef GMSD_EXPERIMENTAL - memcopy(subclass, other.subclass, sizeof(subclass)); -#endif - - return copy; -} - -garmin_fs_t::~garmin_fs_t() -{ - garmin_ilink_t* links; - if ((links = ilinks) != nullptr) { - links->ref_count--; - if (links->ref_count <= 0) { - while (links != nullptr) { - garmin_ilink_t* tmp = links; - links = links->next; - xfree(tmp); - } - } - } -} - -bool -garmin_fs_convert_category(const QString& category_name, uint16_t* category) -{ // Is the name "Category" followed by a number? Use that number. if (category_name.startsWith(u"Category ", Qt::CaseInsensitive)) { bool ok; int i = category_name.mid(9).toInt(&ok); if (ok && (i >= 1) && (i <= 16)) { - *category = (1 << --i); - return true; + category = (1 << --i); + return category; } } if (global_opts.inifile != nullptr) { // Do we have a gpsbabel.ini that maps category names to category #'s? for (int i = 0; i < 16; i++) { QString key = QString::number(i + 1); - QString c = inifile_readstr(global_opts.inifile, GMSD_SECTION_CATEGORIES, key); + QString c = inifile_readstr(global_opts.inifile, kGmsdSectionCategories, key); if (c.compare(category_name, Qt::CaseInsensitive) == 0) { - *category = (1 << i); - return true; + category = (1 << i); + return category; } } } - return false; + return category; } -bool -garmin_fs_merge_category(const QString& category_name, Waypoint* waypt) +QStringList +garmin_fs_t::print_categories(uint16_t categories) { - uint16_t cat; + QStringList categoryList; - // Attempt to get a textual category name to a category number. - if (!garmin_fs_convert_category(category_name, &cat)) { - return false; + if (categories == 0) { + return categoryList; } - garmin_fs_t* gmsd = garmin_fs_t::find(waypt); - cat = cat | (garmin_fs_t::get_category(gmsd, 0)); + for (int i = 0; i < 16; i++) { + if ((categories & 1) != 0) { + QString c; + if (global_opts.inifile != nullptr) { + QString key = QString::number(i + 1); + c = inifile_readstr(global_opts.inifile, kGmsdSectionCategories, key); + } - if (gmsd == nullptr) { - gmsd = garmin_fs_alloc(-1); - waypt->fs.FsChainAdd(gmsd); + if (c.isNull()) { + categoryList << QString::asprintf("Category %d", i+1); + } +// *fout << QString::asprintf("%s", gps_categories[i]); + else { + categoryList << c; + } + + } + categories = categories >> 1; } - garmin_fs_t::set_category(gmsd, cat); - return true; + return categoryList; } diff --git a/garmin_fs.h b/garmin_fs.h index 0535d85ac..ac74e8957 100644 --- a/garmin_fs.h +++ b/garmin_fs.h @@ -25,7 +25,9 @@ #define GARMIN_FS_H #include // for int32_t, int16_t, uint16_t +#include // for optional +#include // for QList #include // for QString #include "defs.h" @@ -41,9 +43,9 @@ */ struct garmin_ilink_t { - int ref_count; - double lat, lon, alt; - garmin_ilink_t* next; + double lat; + double lon; + double alt; }; struct garmin_fs_flags_t { @@ -95,6 +97,8 @@ struct garmin_fs_flags_t { class garmin_fs_t : public FormatSpecificData { public: + /* Data Members */ + garmin_fs_flags_t flags; int protocol{0}; /* ... used by device (-1 is MapSource) */ @@ -117,26 +121,30 @@ class garmin_fs_t : public FormatSpecificData { QString email; /* email address */ unsigned int duration; /* expected travel time to next route point, in seconds, only when auto-routed */ - garmin_ilink_t* ilinks{nullptr}; + QList ilinks; #ifdef GMSD_EXPERIMENTAL char subclass[22]{}; #endif -public: + /* Special Member Functions */ + garmin_fs_t() : FormatSpecificData(kFsGmsd) {} -private: - garmin_fs_t(const garmin_fs_t& other) = default; -public: - garmin_fs_t& operator=(const garmin_fs_t& rhs) = delete; /* not implemented */ - garmin_fs_t(garmin_fs_t&&) = delete; /* not implemented */ - garmin_fs_t& operator=(garmin_fs_t&&) = delete; /* not implemented */ - ~garmin_fs_t() override; + explicit garmin_fs_t(int p) : garmin_fs_t() {protocol = p;} + + /* Member Functions */ + + garmin_fs_t* clone() const override + { + return new garmin_fs_t(*this); + } - garmin_fs_t* clone() const override; static garmin_fs_t* find(const Waypoint* wpt) { return reinterpret_cast(wpt->fs.FsChainFind(kFsGmsd)); } + static std::optional convert_category(const QString& category_name); + static QStringList print_categories(uint16_t categories); + #define GEN_GMSD_METHODS(field) \ static bool has_##field(const garmin_fs_t* gmsd) \ { \ @@ -212,18 +220,10 @@ class garmin_fs_t : public FormatSpecificData { GEN_GMSD_STR_METHODS(email) #undef GEN_GMSD_STR_METHODS -}; - -garmin_fs_t* garmin_fs_alloc(int protocol); -void garmin_fs_destroy(void* fs); -void garmin_fs_copy(void** dest, const void* src); - -/* ..convert_category: returns true=OK; false=Unable to convert category */ -bool garmin_fs_convert_category(const QString& category_name, uint16_t* category); -/* ..merge_category: returns true=OK; false=Unable to convert category */ -bool garmin_fs_merge_category(const QString& category_name, Waypoint* waypt); - -#define GMSD_SECTION_CATEGORIES "Garmin Categories" +private: + /* Constants */ + static constexpr char kGmsdSectionCategories[] = "Garmin Categories"; +}; #endif diff --git a/garmin_gpi.cc b/garmin_gpi.cc index 340c823be..3f9a824fb 100644 --- a/garmin_gpi.cc +++ b/garmin_gpi.cc @@ -41,7 +41,7 @@ #include "defs.h" #include "formspec.h" // for FormatSpecificDataList -#include "garmin_fs.h" // for garmin_fs_t, garmin_fs_alloc +#include "garmin_fs.h" // for garmin_fs_t #include "gbfile.h" // for gbfputint32, gbfgetint32, gbfgetint16, gbfputint16, gbfgetc, gbfputc, gbfread, gbftell, gbfwrite, gbfseek, gbfclose, gbfopen_le, gbfgetuint16, gbsize_t, gbfile #include "jeeps/gpsmath.h" // for GPS_Math_Deg_To_Semi, GPS_Math_Semi_To_Deg @@ -76,7 +76,7 @@ GarminGPIFormat::gpi_gmsd_init(Waypoint* wpt) } garmin_fs_t* gmsd = garmin_fs_t::find(wpt); if (gmsd == nullptr) { - gmsd = garmin_fs_alloc(-1); + gmsd = new garmin_fs_t(-1); wpt->fs.FsChainAdd(gmsd); } return gmsd; @@ -700,7 +700,7 @@ GarminGPIFormat::wdata_compute_size(writer_data_t* data) const res = 23; /* bounds, ... of tag 0x80008 */ foreach (Waypoint* wpt, data->waypt_list) { - garmin_fs_t* gmsd; + const garmin_fs_t* gmsd; res += 12; /* tag/sz/sub-sz */ res += 19; /* poi fixed size */ diff --git a/garmin_txt.cc b/garmin_txt.cc index c49569445..8a6a1433f 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -33,6 +33,7 @@ #include // for abs #include // for strstr, strlen #include // for time_t, gmtime, localtime, strftime +#include // for optional #include // for pair, make_pair #include // for QByteArray @@ -49,9 +50,8 @@ #include "csv_util.h" // for csv_linesplit #include "formspec.h" // for FormatSpecificDataList -#include "garmin_fs.h" // for garmin_fs_t, garmin_fs_alloc, garmin_fs_convert_category, GMSD_SECTION_CATEGORIES +#include "garmin_fs.h" // for garmin_fs_t #include "garmin_tables.h" // for gt_display_modes_e, gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, gt_get_mps_grid_longname, gt_lookup_datum_index, gt_lookup_grid_type, GDB, gt_get_icao_cc, gt_get_icao_country, gt_get_mps_datum_name, gt_waypt_class_names, GT_DISPLAY_MODE... -#include "inifile.h" // for inifile_readstr #include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS84_To_UKOSMap_M #include "src/core/datetime.h" // for DateTime #include "src/core/logging.h" // for Fatal @@ -221,7 +221,7 @@ convert_datum(const Waypoint* wpt, double* dest_lat, double* dest_lon) static void enum_waypt_cb(const Waypoint* wpt) { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); int wpt_class = garmin_fs_t::get_wpt_class(gmsd, 0); if (wpt_class < 0x80) { if (gtxt_flags.enum_waypoints) { /* enumerate only */ @@ -393,30 +393,9 @@ print_date_and_time(const time_t time, const bool time_only) static void print_categories(uint16_t categories) { - if (categories == 0) { - return; - } - - int count = 0; - for (int i = 0; i < 16; i++) { - if ((categories & 1) != 0) { - QString c; - if (global_opts.inifile != nullptr) { - QString key = QString::number(i + 1); - c = inifile_readstr(global_opts.inifile, GMSD_SECTION_CATEGORIES, key); - } - - *fout << QString::asprintf("%s", (count++ > 0) ? "," : ""); - if (c.isNull()) { - *fout << QString::asprintf("Category %d", i+1); - } -// *fout << QString::asprintf("%s", gps_categories[i]); - else { - *fout << c; - } - - } - categories = categories >> 1; + const QStringList categoryList = garmin_fs_t::print_categories(categories); + if (!categoryList.isEmpty()) { + *fout << categoryList.join(','); } } @@ -528,7 +507,7 @@ write_waypt(const Waypoint* wpt) { const char* wpt_type; - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); int i = garmin_fs_t::get_display(gmsd, 0); if (i > GT_DISPLAY_MODE_MAX) { @@ -740,6 +719,28 @@ track_disp_wpt_cb(const Waypoint* wpt) * %%% global callbacks called by gpsbabel main process %%% * *******************************************************************************/ +static void +garmin_txt_utc_option() +{ + if (opt_utc != nullptr) { + if (case_ignore_strcmp(opt_utc, "utc") == 0) { + utc_offs = 0; + } else { + utc_offs = xstrtoi(opt_utc, nullptr, 10); + } + utc_offs *= (60 * 60); + gtxt_flags.utc = 1; + } +} + +static void +garmin_txt_adjust_time(QDateTime& dt) +{ + if (gtxt_flags.utc) { + dt = dt.toUTC().addSecs(dt.offsetFromUtc() - utc_offs); + } +} + static void garmin_txt_wr_init(const QString& fname) { @@ -786,15 +787,7 @@ garmin_txt_wr_init(const QString& fname) datum_index = gt_lookup_datum_index(datum_str, MYNAME); } - if (opt_utc != nullptr) { - if (case_ignore_strcmp(opt_utc, "utc") == 0) { - utc_offs = 0; - } else { - utc_offs = xstrtoi(opt_utc, nullptr, 10); - } - utc_offs *= (60 * 60); - gtxt_flags.utc = 1; - } + garmin_txt_utc_option(); } static void @@ -902,7 +895,7 @@ strftime_to_timespec(const char* s) q += "yyyy"; continue; case 'H': - q += "hh"; + q += "HH"; continue; case 'M': q += "mm"; @@ -931,8 +924,11 @@ strftime_to_timespec(const char* s) case 'F': q += "yyyy-MM-dd"; continue; + case 'p': + q += "AP"; + continue; default: - q += s[i+1]; + warning(MYNAME ": omitting unknown strptime conversion \"%%%c\" in \"%s\"\n", s[i], s); break; } } @@ -964,11 +960,10 @@ parse_categories(const QString& str) for (const auto& catstring : catstrings) { QString cin = catstring.trimmed(); if (!cin.isEmpty()) { - uint16_t val; - if (!garmin_fs_convert_category(cin, &val)) { + if (std::optional cat = garmin_fs_t::convert_category(cin); !cat.has_value()) { warning(MYNAME ": Unable to convert category \"%s\" at line %d!\n", qPrintable(cin), current_line); } else { - res = res | val; + res = res | *cat; } } } @@ -1102,7 +1097,7 @@ parse_waypoint(const QStringList& lineparts) bind_fields(waypt_header); auto* wpt = new Waypoint; - garmin_fs_t* gmsd = garmin_fs_alloc(-1); + auto* gmsd = new garmin_fs_t(-1); wpt->fs.FsChainAdd(gmsd); for (const auto& str : lineparts) { @@ -1184,6 +1179,7 @@ parse_waypoint(const QStringList& lineparts) break; case 16: if (QDateTime dt = parse_date_and_time(str); dt.isValid()) { + garmin_txt_adjust_time(dt); wpt->SetCreationTime(dt); } break; @@ -1319,6 +1315,7 @@ parse_track_waypoint(const QStringList& lineparts) break; case 2: if (QDateTime dt = parse_date_and_time(str); dt.isValid()) { + garmin_txt_adjust_time(dt); wpt->SetCreationTime(dt); } break; @@ -1367,6 +1364,7 @@ garmin_txt_rd_init(const QString& fname) grid_index = (grid_type) -1; init_date_and_time_format(); + garmin_txt_utc_option(); } static void diff --git a/gdb.cc b/gdb.cc index 5efbb55f3..db3bec6a5 100644 --- a/gdb.cc +++ b/gdb.cc @@ -42,7 +42,7 @@ #include "defs.h" // for Waypoint, warning, route_head, fatal, UrlLink, bounds, UrlList, unknown_alt, xfree, waypt_add_to_bounds, waypt_init_bounds, xstrtoi, route_add_wpt, route_disp_all, waypt_bounds_valid, xmalloc, gb_color, WaypointList, find_wa... #include "formspec.h" // for FormatSpecificDataList -#include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t, garmin_fs_alloc +#include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t #include "garmin_tables.h" // for gt_waypt_class_map_point, gt_color_index_by_rgb, gt_color_value, gt_waypt_classes_e, gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, gt_gdb_display_mode_symbol, gt_get_icao_country, gt_waypt_class_user_waypoint, GDB, gt_display_mode_symbol #include "gbfile.h" // for gbfgetint32, gbfputint32, gbfgetc, gbfread, gbfwrite, gbfgetdbl, gbfputc, gbfgetcstr, gbfclose, gbfgetnativecstr, gbfopen_le, gbfputint16, gbfile, gbfcopyfrom, gbfputcstr, gbfrewind, gbfseek, gbftell, gbfgetcstr_old, gbfgetint16, gbfgetuint32, gbfputdbl #include "grtcirc.h" // for RAD, gcdist, radtometers @@ -440,7 +440,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out) waypt_ct++; res = new Waypoint; - gmsd = garmin_fs_alloc(-1); + gmsd = new garmin_fs_t(-1); res->fs.FsChainAdd(gmsd); res->shortname = fread_cstr(); wpt_class = (gt_waypt_classes_e) FREAD_i32; @@ -738,46 +738,37 @@ GdbFormat::read_route() } int links = FREAD_i32; - garmin_ilink_t* il_anchor = nullptr; - garmin_ilink_t* il_root = nullptr; + QList il_list; #if GDB_DEBUG DBG(GDB_DBG_RTE, links) printf(MYNAME "-rte_pt \"%s\" (%d): %d interlink step(s)\n", qPrintable(wpt->shortname), wpt_class, links); #endif for (int j = 0; j < links; j++) { - auto* il_step = (garmin_ilink_t*) xmalloc(sizeof(garmin_ilink_t)); + garmin_ilink_t il_step; - il_step->ref_count = 1; - - il_step->lat = FREAD_LATLON; - il_step->lon = FREAD_LATLON; + il_step.lat = FREAD_LATLON; + il_step.lon = FREAD_LATLON; if (FREAD_C == 1) { - il_step->alt = FREAD_DBL; + il_step.alt = FREAD_DBL; } else { - il_step->alt = unknown_alt; + il_step.alt = unknown_alt; } if (j == 0) { - wpt->latitude = il_step->lat; - wpt->longitude = il_step->lon; - wpt->altitude = il_step->alt; + wpt->latitude = il_step.lat; + wpt->longitude = il_step.lon; + wpt->altitude = il_step.alt; } - il_step->next = nullptr; - if (il_anchor == nullptr) { - il_root = il_step; - } else { - il_anchor->next = il_step; - } - il_anchor = il_step; + il_list.append(il_step); #if GDB_DEBUG DBG(GDB_DBG_RTEe, true) { printf(MYNAME "-rte_il \"%s\" (%d of %d): %c%0.6f %c%0.6f\n", qPrintable(wpt->shortname), j + 1, links, - il_step->lat < 0 ? 'S' : 'N', il_step->lat, - il_step->lon < 0 ? 'W' : 'E', il_step->lon); + il_step.lat < 0 ? 'S' : 'N', il_step.lat, + il_step.lon < 0 ? 'W' : 'E', il_step.lon); } #endif } @@ -832,19 +823,13 @@ GdbFormat::read_route() if (wpt != nullptr) { garmin_fs_t* gmsd = garmin_fs_t::find(wpt); if (gmsd == nullptr) { - gmsd = garmin_fs_alloc(-1); + gmsd = new garmin_fs_t(-1); wpt->fs.FsChainAdd(gmsd); } garmin_fs_t::set_wpt_class(gmsd, wpt_class); - gmsd->ilinks = il_root; - il_root = nullptr; + gmsd->ilinks = il_list; } - while (il_root) { - garmin_ilink_t* il = il_root; - il_root = il_root->next; - xfree(il); - } } /* ENDFOR: for (i = 0; i < points; i++) */ /* VERSION DEPENDENT CODE */ @@ -1194,7 +1179,7 @@ GdbFormat::gdb_check_waypt(Waypoint* wpt) void GdbFormat::write_waypoint( - const Waypoint* wpt, const QString& shortname, garmin_fs_t* gmsd, + const Waypoint* wpt, const QString& shortname, const garmin_fs_t* gmsd, const int icon, const int display) { char zbuf[32], ffbuf[32]; @@ -1391,7 +1376,7 @@ GdbFormat::write_route(const route_head* rte, const QString& rte_name) fatal(MYNAME ": Sorry, that should never happen!!!\n"); } - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); /* extra_data may contain a modified shortname */ gdb_write_cstr((wpt->extra_data) ? *static_cast(wpt->extra_data) : wpt->shortname); @@ -1564,7 +1549,7 @@ GdbFormat::write_waypoint_cb(const Waypoint* refpt) fout = ftmp; /* prepare the waypoint */ - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); int wpt_class = garmin_fs_t::get_wpt_class(gmsd, -1); if (wpt_class == -1) { diff --git a/gdb.h b/gdb.h index 6697ca592..fc3497401 100644 --- a/gdb.h +++ b/gdb.h @@ -150,7 +150,7 @@ class GdbFormat : public Format void reset_short_handle(const char* defname); void write_header(); static void gdb_check_waypt(Waypoint* wpt); - void write_waypoint(const Waypoint* wpt, const QString& shortname, garmin_fs_t* gmsd, int icon, int display); + void write_waypoint(const Waypoint* wpt, const QString& shortname, const garmin_fs_t* gmsd, int icon, int display); static void route_compute_bounds(const route_head* rte, bounds* bounds); void route_write_bounds(bounds* bounds) const; void write_route(const route_head* rte, const QString& rte_name); diff --git a/gpx.cc b/gpx.cc index de176e454..176ecc676 100644 --- a/gpx.cc +++ b/gpx.cc @@ -47,7 +47,7 @@ #include // for qAsConst, QAddConst<>::Type #include "defs.h" -#include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t, garmin_fs_alloc, garmin_fs_merge_category +#include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t #include "garmin_tables.h" // for gt_color_index_by_rgb, gt_color_name, gt_color_value_by_name #include "geocache.h" // for Geocache, Geocache::UtfSt... #include "mkshort.h" // for MakeShort @@ -218,7 +218,7 @@ GpxFormat::tag_garmin_fs(tag_type tag, const QString& text, Waypoint* waypt) { garmin_fs_t* gmsd = garmin_fs_t::find(waypt); if (gmsd == nullptr) { - gmsd = garmin_fs_alloc(-1); + gmsd = new garmin_fs_t(-1); waypt->fs.FsChainAdd(gmsd); } @@ -243,7 +243,10 @@ GpxFormat::tag_garmin_fs(tag_type tag, const QString& text, Waypoint* waypt) } break; case tag_type::garmin_wpt_category: - if (!garmin_fs_merge_category(text, waypt)) { + if (auto cat = garmin_fs_t::convert_category(text); cat.has_value()) { + cat = *cat | (garmin_fs_t::get_category(gmsd, 0)); + garmin_fs_t::set_category(gmsd, *cat); + } else { // There's nothing a user can really do about this (well, they could // create a gpsbabel.ini that mapped them to garmin category numbers // but that feature is so obscure and used in so few outputs that @@ -1346,7 +1349,7 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin // Although not required by the schema we assume that gpxx:RoutePointExtension must be a child of gpx:rtept. // Although not required by the schema we assume that gpxx:TrackPointExtension must be a child of gpx:trkpt. // Although not required by the schema we assume that gpxtpx:TrackPointExtension must be a child of gpx:trkpt. - garmin_fs_t* gmsd = garmin_fs_t::find(waypointp); + const garmin_fs_t* gmsd = garmin_fs_t::find(waypointp); switch (point_type) { case gpxpt_waypoint: writer->stackOptionalStartElement(QStringLiteral("gpxx:WaypointExtension")); @@ -1379,11 +1382,9 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin if (garmin_fs_t::has_category(gmsd)) { uint16_t cx = gmsd->category; writer->stackStartElement(QStringLiteral("gpxx:Categories")); - for (int i = 0; i < 16; i++) { - if (cx & 1) { - writer->stackTextElement(QStringLiteral("gpxx:Category"), QStringLiteral("Category %1").arg(i+1)); - } - cx = cx >> 1; + const QStringList categoryList = garmin_fs_t::print_categories(cx); + for (const auto& text : categoryList) { + writer->stackTextElement(QStringLiteral("gpxx:Category"), text); } writer->stackEndElement(); // gpxx:Categories } @@ -1401,19 +1402,21 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin writer->stackEndElement(); // gpxx:WaypointExtension break; case gpxpt_route: - if (gmsd != nullptr && gmsd->ilinks != nullptr) { + if (gmsd != nullptr && !gmsd->ilinks.isEmpty()) { writer->stackOptionalStartElement(QStringLiteral("gpxx:RoutePointExtension")); - garmin_ilink_t* link = gmsd->ilinks; - garmin_ilink_t* prior = nullptr; // GDB files sometime contain repeated point; omit them - while (link != nullptr) { - if (prior == nullptr || prior->lat != link->lat || prior->lon != link->lon) { + double prior_lat; // GDB files sometime contain repeated point; omit them + double prior_lon; + bool first = true; + for (const auto& link : gmsd->ilinks) { + if (first || (prior_lat != link.lat) || (prior_lon != link.lon)) { writer->stackStartElement(QStringLiteral("gpxx:rpt")); - writer->stackAttribute(QStringLiteral("lat"), toString(link->lat)); - writer->stackAttribute(QStringLiteral("lon"), toString(link->lon)); + writer->stackAttribute(QStringLiteral("lat"), toString(link.lat)); + writer->stackAttribute(QStringLiteral("lon"), toString(link.lon)); writer->stackEndElement(); // "gpxx:rpt" + prior_lat = link.lat; + prior_lon = link.lon; + first = false; } - prior = link; - link = link->next; } writer->stackEndElement(); // gpxx:RoutePointExtension } diff --git a/random.cc b/random.cc index 7026a9e53..339c04602 100644 --- a/random.cc +++ b/random.cc @@ -28,7 +28,7 @@ #include "defs.h" #include "random.h" #include "formspec.h" // for FormatSpecificDataList -#include "garmin_fs.h" // for garmin_fs_t, GMSD_SET, garmin_fs_flags_t, garmin_fs_alloc +#include "garmin_fs.h" // for garmin_fs_t, GMSD_SET, garmin_fs_flags_t #include "src/core/datetime.h" // for DateTime @@ -104,7 +104,7 @@ Waypoint* RandomFormat::random_generate_wpt(int i, const QDateTime& time, const Waypoint* prev) { auto* wpt = new Waypoint; - garmin_fs_t* gmsd = garmin_fs_alloc(-1); + auto* gmsd = new garmin_fs_t(-1); wpt->fs.FsChainAdd(gmsd); do { diff --git a/reference/garmincategories.gpx b/reference/garmincategories.gpx new file mode 100644 index 000000000..95b140d19 --- /dev/null +++ b/reference/garmincategories.gpx @@ -0,0 +1,35 @@ + + + + + + + + + Hwy 119 + The Diagonal + The Diagonal + Flag, Blue + + + SymbolAndName + + Slow food + Category 11 + + + + + + + Hwy 72 + The Peak to Peak + The Peak to Peak + Flag, Blue + + + SymbolAndName + + + + diff --git a/reference/garmincategories.txt b/reference/garmincategories.txt new file mode 100644 index 000000000..b7ec5292c --- /dev/null +++ b/reference/garmincategories.txt @@ -0,0 +1,7 @@ +Grid Lat/Lon hdddmm.mmm' +Datum WGS 84 + +Header Name Description Type Position Altitude Depth Proximity Temperature Display Mode Color Symbol Facility City State Country Date Modified Link Categories + +Waypoint Hwy 119 The Diagonal User Waypoint N39 58.432183 W105 27.951022 Symbol & Name Unknown Flag, Blue 09.03.2013 13:45:12 PM Slow food,Category 11 +Waypoint Hwy 72 The Peak to Peak User Waypoint N40 00.238037 W105 29.937744 Symbol & Name Unknown Flag, Blue 09.03.2013 13:45:02 PM diff --git a/testo.d/gpx.test b/testo.d/gpx.test index 85581adf4..f917b2a2e 100644 --- a/testo.d/gpx.test +++ b/testo.d/gpx.test @@ -79,6 +79,13 @@ compare ${REFERENCE}/gpxpassthrough10~gpx.gpx ${TMPDIR}/gpxpassthrough10~gpx.gpx gpsbabel -i gpx -f ${REFERENCE}/gpxpassthrough11.gpx -o gpx -F ${TMPDIR}/gpxpassthrough11~gpx.gpx compare ${REFERENCE}/gpxpassthrough11~gpx.gpx ${TMPDIR}/gpxpassthrough11~gpx.gpx +# garmin specific categories +gpsbabel -p gpsbabel-sample.ini -i gpx -f ${REFERENCE}/garmincategories.gpx -o garmin_txt,utc=-7 -F ${TMPDIR}/garmincategories~gpx.txt +compare ${REFERENCE}/garmincategories.txt ${TMPDIR}/garmincategories~gpx.txt + +gpsbabel -p gpsbabel-sample.ini -i garmin_txt,utc=-7 -f ${REFERENCE}/garmincategories.txt -o gpx,garminextensions -F ${TMPDIR}/garmincategories~txt.gpx +compare ${REFERENCE}/garmincategories.gpx ${TMPDIR}/garmincategories~txt.gpx + if [ -z "${VALGRIND}" ]; then set -e if command -v xmllint > /dev/null; diff --git a/unicsv.cc b/unicsv.cc index 92ca85043..679c19ad4 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -42,7 +42,7 @@ #include "defs.h" #include "csv_util.h" // for csv_linesplit, human_to_dec #include "formspec.h" // for FormatSpecificDataList -#include "garmin_fs.h" // for garmin_fs_flags_t, garmin_fs_t, GMSD_GET, GMSD_HAS, GMSD_SETQSTR, GMSD_FIND, garmin_fs_alloc +#include "garmin_fs.h" // for garmin_fs_t #include "garmin_tables.h" // for gt_lookup_datum_index, gt_get_mps_grid_longname, gt_lookup_grid_type #include "geocache.h" // for Geocache, Geocache::status_t, Geoc... #include "jeeps/gpsmath.h" // for GPS_Math_UKOSMap_To_WGS84_M, GPS_Math_EN_To_UKOSNG_Map, GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_Swiss_EN_To_WGS84, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS... @@ -823,7 +823,7 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) case fld_garmin_facility: gmsd = garmin_fs_t::find(wpt); if (! gmsd) { - gmsd = garmin_fs_alloc(-1); + gmsd = new garmin_fs_t(-1); wpt->fs.FsChainAdd(gmsd); } switch (unicsv_fields_tab[column]) { @@ -1113,7 +1113,7 @@ void UnicsvFormat::unicsv_waypt_enum_cb(const Waypoint* wpt) { const QString& shortname = wpt->shortname; - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); if (!shortname.isEmpty()) { unicsv_outp_flags[fld_shortname] = true; @@ -1264,7 +1264,7 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) unicsv_waypt_ct++; QString shortname = wpt->shortname; - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); if (unicsv_datum_idx == kDautmWGS84) { lat = wpt->latitude; diff --git a/util.cc b/util.cc index e1723f533..c625e95d4 100644 --- a/util.cc +++ b/util.cc @@ -623,7 +623,7 @@ convert_human_date_format(const char* human_datef) } if (okay == 0) { - fatal("Invalid character \"%c\" in date format!", *cin); + fatal("Invalid character \"%c\" in date format \"%s\"!\n", *cin, human_datef); } } QString rv(result); @@ -717,7 +717,7 @@ convert_human_time_format(const char* human_timef) } if (okay == 0) { - fatal("Invalid character \"%c\" in time format!", *cin); + fatal("Invalid character \"%c\" in time format \"%s\"!\n", *cin, human_timef); } } QString rv(result); diff --git a/waypt.cc b/waypt.cc index 8130add75..77a219faa 100644 --- a/waypt.cc +++ b/waypt.cc @@ -230,22 +230,20 @@ double waypt_distance_ex(const Waypoint* A, const Waypoint* B) { double res = 0; - garmin_fs_t* gmsd; if ((A == nullptr) || (B == nullptr)) { return 0; } - if ((gmsd = garmin_fs_t::find(A)) && (gmsd->ilinks != nullptr)) { - garmin_ilink_t* link = gmsd->ilinks; - - res = gcgeodist(A->latitude, A->longitude, link->lat, link->lon); - while (link->next != nullptr) { - garmin_ilink_t* prev = link; - link = link->next; - res += gcgeodist(prev->lat, prev->lon, link->lat, link->lon); + if (const garmin_fs_t* gmsd = garmin_fs_t::find(A); (gmsd != nullptr) && (!gmsd->ilinks.isEmpty())) { + auto prev_lat = A->latitude; + auto prev_lon = A->longitude; + for (const auto& link : gmsd->ilinks) { + res += gcgeodist(prev_lat, prev_lon, link.lat, link.lon); + prev_lat = link.lat; + prev_lon = link.lon; } - res += gcgeodist(link->lat, link->lon, B->latitude, B->longitude); + res += gcgeodist(gmsd->ilinks.last().lat, gmsd->ilinks.last().lon, B->latitude, B->longitude); } else { res = gcgeodist(A->latitude, A->longitude, B->latitude, B->longitude); } diff --git a/xcsv.cc b/xcsv.cc index d2c57e549..d649fff55 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -51,7 +51,7 @@ #include "defs.h" #include "csv_util.h" // for csv_stringtrim, dec_to_human, csv_stringclean, human_to_dec, ddmmdir_to_degrees, dec_to_intdeg, decdir_to_dec, intdeg_to_dec, csv_linesplit #include "formspec.h" // for FormatSpecificDataList -#include "garmin_fs.h" // for garmin_fs_t, garmin_fs_alloc +#include "garmin_fs.h" // for garmin_fs_t #include "geocache.h" // for Geocache, Geocache::status_t, Geoc... #include "grtcirc.h" // for RAD, gcdist, radtometers #include "jeeps/gpsmath.h" // for GPS_Math_WGS84_To_UTM_EN, GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_UKOSMap_M @@ -361,7 +361,7 @@ XcsvFormat::gmsd_init(Waypoint* wpt) { garmin_fs_t* gmsd = garmin_fs_t::find(wpt); if (gmsd == nullptr) { - gmsd = garmin_fs_alloc(-1); + gmsd = new garmin_fs_t(-1); wpt->fs.FsChainAdd(gmsd); } return gmsd; @@ -1534,42 +1534,42 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) break; /* GMSD ************************************************************/ case XcsvStyle::XT_COUNTRY: { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_country(gmsd, ""))); } break; case XcsvStyle::XT_STATE: { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_state(gmsd, ""))); } break; case XcsvStyle::XT_CITY: { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_city(gmsd, ""))); } break; case XcsvStyle::XT_POSTAL_CODE: { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_postal_code(gmsd, ""))); } break; case XcsvStyle::XT_STREET_ADDR: { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_addr(gmsd, ""))); } break; case XcsvStyle::XT_PHONE_NR: { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_phone_nr(gmsd, ""))); } break; case XcsvStyle::XT_FACILITY: { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_facility(gmsd, ""))); } break; case XcsvStyle::XT_EMAIL: { - garmin_fs_t* gmsd = garmin_fs_t::find(wpt); + const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_email(gmsd, ""))); } break; From 4c934544696c56523bcb7e55b30607efa23c21a3 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:43:17 -0700 Subject: [PATCH 031/132] convert vcf to dynamic Format. (#1210) --- CMakeLists.txt | 1 + vcf.cc | 63 +++++++++++++--------------------------- vcf.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ vecs.cc | 8 ++--- 4 files changed, 104 insertions(+), 47 deletions(-) create mode 100644 vcf.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 315137eef..fcbb1dc20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,6 +238,7 @@ set(HEADERS text.h unicsv.h units.h + vcf.h vecs.h xcsv.h xmlgeneric.h diff --git a/vcf.cc b/vcf.cc index fd3e90844..4775e753f 100644 --- a/vcf.cc +++ b/vcf.cc @@ -18,40 +18,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "vcf.h" + #include // for fabs #include // for abs #include // for QString -#include // for QVector #include // for CaseInsensitive #include "defs.h" -#include "gbfile.h" // for gbfprintf, gbfputs, gbfclose, gbfopen, gbfile +#include "gbfile.h" // for gbfprintf, gbfputs, gbfclose, gbfopen #include "geocache.h" // for Geocache, Geocache::UtfString -static gbfile* file_out; - -static char* vcf_encrypt = nullptr; - #define MYNAME "VCF" -static -QVector vcf_args = { - { - "encrypt", &vcf_encrypt, - "Encrypt hints using ROT13", nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, -}; -static void -wr_init(const QString& fname) +void +VcfFormat::wr_init(const QString& fname) { file_out = gbfopen(fname, "w", MYNAME); } -static void -wr_deinit() +void +VcfFormat::wr_deinit() { gbfclose(file_out); } @@ -60,8 +50,8 @@ wr_deinit() * Print a possibly empty input string, replacing newlines with escaped * newlines as we go. */ -static void -vcf_print_utf(const Geocache::UtfString* s) +void +VcfFormat::vcf_print_utf(const Geocache::UtfString* s) { if (nullptr == s) { return; @@ -77,8 +67,8 @@ vcf_print_utf(const Geocache::UtfString* s) gbfputs(stripped_html, file_out); } -static void -vcf_print(const char* s) +void +VcfFormat::vcf_print(const char* s) { if (!s) { return; @@ -90,14 +80,14 @@ vcf_print(const char* s) gbfputs(cleaned, file_out); } -static void -vcf_print(const QString& s) +void +VcfFormat::vcf_print(const QString& s) { vcf_print(CSTR(s)); } -static void -vcf_disp(const Waypoint* wpt) +void +VcfFormat::vcf_disp(const Waypoint* wpt) { int lonint = abs((int) wpt->longitude); int latint = abs((int) wpt->latitude); @@ -126,23 +116,10 @@ vcf_disp(const Waypoint* wpt) gbfprintf(file_out, "\nEND:VCARD\n"); } -static void -data_write() +void VcfFormat::write() { - waypt_disp_all(vcf_disp); + auto vcf_disp_lambda = [this](const Waypoint* waypointp)->void { + vcf_disp(waypointp); + }; + waypt_disp_all(vcf_disp_lambda); } - - -ff_vecs_t vcf_vecs = { - ff_type_file, - { ff_cap_write, ff_cap_none, ff_cap_none}, - nullptr, - wr_init, - nullptr, - wr_deinit, - nullptr, - data_write, - nullptr, - &vcf_args, - NULL_POS_OPS -}; diff --git a/vcf.h b/vcf.h new file mode 100644 index 000000000..7a4a53131 --- /dev/null +++ b/vcf.h @@ -0,0 +1,79 @@ +/* + Output only format for Vcard format, VCF + + Copyright (C) 2005 Robert Lipe, robertlipe+source@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef VCF_H_INCLUDED_ +#define VCF_H_INCLUDED_ + +#include // for QString +#include // for QVector + +#include "defs.h" +#include "format.h" // for Format +#include "gbfile.h" // for gbfile +#include "geocache.h" // for Geocache + + +class VcfFormat : public Format +{ +public: + using Format::Format; + + QVector* get_args() override + { + return &vcf_args; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + return {ff_cap_write, ff_cap_none, ff_cap_none}; + } + + void wr_init(const QString& fname) override; + void write() override; + void wr_deinit() override; + +private: + + /* Member Functions */ + + void vcf_print_utf(const Geocache::UtfString* s); + void vcf_print(const char* s); + void vcf_print(const QString& s); + void vcf_disp(const Waypoint* wpt); + + /* Data Members */ + + gbfile* file_out{}; + + char* vcf_encrypt = nullptr; + + QVector vcf_args = { + { + "encrypt", &vcf_encrypt, + "Encrypt hints using ROT13", nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + }; + +}; +#endif // VCF_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index 10c5fca2f..944e863ab 100644 --- a/vecs.cc +++ b/vecs.cc @@ -68,8 +68,9 @@ #include "subrip.h" // for SubripFormat #include "text.h" // for TextFormat #include "unicsv.h" // for UnicsvFormat +#include "vcf.h" // for VcfFormat #include "xcsv.h" // for XcsvStyle, XcsvFormat -#include "googletakeout.h" // for GoogleTakeoutFormat +#include "googletakeout.h" // for GoogleTakeoutFormat extern ff_vecs_t geo_vecs; @@ -86,7 +87,6 @@ extern ff_vecs_t mtk_m241_vecs; extern ff_vecs_t mtk_m241_fvecs; #endif // MAXIMAL_ENABLED #if MAXIMAL_ENABLED -extern ff_vecs_t vcf_vecs; extern ff_vecs_t gtm_vecs; #if CSVFMTS_ENABLED extern ff_vecs_t garmin_txt_vecs; @@ -136,7 +136,6 @@ struct Vecs::Impl { LegacyFormat mtk_m241_ffmt {mtk_m241_fvecs}; #endif // MAXIMAL_ENABLED #if MAXIMAL_ENABLED - LegacyFormat vcf_fmt {vcf_vecs}; UnicsvFormat unicsv_fmt; LegacyFormat gtm_fmt {gtm_vecs}; #if CSVFMTS_ENABLED @@ -317,11 +316,12 @@ struct Vecs::Impl { #endif // MAXIMAL_ENABLED #if MAXIMAL_ENABLED { - &vcf_fmt, + nullptr, "vcard", "Vcard Output (for iPod)", "vcf", nullptr, + &fmtfactory }, { &unicsv_fmt, From 9500fdfe2b09e3acb81a166f908f8102b925c1fc Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:40:36 -0700 Subject: [PATCH 032/132] add fedora 39 to ci (#1211) * add fedora 39 to ci * retire qAsConst for std::as_const --- .github/workflows/fedora.yml | 4 ++++ bend.cc | 6 ++++-- duplicate.cc | 5 +++-- exif.cc | 8 ++++---- garmin.cc | 3 ++- garmin_txt.cc | 4 ++-- gpx.cc | 6 ++++-- interpolate.cc | 4 ++-- lowranceusr.cc | 9 +++++---- mkshort.cc | 6 +++--- position.cc | 4 ++-- radius.cc | 5 +++-- resample.cc | 5 +++-- route.cc | 3 ++- tools/Dockerfile_f39 | 22 ++++++++++++++++++++++ trackfilter.cc | 15 ++++++++------- unicsv.cc | 3 ++- util.cc | 5 +++-- vecs.cc | 7 ++++--- waypt.cc | 3 ++- xcsv.cc | 12 +++++++----- 21 files changed, 91 insertions(+), 48 deletions(-) create mode 100644 tools/Dockerfile_f39 diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index 76543d9d5..ce8187ab7 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -24,6 +24,10 @@ jobs: CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' - IMAGE: '38' CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6' + - IMAGE: '39' + CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' + - IMAGE: '39' + CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6' container: image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_f${{ matrix.IMAGE }} env: diff --git a/bend.cc b/bend.cc index 1bfb7060e..29cc1d488 100644 --- a/bend.cc +++ b/bend.cc @@ -22,12 +22,14 @@ #include // macos wants abs from here! #include // for strtod, abs +#include // for as_const #include // for QString -#include // for qAsConst, QAddConst<>::Type, foreach +#include // for QForeachContainer, qMakeForeachContainer, foreach #include "defs.h" #include "bend.h" +#include "formspec.h" // for FormatSpecificDataList #include "grtcirc.h" // for RAD, heading_true_degrees, gcdist, linepart, radtometers, DEG @@ -159,7 +161,7 @@ void BendFilter::process_route_orig(const route_head* route_orig) void BendFilter::process() { - for (const auto* route_orig : qAsConst(*routes_orig)) { + for (const auto* route_orig : std::as_const(*routes_orig)) { process_route_orig(route_orig); } } diff --git a/duplicate.cc b/duplicate.cc index 252c068e9..552b23faf 100644 --- a/duplicate.cc +++ b/duplicate.cc @@ -21,9 +21,10 @@ #include "duplicate.h" +#include // for as_const + #include // for QList, QList<>::iterator, QList<>::const_iterator #include // for QMultiHash -#include // for qAsConst #include "defs.h" @@ -42,7 +43,7 @@ void DuplicateFilter::init() void DuplicateFilter::process() { QMultiHash wpthash; - for (Waypoint* waypointp : qAsConst(*global_waypoint_list)) { + for (Waypoint* waypointp : std::as_const(*global_waypoint_list)) { QString key; if (lcopt) { diff --git a/exif.cc b/exif.cc index 2e0ba8289..6521cbb64 100644 --- a/exif.cc +++ b/exif.cc @@ -50,7 +50,7 @@ #include // for QVariant #include // for QVector #include // for UTC, ISODate -#include // for qAsConst, qPrintable, qint64 +#include // for qPrintable, qint64 #include // for sort, min #include // for assert @@ -61,7 +61,7 @@ #include // for printf, SEEK_SET, snprintf, SEEK_CUR #include // for abs #include // for memcmp, strlen -#include // for add_const<>::type +#include // for as_const #include "defs.h" // for Waypoint, fatal, warning, global_options, global_opts, unknown_alt, xfree, route_disp_all, track_disp_all, waypt_disp_all, wp_flags, KNOTS_TO_MPS, KPH_TO_MPS, MPH_TO_MPS, MPS_TO_KPH, WAYPT_HAS, case_ignore_strcmp, waypt_add, xstrdup, xstrndup, fix_2d #include "garmin_tables.h" // for gt_lookup_datum_index @@ -273,7 +273,7 @@ ExifFormat::exif_read_datestamp(const ExifTag* tag) void ExifFormat::exif_release_apps() { - for (auto* app : qAsConst(*exif_apps)) { + for (auto* app : std::as_const(*exif_apps)) { if (app->fcache) { gbfclose(app->fcache); } @@ -1304,7 +1304,7 @@ ExifFormat::exif_write_apps() const { gbfputuint16(0xFFD8, fout_); - for (auto* app : qAsConst(*exif_apps)) { + for (auto* app : std::as_const(*exif_apps)) { gbfputuint16(app->marker, fout_); diff --git a/garmin.cc b/garmin.cc index dd04edc42..f6fd25dd6 100644 --- a/garmin.cc +++ b/garmin.cc @@ -26,6 +26,7 @@ #include // for strtol #include // for memcpy, strlen, strncpy, strchr #include // for time_t +#include // for as_const #include // for QByteArray #include // for QRegularExpression @@ -873,7 +874,7 @@ waypoint_prepare() i = 0; // Iterate with waypt_disp_all? - for (const Waypoint* wpt : qAsConst(*global_waypoint_list)) { + for (const Waypoint* wpt : std::as_const(*global_waypoint_list)) { char obuf[256]; QString src; diff --git a/garmin_txt.cc b/garmin_txt.cc index 8a6a1433f..62efa8d60 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -34,7 +34,7 @@ #include // for strstr, strlen #include // for time_t, gmtime, localtime, strftime #include // for optional -#include // for pair, make_pair +#include // for as_const, pair, make_pair #include // for QByteArray #include // for QChar, QChar::Other_Control @@ -1041,7 +1041,7 @@ bind_fields(const header_type ht) const QStringList altheader = headers.at(ht).toUpper().split('\t'); int i = -1; - for (const auto& name : qAsConst(header_column_names)) { + for (const auto& name : std::as_const(header_column_names)) { i++; int field_idx = altheader.indexOf(name); diff --git a/gpx.cc b/gpx.cc index 176ecc676..f8e0cebc3 100644 --- a/gpx.cc +++ b/gpx.cc @@ -24,7 +24,10 @@ #include // for assert #include // for lround #include // for sscanf +#include // for uint16_t #include // for strchr, strncpy +#include // for optional +#include // for as_const #include // for QByteArray #include // for QDate @@ -44,7 +47,6 @@ #include // for QXmlStreamNamespaceDeclarations #include // for QXmlStreamReader, QXmlStreamReader::Characters, QXmlStreamReader::EndDocument, QXmlStreamReader::EndElement, QXmlStreamReader::Invalid, QXmlStreamReader::StartElement #include // for CaseInsensitive, UTC -#include // for qAsConst, QAddConst<>::Type #include "defs.h" #include "garmin_fs.h" // for garmin_fs_t, garmin_ilink_t @@ -1049,7 +1051,7 @@ GpxFormat::wr_init(const QString& fname) } else { if (gpx_global) { // TODO: gpx 1.1 copyright goes here - for (const auto& l : qAsConst(gpx_global->link)) { + for (const auto& l : std::as_const(gpx_global->link)) { writer->writeStartElement(QStringLiteral("link")); writer->writeAttribute(QStringLiteral("href"), l.url_); writer->writeOptionalTextElement(QStringLiteral("text"), l.url_link_text_); diff --git a/interpolate.cc b/interpolate.cc index 0148c52fc..f1367c1f2 100644 --- a/interpolate.cc +++ b/interpolate.cc @@ -22,12 +22,12 @@ #include "interpolate.h" #include // for INT_MAX -#include // for abs, ceil, isfinite, round +#include // for ceil, isfinite #include // for abs, strtod #include // for optional #include // for QString -#include // for qint64, qAsConst, qRound64 +#include // for qint64, qRound64 #include "defs.h" #include "grtcirc.h" // for linepart, RAD, gcdist, radtomiles diff --git a/lowranceusr.cc b/lowranceusr.cc index cbfd1f05c..6a06e1322 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -93,6 +93,7 @@ #include // for int64_t #include // for abs #include // for strcmp, strlen +#include // for as_const #include // for QByteArray #include // for QDate @@ -104,7 +105,7 @@ #include // for QTextEncoder #include // for QTime #include // for CaseInsensitive, UTC -#include // for qPrintable, uint, qAsConst, QAddConst<>::Type +#include // for qPrintable, uint, QAddConst<>::Type #include "defs.h" #include "formspec.h" // for FsChainFind, FsChainAdd, kFsLowranceusr4, FormatSpecificData @@ -134,7 +135,7 @@ LowranceusrFormat::same_points(const Waypoint* A, const Waypoint* B) void LowranceusrFormat::register_waypt(const Waypoint* wpt) const { - for (const Waypoint* cmp : qAsConst(*waypt_table)) { + for (const Waypoint* cmp : std::as_const(*waypt_table)) { if (same_points(wpt, cmp)) { return; } @@ -154,7 +155,7 @@ const Waypoint* LowranceusrFormat::lowranceusr4_find_waypt(uint uid_unit, int uid_seq_low, int uid_seq_high) { // Iterate with waypt_disp_all? - for (const Waypoint* waypointp : qAsConst(*global_waypoint_list)) { + for (const Waypoint* waypointp : std::as_const(*global_waypoint_list)) { const auto* fs = reinterpret_cast(waypointp->fs.FsChainFind(kFsLowranceusr4)); if (fs && fs->uid_unit == uid_unit && @@ -175,7 +176,7 @@ const Waypoint* LowranceusrFormat::lowranceusr4_find_global_waypt(uint id1, uint id2, uint id3, uint id4) { // Iterate with waypt_disp_all? - for (const Waypoint* waypointp : qAsConst(*global_waypoint_list)) { + for (const Waypoint* waypointp : std::as_const(*global_waypoint_list)) { const auto* fs = reinterpret_cast(waypointp->fs.FsChainFind(kFsLowranceusr4)); if (fs && fs->UUID1 == id1 && diff --git a/mkshort.cc b/mkshort.cc index 8bf839b41..92b3416b4 100644 --- a/mkshort.cc +++ b/mkshort.cc @@ -23,13 +23,13 @@ #include // for assert #include // for isspace, isdigit +#include // for as_const #include // for QByteArray #include // for QChar, QChar::ReplacementCharacter #include // for QString #include // for QVector #include // for CaseInsensitive -#include // for qAsConst #include "defs.h" #include "geocache.h" // for Geocache @@ -254,7 +254,7 @@ QByteArray MakeShort::mkshort(const QByteArray& istring, bool is_utf8) */ QByteArray tstring; ostring.swap(tstring); - for (const auto ch : qAsConst(tstring)) { + for (const auto ch : std::as_const(tstring)) { if (!isspace(ch)) { ostring.append(ch); } @@ -277,7 +277,7 @@ QByteArray MakeShort::mkshort(const QByteArray& istring, bool is_utf8) { QByteArray tstring; ostring.swap(tstring); - for (const auto ch : qAsConst(tstring)) { + for (const auto ch : std::as_const(tstring)) { if (badchars_.contains(ch)) { continue; } diff --git a/position.cc b/position.cc index 9060b916c..a7275b84e 100644 --- a/position.cc +++ b/position.cc @@ -22,10 +22,10 @@ #include "position.h" #include // for abs -#include // for strtod +#include // for strtod, abs #include // for QList -#include // for qAsConst, qRound64, qint64 +#include // for qRound64, qint64 #include "defs.h" #include "src/core/datetime.h" // for DateTime diff --git a/radius.cc b/radius.cc index ce19ceb83..5552790d2 100644 --- a/radius.cc +++ b/radius.cc @@ -22,9 +22,10 @@ #include "radius.h" #include // for strtod +#include // for as_const #include // for QString -#include // for qAsConst, QAddConst<>::Type, foreach +#include // QAddConst<>::Type, foreach #include "defs.h" // for Waypoint, del_marked_wpts, route_add_head, route_add_wpt, waypt_add, waypt_sort, waypt_swap, xstrtoi, route_head, WaypointList, kMilesPerKilometer @@ -73,7 +74,7 @@ void RadiusFilter::process() waypt_swap(comp); int i = 0; - for (Waypoint* wp : qAsConst(comp)) { + for (Waypoint* wp : std::as_const(comp)) { delete static_cast(wp->extra_data); wp->extra_data = nullptr; diff --git a/resample.cc b/resample.cc index a7eb97313..74a77d84a 100644 --- a/resample.cc +++ b/resample.cc @@ -24,12 +24,13 @@ #include // for round #include // for optional #include // for tuple, tuple_element<>::type +#include // for as_const #include // for QDebug #include // for QList<>::const_iterator #include // for QString #include // for qSetRealNumberPrecision -#include // for qDebug, qAsConst, qint64 +#include // for qDebug, qint64 #include "defs.h" // for Waypoint, route_head, fatal, WaypointList, track_add_wpt, track_disp_all, RouteList, track_add_head, track_del_wpt, track_swap, UrlList, gb_color, global_options, global_opts #include "src/core/datetime.h" // for DateTime @@ -88,7 +89,7 @@ void ResampleFilter::average_waypoint(Waypoint* wpt, bool zero_stuffed) } counter = 0; if (global_opts.debug_level >= 5) { - for (const auto& [pos, avc, alt] : qAsConst(history)) { + for (const auto& [pos, avc, alt] : std::as_const(history)) { qDebug() << "initial conditions" << pos << avc << alt; } qDebug() << "initial accumulator" << accumulated_position << accumulated_altitude_valid_count << accumulated_altitude; diff --git a/route.cc b/route.cc index f0a17cc6e..f8fdd8422 100644 --- a/route.cc +++ b/route.cc @@ -20,6 +20,7 @@ #include // for assert #include // for nullptr_t #include // for optional, operator>, operator< +#include // for as_const #include // for operator>, QDateTime, operator< #include // for QList<>::const_iterator @@ -462,7 +463,7 @@ RouteList::del_marked_wpts(route_head* rte) // mimic trkseg handling from WaypointList::del_rte_waypt bool inherit_new_trkseg = false; - for (Waypoint* wpt : qAsConst(oldlist)) { + for (Waypoint* wpt : std::as_const(oldlist)) { if (wpt->wpt_flags.marked_for_deletion) { if (wpt->wpt_flags.new_trkseg) { inherit_new_trkseg = true; diff --git a/tools/Dockerfile_f39 b/tools/Dockerfile_f39 new file mode 100644 index 000000000..5d89d175f --- /dev/null +++ b/tools/Dockerfile_f39 @@ -0,0 +1,22 @@ +# this file is used to build the image gpsbabel_build_environment used by travis. + +FROM fedora:39 + +LABEL maintainer="https://github.com/tsteven4" + +WORKDIR /app + +# basic tools to build +RUN dnf install --assumeyes git make valgrind diffutils findutils langpacks-en ninja-build && \ + dnf clean all +# libraries used by gpsbabel. zlib and shapelib may or may not be used depending qmake options. +RUN dnf install --assumeyes libusb1-devel zlib-devel shapelib-devel && \ + dnf clean all +# Qt used by gpsbabel, gpsbabelfe +RUN dnf install --assumeyes qt5-qtbase-devel qt5-qtserialport-devel qt5-qtwebengine-devel qt5-linguist qt5-qttranslations && \ + dnf clean all +RUN dnf install --assumeyes qt6-qtbase-devel qt6-qtserialport-devel qt6-qtwebengine-devel qt6-linguist qt6-qttranslations qt6-qt5compat-devel qt6-qttools-devel libxkbcommon-devel && \ + dnf clean all +# tools to build the docs +RUN dnf install --assumeyes expat desktop-file-utils libxslt docbook-style-xsl fop docbook5-style-xsl docbook5-schemas && \ + dnf clean all diff --git a/trackfilter.cc b/trackfilter.cc index 1c3dd1384..708032496 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -30,6 +30,7 @@ static constexpr bool TRACKF_DBG = false; #include // for strlen, strchr, strcmp #include // for gmtime, strftime, time_t, tm #include // for next +#include // for as_const #include // for QByteArray #include // for QChar @@ -41,7 +42,7 @@ static constexpr bool TRACKF_DBG = false; #include // for QRegularExpressionMatch #include // for QString #include // for UTC, CaseInsensitive -#include // for qAsConst, foreach, qPrintable, QAddConst<>::Type, qint64 +#include // for foreach, qPrintable, QAddConst<>::Type, qint64 #include "defs.h" #include "trackfilter.h" @@ -62,7 +63,7 @@ int TrackFilter::trackfilter_opt_count() { int res = 0; - for (const auto& arg : qAsConst(args)) { + for (const auto& arg : std::as_const(args)) { if (*arg.argval != nullptr) { res++; } @@ -296,7 +297,7 @@ void TrackFilter::trackfilter_title() if (strlen(opt_title) == 0) { fatal(MYNAME "-title: Missing your title!\n"); } - for (auto* track : qAsConst(track_list)) { + for (auto* track : std::as_const(track_list)) { trackfilter_pack_init_rte_name(track, QDateTime::fromMSecsSinceEpoch(0, Qt::UTC)); } } @@ -576,7 +577,7 @@ void TrackFilter::trackfilter_move() int timeless_points = 0; - for (auto* track : qAsConst(track_list)) { + for (auto* track : std::as_const(track_list)) { foreach (Waypoint* wpt, track->waypoint_list) { if (wpt->creation_time.isValid()) { wpt->creation_time = wpt->creation_time.addMSecs(delta); @@ -607,7 +608,7 @@ void TrackFilter::trackfilter_synth() fix_type fix = trackfilter_parse_fix(&nsats); - for (auto* track : qAsConst(track_list)) { + for (auto* track : std::as_const(track_list)) { bool first = true; foreach (Waypoint* wpt, track->waypoint_list) { if (opt_fix) { @@ -757,7 +758,7 @@ void TrackFilter::trackfilter_seg2trk() { if (!track_list.isEmpty()) { QList new_track_list; - for (auto* src : qAsConst(track_list)) { + for (auto* src : std::as_const(track_list)) { new_track_list.append(src); route_head* dest = src; route_head* insert_point = src; @@ -871,7 +872,7 @@ void TrackFilter::trackfilter_faketime() assert(opt_faketime != nullptr); faketime_t faketime = trackfilter_faketime_check(opt_faketime); - for (auto* track : qAsConst(track_list)) { + for (auto* track : std::as_const(track_list)) { foreach (Waypoint* wpt, track->waypoint_list) { if (!wpt->creation_time.isValid() || faketime.force) { diff --git a/unicsv.cc b/unicsv.cc index 679c19ad4..040908078 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -24,6 +24,7 @@ #include // for fabs, lround #include // for NULL, sscanf #include // for tm +#include // for as_const #include // for QByteArray #include // for QChar @@ -207,7 +208,7 @@ UnicsvFormat::unicsv_parse_gc_code(const QString& str) } long long res = 0; - for (auto c : qAsConst(s)) { + for (auto c : std::as_const(s)) { int val = kBase31.indexOf(c); if (val < 0 || (base == 16 && val > 15)) { return 0; diff --git a/util.cc b/util.cc index c625e95d4..77e724979 100644 --- a/util.cc +++ b/util.cc @@ -27,6 +27,7 @@ #include // for size_t, vsnprintf, FILE, fopen, printf, sprintf, stderr, stdin, stdout #include // for abs, calloc, free, malloc, realloc #include // for strlen, strcat, strstr, memcpy, strcmp, strcpy, strdup, strchr, strerror +#include // for as_const #include // for QByteArray #include // for QChar, operator<=, operator>= @@ -41,7 +42,7 @@ #include // for CaseInsensitive #include // for QTime #include // for QTimeZone -#include // for qAsConst, qEnvironmentVariableIsSet, QAddConst<>::Type, qPrintable +#include // for qEnvironmentVariableIsSet, QAddConst<>::Type, qPrintable #include "defs.h" #include "src/core/datetime.h" // for DateTime @@ -1033,7 +1034,7 @@ void list_timezones() }; std::sort(zoneids.begin(), zoneids.end(), alpha); Warning() << "Available timezones are:"; - for (const auto& id : qAsConst(zoneids)) { + for (const auto& id : std::as_const(zoneids)) { Warning() << id; } } diff --git a/vecs.cc b/vecs.cc index 944e863ab..75238c8fc 100644 --- a/vecs.cc +++ b/vecs.cc @@ -31,12 +31,13 @@ #include // for QStringList #include // for QVector #include // for CaseInsensitive -#include // for qPrintable, qAsConst +#include // for qPrintable #include // for sort #include // for assert #include // for printf, putchar, sscanf -#include // for add_const<>::type, is_base_of +#include // for is_base_of +#include // for as_const #include "defs.h" // for arglist_t, ff_vecs_t, ff_cap, fatal, CSTR, ARGTYPE_TYPEMASK, case_ignore_strcmp, global_options, global_opts, warning, xfree, ARGTYPE_BOOL, ff_cap_read, ff_cap_write, ARGTYPE_HIDDEN, ff_type_internal, xstrdup, ARGTYPE_INT, ARGTYPE_REQUIRED, ARGTYPE_FLOAT #include "dg-100.h" // for Dg100FileFormat, Dg100SerialFormat, Dg200FileFormat, Dg200SerialFormat @@ -817,7 +818,7 @@ Vecs::fmtinfo_t Vecs::find_vec(const QString& fmtargstring) * Didn't find it in the table of "real" file types, so plan B * is to search the list of xcsv styles. */ - for (const auto& svec : qAsConst(style_list)) { + for (const auto& svec : std::as_const(style_list)) { if (fmtname.compare(svec.name, Qt::CaseInsensitive) != 0) { continue; } diff --git a/waypt.cc b/waypt.cc index 77a219faa..f7f0783b8 100644 --- a/waypt.cc +++ b/waypt.cc @@ -22,6 +22,7 @@ #include // for assert #include // for fabs #include // for fflush, fprintf, stdout +#include // for as_const #include // for QChar #include // for QDateTime @@ -640,7 +641,7 @@ WaypointList::del_marked_wpts() WaypointList oldlist; swap(oldlist); - for (Waypoint* wpt : qAsConst(oldlist)) { + for (Waypoint* wpt : std::as_const(oldlist)) { if (wpt->wpt_flags.marked_for_deletion) { delete wpt; } else { diff --git a/xcsv.cc b/xcsv.cc index d649fff55..9123cf606 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -33,6 +33,7 @@ #include // for strlen, strncmp, strcmp #include // for gmtime, localtime, time_t, mktime, strftime #include // for optional +#include // for as_const #include // for QByteArray #include // for QChar @@ -46,7 +47,8 @@ #include // for QString, operator+, operator== #include // for QStringList #include // for QTextStream -#include // for qAsConst, qRound, qPrintable +#include // for CaseInsensitive +#include // for qRound, qPrintable #include "defs.h" #include "csv_util.h" // for csv_stringtrim, dec_to_human, csv_stringclean, human_to_dec, ddmmdir_to_degrees, dec_to_intdeg, decdir_to_dec, intdeg_to_dec, csv_linesplit @@ -850,7 +852,7 @@ XcsvFormat::read() * pre-read the file to know how many data lines we should be seeing, * we take this cheap shot at the data and cross our fingers. */ - for (const auto& ogp : qAsConst(xcsv_style->epilogue)) { + for (const auto& ogp : std::as_const(xcsv_style->epilogue)) { if (ogp.startsWith(buff)) { buff.clear(); break; @@ -1040,7 +1042,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) } int i = 0; - for (const auto& fmp : qAsConst(xcsv_style->ofields)) { + for (const auto& fmp : std::as_const(xcsv_style->ofields)) { double lat = latitude; double lon = longitude; /* @@ -1659,7 +1661,7 @@ XcsvFormat::write() waypt_out_count = 0; /* output prologue lines, if any. */ - for (const auto& line : qAsConst(xcsv_style->prologue)) { + for (const auto& line : std::as_const(xcsv_style->prologue)) { QString line_to_write = xcsv_replace_tokens(line); xcsv_file->stream << line_to_write << xcsv_style->record_delimiter; } @@ -1682,7 +1684,7 @@ XcsvFormat::write() } /* output epilogue lines, if any. */ - for (const auto& line : qAsConst(xcsv_style->epilogue)) { + for (const auto& line : std::as_const(xcsv_style->epilogue)) { QString line_to_write = xcsv_replace_tokens(line); xcsv_file->stream << line_to_write << xcsv_style->record_delimiter; } From 86100734007a4bf008cfc4b3801ca3015547c643 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 9 Nov 2023 08:00:03 -0700 Subject: [PATCH 033/132] make qstarz format dynamic (#1212) --- qstarz_bl_1000.cc | 26 +++++++------------------- qstarz_bl_1000.h | 10 +++------- vecs.cc | 4 ++-- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/qstarz_bl_1000.cc b/qstarz_bl_1000.cc index 2910a4ab1..a0aadce00 100644 --- a/qstarz_bl_1000.cc +++ b/qstarz_bl_1000.cc @@ -135,7 +135,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* stream >> unused2; if (stream.status() != QDataStream::Ok) { - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Perhaps this isn't a Qstarz BL-1000 file"); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Perhaps this isn't a Qstarz BL-1000 file"); } BL1000_POINT_TYPE type; @@ -171,7 +171,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* default: type = BL1000_POINT_TYPE_UNKNOWN; - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for RCR (record reason): " << rcr); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for RCR (record reason): " << rcr); break; } @@ -205,7 +205,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* fix = fix_unknown; if (type != BL1000_POINT_TYPE_UNKNOWN) { - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for fix quality: " << fixQuality); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for fix quality: " << fixQuality); } break; @@ -219,11 +219,11 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* // qDebug(waypoint) if ((waypoint->latitude < -90) || (waypoint->latitude > 90)) { - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for latitude: " << waypoint->latitude); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for latitude: " << waypoint->latitude); } if ((waypoint->longitude < -180) || (waypoint->longitude > 180)) { - fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for longitude: " << waypoint->longitude); + fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for longitude: " << waypoint->longitude); } waypoint->altitude = altitude; @@ -268,24 +268,12 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head* * entry points called by gpsbabel main process * ***************************************************************************/ -void -QstarzBL1000Format::rd_init(const QString& fname) -{ - read_fname = fname; -} - -void -QstarzBL1000Format::rd_deinit() -{ - read_fname.clear(); -} - void QstarzBL1000Format::read() { - QFile file(read_fname); + QFile file(fname); if (!file.open(QIODevice::ReadOnly)) { - fatal(FatalMsg() << MYNAME << ": Error opening file " << read_fname); + fatal(FatalMsg() << MYNAME << ": Error opening file " << fname); } QDataStream stream(&file); diff --git a/qstarz_bl_1000.h b/qstarz_bl_1000.h index 2870407e9..2a52c4b9d 100644 --- a/qstarz_bl_1000.h +++ b/qstarz_bl_1000.h @@ -55,6 +55,8 @@ struct qstarz_bl_1000_fsdata : FormatSpecificData { class QstarzBL1000Format : public Format { public: + using Format::Format; + ff_type get_type() const override { return ff_type_file; @@ -69,15 +71,9 @@ class QstarzBL1000Format : public Format }; } - void rd_init(const QString& fname) override; + void rd_init(const QString& fname) override {} void read() override; - void rd_deinit() override; void qstarz_bl_1000_read(QDataStream& stream); void qstarz_bl_1000_read_record(QDataStream& stream, route_head* track_route); - -private: - QString read_fname; }; - - #endif diff --git a/vecs.cc b/vecs.cc index 75238c8fc..c4c7a7a99 100644 --- a/vecs.cc +++ b/vecs.cc @@ -162,7 +162,6 @@ struct Vecs::Impl { GarminFitFormat format_fit_fmt; GeoJsonFormat geojson_fmt; GlobalsatSportFormat globalsat_sport_fmt; - QstarzBL1000Format qstarz_bl_1000_fmt; #endif // MAXIMAL_ENABLED const QVector vec_list { @@ -488,11 +487,12 @@ struct Vecs::Impl { nullptr, }, { - &qstarz_bl_1000_fmt, + nullptr, "qstarz_bl-1000", "Qstarz BL-1000", nullptr, nullptr, + &fmtfactory }, { nullptr, From 149a2b87e05a70a943a1ea88ed25f249d51cc0a4 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:14:56 -0700 Subject: [PATCH 034/132] misc cleanups (#1213) initialize garmin_fs class member. catch gui up with Qt 5.15 floor. rename tidy build directory. --- garmin_fs.h | 2 +- gui/formatload.cc | 7 ------- gui/main.cc | 2 +- tools/ci_run_tidy.sh | 8 ++++---- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/garmin_fs.h b/garmin_fs.h index ac74e8957..00c16074b 100644 --- a/garmin_fs.h +++ b/garmin_fs.h @@ -119,7 +119,7 @@ class garmin_fs_t : public FormatSpecificData { QString fax_nr; /* fax number */ QString postal_code; /* postal code */ QString email; /* email address */ - unsigned int duration; /* expected travel time to next route point, in seconds, only when auto-routed */ + unsigned int duration{0}; /* expected travel time to next route point, in seconds, only when auto-routed */ QList ilinks; #ifdef GMSD_EXPERIMENTAL diff --git a/gui/formatload.cc b/gui/formatload.cc index 23d24fb39..046e16f12 100644 --- a/gui/formatload.cc +++ b/gui/formatload.cc @@ -34,9 +34,6 @@ #include // for QVariant #include // for QApplication #include // for QMessageBox -#ifdef GENERATE_CORE_STRINGS -#include // for QT_VERSION, QT_VERSION_CHECK -#endif #include "appname.h" // for appName @@ -48,11 +45,7 @@ extern QTextStream* generate_output_stream; static QString xlt(const QString& f) { #ifdef GENERATE_CORE_STRINGS -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - *generate_output_stream << "QT_TRANSLATE_NOOP(\"core\",\"" << f << "\")" << endl; -#else *generate_output_stream << "QT_TRANSLATE_NOOP(\"core\",\"" << f << "\")" << Qt::endl; -#endif #endif return QCoreApplication::translate("core", f.toUtf8().constData()); } diff --git a/gui/main.cc b/gui/main.cc index 60788074e..6ad489aa8 100644 --- a/gui/main.cc +++ b/gui/main.cc @@ -32,7 +32,7 @@ int main(int argc, char** argv) // MIN_QT_VERSION in GPSBabel.pro should correspond to the QT_VERSION_CHECK // arguments in main.cc and gui/main.cc and the version check in // CMakeLists.txt, gui/CMakeLists.txt. -#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) #error this version of Qt is not supported. #endif diff --git a/tools/ci_run_tidy.sh b/tools/ci_run_tidy.sh index 813043835..6d0eff7e4 100755 --- a/tools/ci_run_tidy.sh +++ b/tools/ci_run_tidy.sh @@ -7,16 +7,16 @@ CODACY_CLANG_TIDY=$(curl -s https://api.github.com/repos/codacy/codacy-clang-tid CHECKS="clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,bugprone-*,google-*,misc-*,performance-*,readability-*,-cppcoreguidelines-pro-type-vararg,-modernize-use-trailing-return-type,-readability-identifier-length" HEADERFILTER=".*" -mkdir bld -cd bld +mkdir bld-tidy +cd bld-tidy cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DGPSBABEL_ENABLE_PCH=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. # generate included ui files cmake --build . cd .. # exclude third party library source -jq '[.[]|select(.file|contains("zlib")|not)] | [.[]|select(.file|contains("shapelib")|not)] | [.[]|select(.file|contains("bld")|not)]' \ -bld/compile_commands.json \ +jq '[.[]|select(.file|contains("zlib")|not)] | [.[]|select(.file|contains("shapelib")|not)] | [.[]|select(.file|contains("bld-tidy")|not)]' \ +bld-tidy/compile_commands.json \ > compile_commands.json # run-clang-tidy may still be forcing injection of escape sequences for colors. From abf488cfd35da6bacc7bf1a9a7486b75380c6047 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sun, 12 Nov 2023 06:28:18 -0700 Subject: [PATCH 035/132] clang tidy fixes (#1214) * fix tidy readability-named-parameter * fix readability-named-parameter fix * fix some readability-inconsistent-declaration-parameter-name tidy warnings. * update tidy script to ignore strptime ignore third party headers clean build directory generate summary * update git ignores --- .gitignore | 6 ++++ arcdist.cc | 2 +- arcdist.h | 2 +- defs.h | 6 ++-- dg-100.h | 4 +-- garmin.cc | 6 ++-- garmin_txt.cc | 8 ++--- geo.h | 4 +-- igc.h | 34 +++++++++---------- jeeps/garminusb.h | 2 +- jeeps/gpsapp.cc | 10 +++--- jeeps/gpslibusb.cc | 2 +- jeeps/gpsusbcommon.h | 2 +- jeeps/gpsusbread.cc | 2 +- jeeps/gpsusbsend.cc | 2 +- lowranceusr.cc | 6 ++-- lowranceusr.h | 74 ++++++++++++++++++++--------------------- random.cc | 4 +-- random.h | 10 +++--- rgbcolors.cc | 18 +++++----- src/core/usasciicodec.h | 4 +-- tools/ci_run_tidy.sh | 7 ++-- validate.cc | 4 +-- validate.h | 4 +-- 24 files changed, 116 insertions(+), 107 deletions(-) diff --git a/.gitignore b/.gitignore index 6d7d77f69..d0e84069e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,12 @@ /autom4te.cache/ /babelweb/ /bld/ +/bld-clazy/ +/bld-sanitizeaddress/ +/bld-sanitizeundefined/ +/bld-tidy/ /build/ +/codacy-clang-tidy /compile_commands.json /config.h /config.log @@ -45,6 +50,7 @@ /out/ /qrc_gpsbabel.cpp /release/ +/run-clang-tidy-nocolor /tmp/ CMakeCache.txt CMakeFiles/ diff --git a/arcdist.cc b/arcdist.cc index 55a33c887..5f56b8ca4 100644 --- a/arcdist.cc +++ b/arcdist.cc @@ -106,7 +106,7 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2) arcpt1 = arcpt2; } -void ArcDistanceFilter::arcdist_arc_disp_hdr_cb(const route_head*) +void ArcDistanceFilter::arcdist_arc_disp_hdr_cb(const route_head* /*unused*/) { /* Set arcpt1 to NULL */ arcdist_arc_disp_wpt_cb(nullptr); diff --git a/arcdist.h b/arcdist.h index 842fb12f4..2458ffc9e 100644 --- a/arcdist.h +++ b/arcdist.h @@ -54,7 +54,7 @@ class ArcDistanceFilter:public Filter /* Member Functions */ void arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2); - void arcdist_arc_disp_hdr_cb(const route_head*); + void arcdist_arc_disp_hdr_cb(const route_head* /*unused*/); /* Data Members */ diff --git a/defs.h b/defs.h index 1ab851799..99e3a54bc 100644 --- a/defs.h +++ b/defs.h @@ -326,7 +326,7 @@ class Waypoint Waypoint(); ~Waypoint(); Waypoint(const Waypoint& other); - Waypoint& operator=(const Waypoint& other); + Waypoint& operator=(const Waypoint& rhs); /* Member Functions */ @@ -927,8 +927,8 @@ struct ff_vecs_t { // This can have a large effect on codacy issues from cppcheck // nullPointerRedundantCheck, nullPointerArithmeticRedundantCheck, // negativeIndex, arrayIndexOutOfBoundsCond. -[[gnu::format(printf, 1, 2)]] [[noreturn]] void fatal(const char*, ...); -[[gnu::format(printf, 1, 2)]] void warning(const char*, ...); +[[gnu::format(printf, 1, 2)]] [[noreturn]] void fatal(const char* fmt, ...); +[[gnu::format(printf, 1, 2)]] void warning(const char* fmt, ...); void printposn(double c, bool is_lat); diff --git a/dg-100.h b/dg-100.h index 12c609712..346ea5ff4 100644 --- a/dg-100.h +++ b/dg-100.h @@ -126,8 +126,8 @@ class Dg100Format : public Format void dg100_getfiles() const; int dg100_erase() const; void common_rd_init(const QString& fname); - void dg100_rd_init(const QString& fname, bool isfile); - void dg200_rd_init(const QString& fname, bool isfile); + void dg100_rd_init(const QString& fname, bool is_file); + void dg200_rd_init(const QString& fname, bool is_file); /* Data Members */ diff --git a/garmin.cc b/garmin.cc index f6fd25dd6..c8ab8f234 100644 --- a/garmin.cc +++ b/garmin.cc @@ -408,7 +408,7 @@ rw_deinit() } static int -waypt_read_cb(int total_ct, GPS_PWay*) +waypt_read_cb(int total_ct, GPS_PWay* /*unused*/) { if (global_opts.verbose_status) { static int i; @@ -485,7 +485,7 @@ waypt_read() } } -static int lap_read_nop_cb(int, GPS_SWay**) +static int lap_read_nop_cb(int /*unused*/, GPS_SWay** /*unused*/) { return 0; } @@ -812,7 +812,7 @@ sane_GPS_Way_New() } static int -waypt_write_cb(GPS_PWay*) +waypt_write_cb(GPS_PWay* /*unused*/) { int n = waypt_count(); diff --git a/garmin_txt.cc b/garmin_txt.cc index 62efa8d60..f7b1575fd 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -245,13 +245,13 @@ enum_waypt_cb(const Waypoint* wpt) /* common route and track pre-work */ static void -prework_hdr_cb(const route_head*) +prework_hdr_cb(const route_head* /*unused*/) { cur_info = &route_info[route_idx]; } static void -prework_tlr_cb(const route_head*) +prework_tlr_cb(const route_head* /*unused*/) { cur_info->last_wpt = cur_info->prev_wpt; route_idx++; @@ -615,7 +615,7 @@ route_disp_hdr_cb(const route_head* rte) } static void -route_disp_tlr_cb(const route_head*) +route_disp_tlr_cb(const route_head* /*unused*/) { route_idx++; } @@ -670,7 +670,7 @@ track_disp_hdr_cb(const route_head* track) } static void -track_disp_tlr_cb(const route_head*) +track_disp_tlr_cb(const route_head* /*unused*/) { route_idx++; } diff --git a/geo.h b/geo.h index ae1197702..96b31f492 100644 --- a/geo.h +++ b/geo.h @@ -61,8 +61,8 @@ class GeoFormat : public Format /* Member Functions */ static void GeoReadLoc(QXmlStreamReader& reader); - void geo_waypt_pr(const Waypoint*, QXmlStreamWriter& writer); - static Geocache::container_t wpt_container(const QString&); + void geo_waypt_pr(const Waypoint* waypointp, QXmlStreamWriter& writer); + static Geocache::container_t wpt_container(const QString& args); /* Data Members */ diff --git a/igc.h b/igc.h index e08963e85..51019a348 100644 --- a/igc.h +++ b/igc.h @@ -236,7 +236,7 @@ class IgcFormat : public Format class TaskRecordReader { public: - void igc_task_rec(const char*); + void igc_task_rec(const char* rec); private: enum class state_t { id, takeoff, start, turnpoint, finish, landing }; @@ -251,7 +251,7 @@ class IgcFormat : public Format class Interpolater { public: - double interpolate_alt(const route_head*, const gpsbabel::DateTime&); + double interpolate_alt(const route_head* track, const gpsbabel::DateTime& time); private: std::optional prev_wpt; @@ -267,23 +267,23 @@ class IgcFormat : public Format /* Member Functions */ - static bool coords_match(double, double, double, double); - igc_rec_type_t get_record(char**) const; - void detect_pres_track(const route_head*); - void detect_gnss_track(const route_head*); - void detect_other_track(const route_head*, int& max_waypt_ct); - void get_tracks(const route_head**, const route_head**); - static QByteArray latlon2str(const Waypoint*); - static QByteArray date2str(const gpsbabel::DateTime&); - static QByteArray tod2str(const gpsbabel::DateTime&); + static bool coords_match(double lat1, double lon1, double lat2, double lon2); + igc_rec_type_t get_record(char** rec) const; + void detect_pres_track(const route_head* rh); + void detect_gnss_track(const route_head* rh); + void detect_other_track(const route_head* rh, int& max_waypt_ct); + void get_tracks(const route_head** pres_track, const route_head** gnss_track); + static QByteArray latlon2str(const Waypoint* wpt); + static QByteArray date2str(const gpsbabel::DateTime& dt); + static QByteArray tod2str(const gpsbabel::DateTime& tod); void wr_header(); - void wr_task_wpt_name(const Waypoint*, const char*); - void wr_task_hdr(const route_head*, unsigned int task_num); - void wr_task_wpt(const Waypoint*); - void wr_task_tlr(const route_head*); + void wr_task_wpt_name(const Waypoint* wpt, const char* alt_name); + void wr_task_hdr(const route_head* rte, unsigned int task_num); + void wr_task_wpt(const Waypoint* wpt); + void wr_task_tlr(const route_head* rte); void wr_tasks(); - void wr_fix_record(const Waypoint*, int, int); - static int correlate_tracks(const route_head*, const route_head*); + void wr_fix_record(const Waypoint* wpt, int pres_alt, int gnss_alt); + static int correlate_tracks(const route_head* pres_track, const route_head* gnss_track); void wr_track(); /* Data Members */ diff --git a/jeeps/garminusb.h b/jeeps/garminusb.h index 5fd0136ac..5e968d655 100644 --- a/jeeps/garminusb.h +++ b/jeeps/garminusb.h @@ -60,7 +60,7 @@ extern garmin_unit_info_t garmin_unit_info[GUSB_MAX_UNITS]; int gusb_cmd_send(const garmin_usb_packet* obuf, size_t sz); int gusb_cmd_get(garmin_usb_packet* ibuf, size_t sz); int gusb_init(const char* portname, gpsdevh** dh); -int gusb_close(gpsdevh*, bool exit_lib = true); +int gusb_close(gpsdevh* dh, bool exit_lib = true); /* * New packet types in USB. diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index 914b7e1c6..95e487629 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -3657,7 +3657,7 @@ static void GPS_D210_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [int32] number of track entries ************************************************************************/ -int32 GPS_A300_Get(const char* port , GPS_PTrack** trk, pcb_fn) +int32 GPS_A300_Get(const char* port , GPS_PTrack** trk, pcb_fn /*unused*/) { static UC data[2]; gpsdevh* fd; @@ -6131,7 +6131,7 @@ int32 GPS_A800_On(const char* port, gpsdevh** fd) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A800_Off(const char*, gpsdevh** fd) +int32 GPS_A800_Off(const char* /*unused*/, gpsdevh** fd) { static UC data[2]; GPS_PPacket tra; @@ -6590,7 +6590,7 @@ int32 GPS_A1006_Get ** ** @return [int32] success ************************************************************************/ -int32 GPS_A1006_Send(const char*, +int32 GPS_A1006_Send(const char* /*unused*/, GPS_PCourse* crs, int32 n_crs, gpsdevh* fd) @@ -6825,7 +6825,7 @@ int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A1007_Send(const char*, +int32 GPS_A1007_Send(const char* /*unused*/, GPS_PCourse_Lap* clp, int32 n_clp, gpsdevh* fd) @@ -7096,7 +7096,7 @@ int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A1008_Send(const char*, +int32 GPS_A1008_Send(const char* /*unused*/, GPS_PCourse_Point* cpt, int32 n_cpt, gpsdevh* fd) diff --git a/jeeps/gpslibusb.cc b/jeeps/gpslibusb.cc index 752379d72..80e6f0f1d 100644 --- a/jeeps/gpslibusb.cc +++ b/jeeps/gpslibusb.cc @@ -66,7 +66,7 @@ static unsigned char gusb_bulk_in_ep; static bool libusb_successfully_initialized{false}; static libusb_device_handle* udev{nullptr}; -static int garmin_usb_scan(libusb_unit_data*, int); +static int garmin_usb_scan(libusb_unit_data* lud, int req_unit_number); static int gusb_libusb_get(garmin_usb_packet* ibuf, size_t sz); static int gusb_libusb_get_bulk(garmin_usb_packet* ibuf, size_t sz); diff --git a/jeeps/gpsusbcommon.h b/jeeps/gpsusbcommon.h index df07c4ae5..8b29d4040 100644 --- a/jeeps/gpsusbcommon.h +++ b/jeeps/gpsusbcommon.h @@ -37,7 +37,7 @@ typedef struct gusb_llops { /* Provided by the common code. */ void gusb_syncup(); -void gusb_register_ll(gusb_llops*); +void gusb_register_ll(gusb_llops* p); void gusb_list_units(); /* Provided by the OS layers */ diff --git a/jeeps/gpsusbread.cc b/jeeps/gpsusbread.cc index 97bb7c035..e6e10062d 100644 --- a/jeeps/gpsusbread.cc +++ b/jeeps/gpsusbread.cc @@ -28,7 +28,7 @@ * Negative on error. * 1 if read success - even if empty packet. */ -int32 GPS_Packet_Read_usb(gpsdevh*, GPS_PPacket* packet, int eat_bulk) +int32 GPS_Packet_Read_usb(gpsdevh* /*unused*/, GPS_PPacket* packet, int eat_bulk) { int32 n; int32 payload_size; diff --git a/jeeps/gpsusbsend.cc b/jeeps/gpsusbsend.cc index 04ac456fa..030776587 100644 --- a/jeeps/gpsusbsend.cc +++ b/jeeps/gpsusbsend.cc @@ -26,7 +26,7 @@ #include int32 -GPS_Write_Packet_usb(gpsdevh*, GPS_PPacket& packet) +GPS_Write_Packet_usb(gpsdevh* /*unused*/, GPS_PPacket& packet) { garmin_usb_packet gp; memset(&gp, 0, sizeof(gp)); diff --git a/lowranceusr.cc b/lowranceusr.cc index 6a06e1322..37201990f 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -1678,7 +1678,7 @@ LowranceusrFormat::lowranceusr4_route_leg_disp(const Waypoint* wpt) const } void -LowranceusrFormat::lowranceusr4_route_trl(const route_head*) const +LowranceusrFormat::lowranceusr4_route_trl(const route_head* /*unused*/) const { /* Mystery byte */ gbfputc(0x01, file_out); // end of Route info ?? @@ -1731,7 +1731,7 @@ LowranceusrFormat::lowranceusr_merge_trail_hdr(const route_head* trk) } void -LowranceusrFormat::lowranceusr_merge_trail_tlr(const route_head*) +LowranceusrFormat::lowranceusr_merge_trail_tlr(const route_head* /*unused*/) { if (trail_count == (int)track_count()) { /* last trail */ short num_trail_points = trail_point_count; @@ -1753,7 +1753,7 @@ LowranceusrFormat::lowranceusr_merge_trail_tlr(const route_head*) } } void -LowranceusrFormat::lowranceusr_merge_trail_hdr_2(const route_head*) +LowranceusrFormat::lowranceusr_merge_trail_hdr_2(const route_head* /*unused*/) { continuous = 0; } diff --git a/lowranceusr.h b/lowranceusr.h index 51b4dbeed..efeb6e310 100644 --- a/lowranceusr.h +++ b/lowranceusr.h @@ -385,50 +385,50 @@ class LowranceusrFormat : public Format /* Member Functions */ - static bool same_points(const Waypoint*, const Waypoint*); - void register_waypt(const Waypoint*) const; - static const Waypoint* lowranceusr4_find_waypt(uint, int, int); - static const Waypoint* lowranceusr4_find_global_waypt(uint, uint, uint, uint); - QString lowranceusr4_readstr(gbfile*, int) const; - void lowranceusr4_writestr(const QString&, gbfile*, int) const; - static gpsbabel::DateTime lowranceusr4_get_timestamp(unsigned int, unsigned int); - static Lowranceusr4Timestamp lowranceusr4_jd_from_timestamp(const gpsbabel::DateTime&); - static QString lowranceusr_find_desc_from_icon_number(int); - static int lowranceusr_find_icon_number_from_desc(const QString&); - static QString lowranceusr4_find_desc_from_icon_number(int); - static int lowranceusr4_find_icon_number_from_desc(const QString&); - static const char* lowranceusr4_find_color_from_icon_number_plus_color_index(int, int); - static int lowranceusr4_find_index_from_icon_desc_and_color_desc(const QString&, const QString&); - static double lon_mm_to_deg(double); - static double lat_mm_to_deg(double); - static long int lon_deg_to_mm(double); - static long int lat_deg_to_mm(double); - void lowranceusr_parse_waypt(Waypoint*, int) const; - void lowranceusr4_parse_waypt(Waypoint*) const; + static bool same_points(const Waypoint* A, const Waypoint* B); + void register_waypt(const Waypoint* wpt) const; + static const Waypoint* lowranceusr4_find_waypt(uint uid_unit, int uid_seq_low, int uid_seq_high); + static const Waypoint* lowranceusr4_find_global_waypt(uint id1, uint id2, uint id3, uint id4); + QString lowranceusr4_readstr(gbfile* file, int bytes_per_char) const; + void lowranceusr4_writestr(const QString& buf, gbfile* file, int bytes_per_char) const; + static gpsbabel::DateTime lowranceusr4_get_timestamp(unsigned int jd_number, unsigned int msecs); + static Lowranceusr4Timestamp lowranceusr4_jd_from_timestamp(const gpsbabel::DateTime& qdt); + static QString lowranceusr_find_desc_from_icon_number(int icon); + static int lowranceusr_find_icon_number_from_desc(const QString& desc); + static QString lowranceusr4_find_desc_from_icon_number(int icon); + static int lowranceusr4_find_icon_number_from_desc(const QString& desc); + static const char* lowranceusr4_find_color_from_icon_number_plus_color_index(int icon, int index); + static int lowranceusr4_find_index_from_icon_desc_and_color_desc(const QString& icon, const QString& color); + static double lon_mm_to_deg(double x); + static double lat_mm_to_deg(double x); + static long int lon_deg_to_mm(double x); + static long int lat_deg_to_mm(double x); + void lowranceusr_parse_waypt(Waypoint* wpt_tmp, int object_num_present) const; + void lowranceusr4_parse_waypt(Waypoint* wpt_tmp) const; void lowranceusr_parse_waypts() const; void lowranceusr_parse_route() const; void lowranceusr4_parse_route() const; void lowranceusr_parse_routes(); void lowranceusr_parse_icons() const; - void lowranceusr_parse_trail(int*); - void lowranceusr4_parse_trail(int*) const; + void lowranceusr_parse_trail(int* trail_num); + void lowranceusr4_parse_trail(int* trail_num) const; void lowranceusr_parse_trails(); - void lowranceusr_waypt_disp(const Waypoint*) const; - void lowranceusr4_waypt_disp(const Waypoint*); - void lowranceusr_waypt_pr(const Waypoint*); + void lowranceusr_waypt_disp(const Waypoint* wpt) const; + void lowranceusr4_waypt_disp(const Waypoint* wpt); + void lowranceusr_waypt_pr(const Waypoint* wpt); void lowranceusr4_write_waypoints(); - void lowranceusr_write_icon(const Waypoint*) const; - void lowranceusr_trail_hdr(const route_head*); - void lowranceusr_route_hdr(const route_head*); - void lowranceusr4_route_hdr(const route_head*); - void lowranceusr4_route_leg_disp(const Waypoint*) const; - void lowranceusr4_route_trl(const route_head*) const; - void lowranceusr_trail_disp(const Waypoint*); - void lowranceusr_merge_trail_hdr(const route_head*); - void lowranceusr_merge_trail_tlr(const route_head*); - void lowranceusr_merge_trail_hdr_2(const route_head*); - void lowranceusr4_trail_hdr(const route_head*); - void lowranceusr4_trail_disp(const Waypoint*) const; + void lowranceusr_write_icon(const Waypoint* wpt) const; + void lowranceusr_trail_hdr(const route_head* trk); + void lowranceusr_route_hdr(const route_head* rte); + void lowranceusr4_route_hdr(const route_head* rte); + void lowranceusr4_route_leg_disp(const Waypoint* wpt) const; + void lowranceusr4_route_trl(const route_head* /*unused*/) const; + void lowranceusr_trail_disp(const Waypoint* wpt); + void lowranceusr_merge_trail_hdr(const route_head* trk); + void lowranceusr_merge_trail_tlr(const route_head* /*unused*/); + void lowranceusr_merge_trail_hdr_2(const route_head* /*unused*/); + void lowranceusr4_trail_hdr(const route_head* trail); + void lowranceusr4_trail_disp(const Waypoint* wpt) const; /* Data Members */ diff --git a/random.cc b/random.cc index 339c04602..b0e8033d0 100644 --- a/random.cc +++ b/random.cc @@ -87,7 +87,7 @@ RandomFormat::random_set_generator() } void -RandomFormat::rd_init(const QString&) +RandomFormat::rd_init(const QString& /*unused*/) { random_set_generator(); } @@ -239,7 +239,7 @@ RandomFormat::read() } void -RandomFormat::rd_position_init(const QString&) +RandomFormat::rd_position_init(const QString& /*unused*/) { random_set_generator(); realtime = new realtime_data; diff --git a/random.h b/random.h index 3f392e3bd..d9ace3005 100644 --- a/random.h +++ b/random.h @@ -73,12 +73,12 @@ class RandomFormat : public Format /* Member Functions */ - double rand_dbl(double); - float rand_flt(float); - int rand_int(int); - QString rand_str(int, const char*); + double rand_dbl(double max); + float rand_flt(float max); + int rand_int(int max); + QString rand_str(int maxlen, const char* fmt); void random_set_generator(); - Waypoint* random_generate_wpt(int, const QDateTime&, const Waypoint*); + Waypoint* random_generate_wpt(int i, const QDateTime& time, const Waypoint* prev); /* Data Members */ diff --git a/rgbcolors.cc b/rgbcolors.cc index fbb2e12ea..a82fa3f8b 100644 --- a/rgbcolors.cc +++ b/rgbcolors.cc @@ -219,31 +219,31 @@ static int HexByte(const char* hex) */ int -color_to_bbggrr(const char* opt_color) +color_to_bbggrr(const char* cname) { char* ep; - int color_num = strtol(opt_color, &ep, 10); + int color_num = strtol(cname, &ep, 10); - if (ep != opt_color) { + if (ep != cname) { return color_num; } - if (opt_color[0] == '#') { - color_num = (HexByte(opt_color+1)) + // red - (HexByte(opt_color+3)<<8) + // green - (HexByte(opt_color+5)<<16); // blue + if (cname[0] == '#') { + color_num = (HexByte(cname+1)) + // red + (HexByte(cname+3)<<8) + // green + (HexByte(cname+5)<<16); // blue return color_num; } for (auto i : color_table) { - if (0 == case_ignore_strcmp(opt_color, i.cn)) { + if (0 == case_ignore_strcmp(cname, i.cn)) { return (i.b << 16) + (i.g << 8) + i.r; } } - fatal("unrecognized color name %s\n", opt_color); + fatal("unrecognized color name %s\n", cname); return -1; } diff --git a/src/core/usasciicodec.h b/src/core/usasciicodec.h index db002278c..b6e32f922 100644 --- a/src/core/usasciicodec.h +++ b/src/core/usasciicodec.h @@ -31,8 +31,8 @@ class UsAsciiCodec : public QTextCodec QByteArray name() const override; QList aliases() const override; int mibEnum() const override; - QString convertToUnicode(const char*, int, ConverterState*) const override; - QByteArray convertFromUnicode(const QChar*, int, ConverterState*) const override; + QString convertToUnicode(const char* chars, int len, ConverterState* state) const override; + QByteArray convertFromUnicode(const QChar* uc, int len, ConverterState* state) const override; }; } // namespace gpsbabel diff --git a/tools/ci_run_tidy.sh b/tools/ci_run_tidy.sh index 6d0eff7e4..856fc3cfd 100755 --- a/tools/ci_run_tidy.sh +++ b/tools/ci_run_tidy.sh @@ -5,8 +5,9 @@ COMMIT=$(git log -1 --format='%H') CODACY_CLANG_TIDY=$(curl -s https://api.github.com/repos/codacy/codacy-clang-tidy/releases/latest | jq '.assets[] | select(.name|startswith("codacy-clang-tidy-linux-")) | .browser_download_url' | tr -d \") CHECKS="clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,bugprone-*,google-*,misc-*,performance-*,readability-*,-cppcoreguidelines-pro-type-vararg,-modernize-use-trailing-return-type,-readability-identifier-length" -HEADERFILTER=".*" +HEADERFILTER="$(pwd)/[^/]*\.h|$(pwd)/jeeps/[^/]*\.h|$(pwd)/src/core/[^/]*\.h|$(pwd)/gui/[^/]*\.h|gbversion\.h" +rm -fr bld-tidy mkdir bld-tidy cd bld-tidy cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DGPSBABEL_ENABLE_PCH=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. @@ -15,7 +16,7 @@ cmake --build . cd .. # exclude third party library source -jq '[.[]|select(.file|contains("zlib")|not)] | [.[]|select(.file|contains("shapelib")|not)] | [.[]|select(.file|contains("bld-tidy")|not)]' \ +jq '[.[]|select(.file|contains("zlib")|not)] | [.[]|select(.file|contains("shapelib")|not)] | [.[]|select(.file|contains("strptime")|not)] | [.[]|select(.file|contains("bld-tidy")|not)]' \ bld-tidy/compile_commands.json \ > compile_commands.json @@ -26,6 +27,8 @@ chmod +x run-clang-tidy-nocolor ./run-clang-tidy-nocolor -p "$(pwd)" -header-filter "${HEADERFILTER}" -checks "${CHECKS}" | \ tee tidy.out +grep warning: tidy.out | sed 's/.*\[/[/' | sort | uniq -c | sort | tee tidy.summary + curl -L "${CODACY_CLANG_TIDY}" --output codacy-clang-tidy chmod +x codacy-clang-tidy diff --git a/validate.cc b/validate.cc index 50d4b0ef3..23cf30b81 100644 --- a/validate.cc +++ b/validate.cc @@ -27,7 +27,7 @@ #if FILTERS_ENABLED #define MYNAME "validate" -void ValidateFilter::validate_head(const route_head*) +void ValidateFilter::validate_head(const route_head* /*unused*/) { head_ct += 1; segment_ct_start = point_ct; @@ -44,7 +44,7 @@ void ValidateFilter::validate_head_trl(const route_head* header) } } -void ValidateFilter::validate_point(const Waypoint*) +void ValidateFilter::validate_point(const Waypoint* /*unused*/) { point_ct += 1; } diff --git a/validate.h b/validate.h index ad47720fb..eff779d5c 100644 --- a/validate.h +++ b/validate.h @@ -59,9 +59,9 @@ class ValidateFilter:public Filter }, }; - void validate_head(const route_head*); + void validate_head(const route_head* /*unused*/); void validate_head_trl(const route_head* header); - void validate_point(const Waypoint*); + void validate_point(const Waypoint* /*unused*/); }; From f1bcf0d91e7e7b9854bdc9df0b326b484dc38e25 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:33:14 -0700 Subject: [PATCH 036/132] jeeps function pointers, GPS_PPacket const correctness, GPS_Serial_[OSP]Packet -> GPS_Serial_Packet (#1215) * use using for jeeps function prototypes. * const correctness wrt GPS_PPacket. The important bit here is in gpssend.cc, Build_Serial_Packet used to rececive a 1KB packet by copy, now it is by const reference. * delete accidentally committed file. * rename GPS_PPacket -> GPS_Packet. original jeeps used GPS_SXXX, GPS_OSXXX, GPS_PXXX for the structure tag, a typedef of the structure, and a pointer to a typedef of the structure. In the case of GPS_PPacket this convention was no longer followed. * change GPS_Packet back to a structure. * try harder to change GPS_Packet back to a struct. * clean up GPS_Serial_[SOP]Packet. * catch some missed renames up. clion on linux missed some windows only renames. --- jeeps/gps.h | 23 +----- jeeps/gpsapp.cc | 170 ++++++++++++++++++++--------------------- jeeps/gpsapp.h | 10 +-- jeeps/gpscom.cc | 4 +- jeeps/gpsdevice.cc | 10 +-- jeeps/gpsdevice.h | 21 ++--- jeeps/gpsdevice_usb.cc | 2 +- jeeps/gpsread.cc | 10 +-- jeeps/gpsread.h | 4 +- jeeps/gpsrqst.cc | 8 +- jeeps/gpssend.cc | 20 ++--- jeeps/gpssend.h | 6 +- jeeps/gpsserial.cc | 8 +- jeeps/gpsusbcommon.h | 6 +- jeeps/gpsusbint.h | 6 +- jeeps/gpsusbread.cc | 2 +- jeeps/gpsusbsend.cc | 2 +- 17 files changed, 149 insertions(+), 163 deletions(-) diff --git a/jeeps/gps.h b/jeeps/gps.h index 951d8263a..f9e9f5484 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -28,21 +28,14 @@ extern int32 gps_show_bytes; extern char gps_categories[16][17]; -typedef struct GPS_SPacket { - US type; - uint32 n; - UC* data; -} GPS_OPacket; - -class GPS_PPacket { -public: +struct GPS_Packet { US type{0}; uint32 n{0}; UC data[MAX_GPS_PACKET_SIZE]{}; }; -typedef struct GPS_Serial_SPacket { +struct GPS_Serial_Packet { UC dle; UC type; UC n; @@ -50,15 +43,7 @@ typedef struct GPS_Serial_SPacket { UC chk; UC edle; UC etx; -} GPS_Serial_OPacket, *GPS_Serial_PPacket; - -typedef struct GPS_SProduct_Data_Type { - int16 id; - int16 version; - char desc[MAX_GPS_PACKET_SIZE]; -} GPS_OProduct_Data_Type, *GPS_PProduct_Data_Type; - - +}; typedef struct GPS_SPvt_Data_Type { @@ -247,7 +232,7 @@ typedef struct GPS_SCourse_Limits { } GPS_OCourse_Limits, *GPS_PCourse_Limits; -typedef int (*pcb_fn)(int, GPS_SWay**); +using pcb_fn = int (*)(int, GPS_SWay**); #include "jeeps/gpsdevice.h" #include "jeeps/gpssend.h" diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index 95e487629..c66ad672c 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -47,7 +47,7 @@ double gps_save_lon; #define XMIN(a,b) (a < b? a : b) static int32 GPS_A000(const char* port); -static void GPS_A001(GPS_PPacket& packet); +static void GPS_A001(const GPS_Packet& packet); static void GPS_A500_Translate(UC* s, GPS_PAlmanac* alm); @@ -201,8 +201,8 @@ int32 GPS_Init(const char* port) static int32 GPS_A000(const char* port) { gpsdevh* fd; - GPS_PPacket tra; - GPS_PPacket rec; + GPS_Packet tra; + GPS_Packet rec; int16 version; int16 id; @@ -379,16 +379,16 @@ static int32 GPS_A000(const char* port) ** Extract protocol capabilities ** This routine could do with re-writing. It's too long and obtuse. ** -** @param [r] packet [GPS_PPacket] A001 protocol packet +** @param [r] packet [GPS_Packet] A001 protocol packet ** ** @return [void] ************************************************************************/ -static void GPS_A001(GPS_PPacket& packet) +static void GPS_A001(const GPS_Packet& packet) { US lasta=0; int32 entries = packet.n / 3; - UC* p = packet.data; + const UC* p = packet.data; for (int32 i=0; iDevice_Flush)(fd); } -int32 GPS_Write_Packet(gpsdevh* fd, GPS_PPacket& packet) +int32 GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet) { return (ops->Write_Packet)(fd, packet); } -int32 GPS_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) +int32 GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet) { return (ops->Read_Packet)(fd, packet); } -bool GPS_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec) +bool GPS_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec) { return (ops->Send_Ack)(fd, tra, rec); } -bool GPS_Get_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec) +bool GPS_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec) { return (ops->Get_Ack)(fd, tra, rec); } -void GPS_Make_Packet(GPS_PPacket* packet, US type, UC* data, uint32 n) +void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32 n) { packet->type = type; if (n > 0) { diff --git a/jeeps/gpsdevice.h b/jeeps/gpsdevice.h index 583f4afb7..f893adf27 100644 --- a/jeeps/gpsdevice.h +++ b/jeeps/gpsdevice.h @@ -37,16 +37,17 @@ int32 GPS_Device_Read(int32 ignored, void* ibuf, int size); int32 GPS_Device_Write(int32 ignored, const void* obuf, int size); void GPS_Device_Error(char* hdr, ...); - int32 GPS_Write_Packet(gpsdevh* fd, GPS_PPacket& packet); - bool GPS_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec); - int32 GPS_Packet_Read(gpsdevh* fd, GPS_PPacket* packet); - bool GPS_Get_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec); - - typedef int32(*gps_device_op)(gpsdevh*); - typedef int32(*gps_device_op5)(const char*, gpsdevh** fd); - typedef bool(*gps_device_op10)(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec); - typedef int32(*gps_device_op12)(gpsdevh* fd, GPS_PPacket& packet); - typedef int32(*gps_device_op13)(gpsdevh* fd, GPS_PPacket* packet); + int32 GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet); + bool GPS_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); + int32 GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet); + bool GPS_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); + + using gps_device_op = int32 (*)(gpsdevh*); + using gps_device_op5 = int32 (*)(const char*, gpsdevh** fd); + using gps_device_op10 = bool (*)(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); + using gps_device_op12 = int32 (*)(gpsdevh* fd, const GPS_Packet& packet); + using gps_device_op13 = int32 (*)(gpsdevh* fd, GPS_Packet* packet); + typedef struct { gps_device_op5 Device_On; gps_device_op Device_Off; diff --git a/jeeps/gpsdevice_usb.cc b/jeeps/gpsdevice_usb.cc index 31583c5c1..15e37c19e 100644 --- a/jeeps/gpsdevice_usb.cc +++ b/jeeps/gpsdevice_usb.cc @@ -42,7 +42,7 @@ static int32 gdu_off(gpsdevh* dh) return gusb_close(dh); } -static int32 gdu_read(gpsdevh* fd, GPS_PPacket* packet) +static int32 gdu_read(gpsdevh* fd, GPS_Packet* packet) { /* Default is to eat bulk request packets. */ return GPS_Packet_Read_usb(fd, packet, 1); diff --git a/jeeps/gpsread.cc b/jeeps/gpsread.cc index 512c647af..db9aef4bd 100644 --- a/jeeps/gpsread.cc +++ b/jeeps/gpsread.cc @@ -64,12 +64,12 @@ time_t GPS_Time_Now() ** Read a packet ** ** @param [r] fd [int32] file descriptor -** @param [w] packet [GPS_PPacket *] packet string +** @param [w] packet [GPS_Packet *] packet string ** ** @return [int32] number of bytes read **********************************************************************/ -int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) +int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet) { time_t start; int32 len = 0; @@ -181,13 +181,13 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet) ** Check that returned packet is an ack for the packet sent ** ** @param [r] fd [int32] file descriptor -** @param [r] tra [GPS_PPacket *] packet just transmitted -** @param [r] rec [GPS_PPacket *] packet to receive +** @param [r] tra [GPS_Packet *] packet just transmitted +** @param [r] rec [GPS_Packet *] packet to receive ** ** @return [bool] true if ACK **********************************************************************/ -bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_PPacket *tra, GPS_PPacket *rec) +bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_Packet *tra, GPS_Packet *rec) { if (!GPS_Serial_Packet_Read(fd, rec)) { return false; diff --git a/jeeps/gpsread.h b/jeeps/gpsread.h index 6c57f2a2e..d8461ac22 100644 --- a/jeeps/gpsread.h +++ b/jeeps/gpsread.h @@ -5,7 +5,7 @@ #include "jeeps/gps.h" time_t GPS_Time_Now(); - int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet); - bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_PPacket *tra, GPS_PPacket *rec); + int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet); + bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_Packet *tra, GPS_Packet *rec); #endif diff --git a/jeeps/gpsrqst.cc b/jeeps/gpsrqst.cc index 457eff8b1..82a28adbc 100644 --- a/jeeps/gpsrqst.cc +++ b/jeeps/gpsrqst.cc @@ -69,8 +69,8 @@ int32 GPS_Rqst_Send_Time(gpsdevh* fd, time_t Time) ************************************************************************/ static int32 GPS_A600_Rqst(gpsdevh* fd, time_t Time) { - GPS_PPacket tra; - GPS_PPacket rec; + GPS_Packet tra; + GPS_Packet rec; switch (gps_date_time_type) { case pD600: @@ -134,8 +134,8 @@ int32 GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon) ************************************************************************/ static int32 GPS_A700_Rqst(gpsdevh* fd, double lat, double lon) { - GPS_PPacket tra; - GPS_PPacket rec; + GPS_Packet tra; + GPS_Packet rec; switch (gps_position_type) { case pD700: diff --git a/jeeps/gpssend.cc b/jeeps/gpssend.cc index 71e7dc46a..07ff72e3d 100644 --- a/jeeps/gpssend.cc +++ b/jeeps/gpssend.cc @@ -34,15 +34,15 @@ ** ** Forms a complete packet to send on serial port * -** @param [r] in [GPS_PPacket *] packet string with portable packet data -** @param [w] out [GPS_Serial_PPacket *] packet string suitable for serial port +** @param [r] in [GPS_Packet *] packet string with portable packet data +** @param [w] out [GPS_Serial_Packet *] packet string suitable for serial port ** ** @return [US] number of data bytes to send ************************************************************************/ static US -Build_Serial_Packet(GPS_PPacket in, GPS_Serial_PPacket out) +Build_Serial_Packet(const GPS_Packet& in, GPS_Serial_Packet* out) { - UC* p; + const UC* p; UC* q; UC chk = 0; US bytes = 0; @@ -111,16 +111,16 @@ DiagS(void* buf, size_t sz) ** Forms a complete packet to send ** ** @param [w] fd [int32] file descriptor -** @param [r] packet [GPS_PPacket] packet +** @param [r] packet [GPS_Packet] packet ** ** @return [int32] number of bytes in the packet ************************************************************************/ -int32 GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket& packet) +int32 GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet) { int32 ret; const char* m1, *m2; - GPS_Serial_OPacket ser_pkt; + GPS_Serial_Packet ser_pkt; UC ser_pkt_data[MAX_GPS_PACKET_SIZE * sizeof(UC)]; US bytes; @@ -183,13 +183,13 @@ int32 GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket& packet) ** Send an acknowledge packet ** ** @param [w] fd [int32] file descriptor -** @param [r] tra [GPS_PPacket *] packet to transmit -** @param [r] rec [GPS_PPacket *] last packet received +** @param [r] tra [GPS_Packet *] packet to transmit +** @param [r] rec [GPS_Packet *] last packet received ** ** @return [bool] success ************************************************************************/ -bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec) +bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec) { UC data[2]; diff --git a/jeeps/gpssend.h b/jeeps/gpssend.h index 6a213dc88..c478e9880 100644 --- a/jeeps/gpssend.h +++ b/jeeps/gpssend.h @@ -6,10 +6,10 @@ #define GPS_ARB_LEN 1024 - int32 GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket& packet); - bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec); + int32 GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet); + bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); - void GPS_Make_Packet(GPS_PPacket* packet, US type, UC* data, uint32 n); + void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32 n); #endif diff --git a/jeeps/gpsserial.cc b/jeeps/gpsserial.cc index d0f8107ab..2a3cb4b2e 100644 --- a/jeeps/gpsserial.cc +++ b/jeeps/gpsserial.cc @@ -234,8 +234,8 @@ int32 GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size) int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br) { static UC data[4]; - GPS_PPacket tra; - GPS_PPacket rec; + GPS_Packet tra; + GPS_Packet rec; win_serial_data* wsd = (win_serial_data*)fd; DWORD speed = mkspeed(br); @@ -614,8 +614,8 @@ int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br) struct termios tty; static UC data[4]; - GPS_PPacket tra; - GPS_PPacket rec; + GPS_Packet tra; + GPS_Packet rec; speed_t speed = mkspeed(br); diff --git a/jeeps/gpsusbcommon.h b/jeeps/gpsusbcommon.h index 8b29d4040..d17456799 100644 --- a/jeeps/gpsusbcommon.h +++ b/jeeps/gpsusbcommon.h @@ -23,9 +23,9 @@ * The 'low level ops' are registered by the OS layer (win32, libusb, etc.) * to provide gruntwork features for the common USB layer. */ -typedef int (*gusb_llop_get)(garmin_usb_packet* ibuf, size_t sz); -typedef int (*gusb_llop_send)(const garmin_usb_packet* opkt, size_t sz); -typedef int (*gusb_llop_close)(gpsdevh* dh, bool exit_lib); +using gusb_llop_get = int (*)(garmin_usb_packet* ibuf, size_t sz); +using gusb_llop_send = int (*)(const garmin_usb_packet* opkt, size_t sz); +using gusb_llop_close = int (*)(gpsdevh* dh, bool exit_lib); typedef struct gusb_llops { gusb_llop_get llop_get_intr; diff --git a/jeeps/gpsusbint.h b/jeeps/gpsusbint.h index 50e152263..cba2bee1c 100644 --- a/jeeps/gpsusbint.h +++ b/jeeps/gpsusbint.h @@ -21,7 +21,7 @@ */ -int32 GPS_Packet_Read_usb(gpsdevh* fd, GPS_PPacket* packet, int eatbulk); -void GPS_Make_Packet_usb(GPS_PPacket* packet, UC type, UC* data, int16 n); -int32 GPS_Write_Packet_usb(gpsdevh* fd, GPS_PPacket& packet); +int32 GPS_Packet_Read_usb(gpsdevh* fd, GPS_Packet* packet, int eatbulk); +void GPS_Make_Packet_usb(GPS_Packet* packet, UC type, UC* data, int16 n); +int32 GPS_Write_Packet_usb(gpsdevh* fd, const GPS_Packet& packet); diff --git a/jeeps/gpsusbread.cc b/jeeps/gpsusbread.cc index e6e10062d..59d83c352 100644 --- a/jeeps/gpsusbread.cc +++ b/jeeps/gpsusbread.cc @@ -28,7 +28,7 @@ * Negative on error. * 1 if read success - even if empty packet. */ -int32 GPS_Packet_Read_usb(gpsdevh* /*unused*/, GPS_PPacket* packet, int eat_bulk) +int32 GPS_Packet_Read_usb(gpsdevh* /*unused*/, GPS_Packet* packet, int eat_bulk) { int32 n; int32 payload_size; diff --git a/jeeps/gpsusbsend.cc b/jeeps/gpsusbsend.cc index 030776587..90da93d05 100644 --- a/jeeps/gpsusbsend.cc +++ b/jeeps/gpsusbsend.cc @@ -26,7 +26,7 @@ #include int32 -GPS_Write_Packet_usb(gpsdevh* /*unused*/, GPS_PPacket& packet) +GPS_Write_Packet_usb(gpsdevh* /*unused*/, const GPS_Packet& packet) { garmin_usb_packet gp; memset(&gp, 0, sizeof(gp)); From de0458eddc8c3154618c54ba0a04e785d041f91e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 14 Nov 2023 07:36:58 -0700 Subject: [PATCH 037/132] use uniform header guards in jeeps. (#1216) and delete an obsolete prototype. rename jgpsutil.cc now that it doesn't conflict with a format. --- CMakeLists.txt | 2 +- jeeps/garminusb.h | 5 +++++ jeeps/gps.h | 6 +++--- jeeps/gpsapp.h | 6 +++--- jeeps/gpscom.h | 6 +++--- jeeps/gpsdatum.h | 6 +++--- jeeps/gpsdevice.h | 6 +++--- jeeps/gpsfmt.h | 6 +++--- jeeps/gpsmath.h | 6 +++--- jeeps/gpsmem.h | 6 +++--- jeeps/gpsport.h | 8 ++++++++ jeeps/gpsproj.h | 6 +++--- jeeps/gpsprot.h | 12 +++++------- jeeps/gpsread.h | 6 +++--- jeeps/gpsrqst.h | 6 +++--- jeeps/gpssend.h | 6 +++--- jeeps/gpsserial.h | 6 +++--- jeeps/gpsusbcommon.h | 4 ++++ jeeps/gpsusbint.h | 6 +++++- jeeps/{jgpsutil.cc => gpsutil.cc} | 0 jeeps/gpsutil.h | 6 +++--- 21 files changed, 70 insertions(+), 51 deletions(-) rename jeeps/{jgpsutil.cc => gpsutil.cc} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fcbb1dc20..c664f0ed8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,7 @@ set(JEEPS jeeps/gpsusbcommon.cc jeeps/gpsusbread.cc jeeps/gpsusbsend.cc - jeeps/jgpsutil.cc + jeeps/gpsutil.cc ) # SUPPORT diff --git a/jeeps/garminusb.h b/jeeps/garminusb.h index 5e968d655..41e9a9447 100644 --- a/jeeps/garminusb.h +++ b/jeeps/garminusb.h @@ -18,6 +18,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifndef JEEPS_GARMINUSB_H_INCLUDED_ +#define JEEPS_GARMINUSB_H_INCLUDED_ + #include #include "jeeps/gpsdevice.h" @@ -68,3 +71,5 @@ int gusb_close(gpsdevh* dh, bool exit_lib = true); #define GUSB_SESSION_START 5 /* We request units attention */ #define GUSB_SESSION_ACK 6 /* Unit responds that we have its attention */ #define GUSB_REQUEST_BULK 2 /* Unit requests we read from bulk pipe */ + +#endif // JEEPS_GARMINUSB_H_INCLUDED_ diff --git a/jeeps/gps.h b/jeeps/gps.h index f9e9f5484..a3701a998 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -1,5 +1,5 @@ -#ifndef gps_h -#define gps_h +#ifndef JEEPS_GPS_H_INCLUDED_ +#define JEEPS_GPS_H_INCLUDED_ #include "defs.h" #include "jeeps/gpsport.h" @@ -265,4 +265,4 @@ extern const char* gps_aviation_sym[]; extern const char* gps_16_sym[]; -#endif +#endif // JEEPS_GPS_H_INCLUDED_ diff --git a/jeeps/gpsapp.h b/jeeps/gpsapp.h index ee03d78de..12b33a211 100644 --- a/jeeps/gpsapp.h +++ b/jeeps/gpsapp.h @@ -1,5 +1,5 @@ -#ifndef gpsapp_h -#define gpsapp_h +#ifndef JEEPS_GPSAPP_H_INCLUDED_ +#define JEEPS_GPSAPP_H_INCLUDED_ #include "jeeps/gps.h" @@ -112,4 +112,4 @@ void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n); int32 GPS_Set_Baud_Rate(const char* port, int br); -#endif +#endif // JEEPS_GPSAPP_H_INCLUDED_ diff --git a/jeeps/gpscom.h b/jeeps/gpscom.h index 53ece39b7..c8cc25806 100644 --- a/jeeps/gpscom.h +++ b/jeeps/gpscom.h @@ -1,5 +1,5 @@ -#ifndef gpscom_h -#define gpscom_h +#ifndef JEEPS_GPSCOM_H_INCLUDED_ +#define JEEPS_GPSCOM_H_INCLUDED_ #include "jeeps/gps.h" @@ -44,4 +44,4 @@ int32 GPS_Command_Get_Fitness_User_Profile(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); int32 GPS_Command_Get_Workout_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); int32 GPS_Command_Get_Course_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); -#endif +#endif // JEEPS_GPSCOM_H_INCLUDED_ diff --git a/jeeps/gpsdatum.h b/jeeps/gpsdatum.h index c59f7977e..4444797dd 100644 --- a/jeeps/gpsdatum.h +++ b/jeeps/gpsdatum.h @@ -1,5 +1,5 @@ -#ifndef gpsdatum_h -#define gpsdatum_h +#ifndef JEEPS_GPSDATUM_H_INCLUDED_ +#define JEEPS_GPSDATUM_H_INCLUDED_ @@ -234,4 +234,4 @@ -#endif +#endif // JEEPS_GPSDATUM_H_INCLUDED_ diff --git a/jeeps/gpsdevice.h b/jeeps/gpsdevice.h index f893adf27..5abf56b0a 100644 --- a/jeeps/gpsdevice.h +++ b/jeeps/gpsdevice.h @@ -19,8 +19,8 @@ */ -#ifndef gpsdevice_h -#define gpsdevice_h +#ifndef JEEPS_GPSDEVICE_H_INCLUDED_ +#define JEEPS_GPSDEVICE_H_INCLUDED_ typedef struct gpsdevh gpsdevh; @@ -60,4 +60,4 @@ gps_device_op12 Write_Packet; } gps_device_ops; -#endif /* gpsdevice_h */ +#endif /* JEEPS_GPSDEVICE_H_INCLUDED_ */ diff --git a/jeeps/gpsfmt.h b/jeeps/gpsfmt.h index cbaad086d..3cf101690 100644 --- a/jeeps/gpsfmt.h +++ b/jeeps/gpsfmt.h @@ -1,5 +1,5 @@ -#ifndef gpsfmt_h -#define gpsfmt_h +#ifndef JEEPS_GPSFMT_H_INCLUDED_ +#define JEEPS_GPSFMT_H_INCLUDED_ #include "jeeps/gps.h" @@ -15,4 +15,4 @@ int32 GPS_Fmt_Print_Proximity(GPS_PWay* way, int32 n, FILE* outf); int32 GPS_Fmt_Print_Route(GPS_PWay* way, int32 n, FILE* outf); -#endif +#endif // JEEPS_GPSFMT_H_INCLUDED_ diff --git a/jeeps/gpsmath.h b/jeeps/gpsmath.h index 36d78436d..fa35c1ce0 100644 --- a/jeeps/gpsmath.h +++ b/jeeps/gpsmath.h @@ -1,5 +1,5 @@ -#ifndef gpsmath_h -#define gpsmath_h +#ifndef JEEPS_GPSMATH_H_INCLUDED_ +#define JEEPS_GPSMATH_H_INCLUDED_ #include "jeeps/gpsport.h" @@ -145,4 +145,4 @@ int32 GPS_Lookup_Datum_Index(const QString& n); const char* GPS_Math_Get_Datum_Name(int datum_index); -#endif +#endif // JEEPS_GPSMATH_H_INCLUDED_ diff --git a/jeeps/gpsmem.h b/jeeps/gpsmem.h index 5d29231e1..01038d9fa 100644 --- a/jeeps/gpsmem.h +++ b/jeeps/gpsmem.h @@ -1,5 +1,5 @@ -#ifndef gpsmem_h -#define gpsmem_h +#ifndef JEEPS_GPSMEM_H_INCLUDED_ +#define JEEPS_GPSMEM_H_INCLUDED_ #include "jeeps/gps.h" @@ -20,4 +20,4 @@ GPS_PCourse_Point GPS_Course_Point_New(); void GPS_Course_Point_Del(GPS_PCourse_Point* thys); -#endif +#endif // JEEPS_GPSMEM_H_INCLUDED_ diff --git a/jeeps/gpsport.h b/jeeps/gpsport.h index 3fac996ee..3646a3e67 100644 --- a/jeeps/gpsport.h +++ b/jeeps/gpsport.h @@ -7,9 +7,17 @@ * defs.h includes gbtypes.h before this file, just use that. */ +#ifndef JEEPS_GPSPORT_H_INCLUDED_ +#define JEEPS_GPSPORT_H_INCLUDED_ + +#include + + typedef unsigned char UC; typedef uint16_t US; typedef uint16_t uint16; typedef int16_t int16; typedef uint32_t uint32; typedef int32_t int32; + +#endif // JEEPS_GPSPORT_H_INCLUDED_ diff --git a/jeeps/gpsproj.h b/jeeps/gpsproj.h index f76814560..cbdca53df 100644 --- a/jeeps/gpsproj.h +++ b/jeeps/gpsproj.h @@ -1,5 +1,5 @@ -#ifndef gpsproj_h -#define gpsproj_h +#ifndef JEEPS_GPSPROJ_H_INCLUDED_ +#define JEEPS_GPSPROJ_H_INCLUDED_ #include "jeeps/gps.h" @@ -145,4 +145,4 @@ double* lambda, double phi0, double lambda0, double E0, double N0, double a, double b); -#endif +#endif // JEEPS_GPSPROJ_H_INCLUDED_ diff --git a/jeeps/gpsprot.h b/jeeps/gpsprot.h index e16600fdf..5a2a3cc6c 100644 --- a/jeeps/gpsprot.h +++ b/jeeps/gpsprot.h @@ -1,5 +1,5 @@ -#ifndef gpsprotocols_h -#define gpsprotocols_h +#ifndef JEEPS_GPSPROT_H_INCLUDED_ +#define JEEPS_GPSPROT_H_INCLUDED_ #ifndef COMMON #define COMMON extern @@ -90,8 +90,7 @@ US Cmnd_Transfer_Course_Points; US Cmnd_Transfer_Course_Tracks; US Cmnd_Transfer_Course_Limits; - } - ; + }; @@ -365,8 +364,7 @@ int32 prxd; int32 alma; int32 almd; - } - ; + }; US GPS_Protocol_Version_Change(US id, US version); COMMON int32 GPS_Protocol_Table_Set(US id); @@ -374,4 +372,4 @@ void GPS_Unknown_Protocol_Print(); -#endif +#endif // JEEPS_GPSPROT_H_INCLUDED_ diff --git a/jeeps/gpsread.h b/jeeps/gpsread.h index d8461ac22..6bee1e7ab 100644 --- a/jeeps/gpsread.h +++ b/jeeps/gpsread.h @@ -1,5 +1,5 @@ -#ifndef gpsread_h -#define gpsread_h +#ifndef JEEPS_GPSREAD_H_INCLUDED_ +#define JEEPS_GPSREAD_H_INCLUDED_ #include "jeeps/gps.h" @@ -8,4 +8,4 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet); bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_Packet *tra, GPS_Packet *rec); -#endif +#endif // JEEPS_GPSREAD_H_INCLUDED_ diff --git a/jeeps/gpsrqst.h b/jeeps/gpsrqst.h index ad05722d6..c97e01354 100644 --- a/jeeps/gpsrqst.h +++ b/jeeps/gpsrqst.h @@ -1,5 +1,5 @@ -#ifndef gpsrqst_h -#define gpsrqst_h +#ifndef JEEPS_GPSRQST_H_INCLUDED_ +#define JEEPS_GPSRQST_H_INCLUDED_ #include "jeeps/gps.h" @@ -8,4 +8,4 @@ int32 GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon); -#endif +#endif // JEEPS_GPSRQST_H_INCLUDED_ diff --git a/jeeps/gpssend.h b/jeeps/gpssend.h index c478e9880..3f3b12e8d 100644 --- a/jeeps/gpssend.h +++ b/jeeps/gpssend.h @@ -1,5 +1,5 @@ -#ifndef gpssend_h -#define gpssend_h +#ifndef JEEPS_GPSSEND_H_INCLUDED_ +#define JEEPS_GPSSEND_H_INCLUDED_ #include "jeeps/gps.h" @@ -12,4 +12,4 @@ void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32 n); -#endif +#endif // JEEPS_GPSSEND_H_INCLUDED_ diff --git a/jeeps/gpsserial.h b/jeeps/gpsserial.h index f5eba487d..c960234d3 100644 --- a/jeeps/gpsserial.h +++ b/jeeps/gpsserial.h @@ -1,5 +1,5 @@ -#ifndef gpsserial_h -#define gpsserial_h +#ifndef JEEPS_GPSSERIAL_H_INCLUDED_ +#define JEEPS_GPSSERIAL_H_INCLUDED_ #include "jeeps/gps.h" @@ -24,4 +24,4 @@ int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br); -#endif +#endif // JEEPS_GPSSERIAL_H_INCLUDED_ diff --git a/jeeps/gpsusbcommon.h b/jeeps/gpsusbcommon.h index d17456799..22f587f1a 100644 --- a/jeeps/gpsusbcommon.h +++ b/jeeps/gpsusbcommon.h @@ -19,6 +19,9 @@ */ +#ifndef JEEPS_GPSUSBCOMMON_H_INCLUDED_ +#define JEEPS_GPSUSBCOMMON_H_INCLUDED_ + /* * The 'low level ops' are registered by the OS layer (win32, libusb, etc.) * to provide gruntwork features for the common USB layer. @@ -43,3 +46,4 @@ void gusb_list_units(); /* Provided by the OS layers */ // int gusb_init(const char *portname, gpsdev **dh); +#endif // JEEPS_GPSUSBCOMMON_H_INCLUDED_ diff --git a/jeeps/gpsusbint.h b/jeeps/gpsusbint.h index cba2bee1c..2e557d1c5 100644 --- a/jeeps/gpsusbint.h +++ b/jeeps/gpsusbint.h @@ -21,7 +21,11 @@ */ +#ifndef JEEPS_GPSUSBINT_H_INCLUDED_ +#define JEEPS_GPSUSBINT_H_INCLUDED_ + int32 GPS_Packet_Read_usb(gpsdevh* fd, GPS_Packet* packet, int eatbulk); -void GPS_Make_Packet_usb(GPS_Packet* packet, UC type, UC* data, int16 n); int32 GPS_Write_Packet_usb(gpsdevh* fd, const GPS_Packet& packet); +#endif // JEEPS_GPSUSBINT_H_INCLUDED_ + diff --git a/jeeps/jgpsutil.cc b/jeeps/gpsutil.cc similarity index 100% rename from jeeps/jgpsutil.cc rename to jeeps/gpsutil.cc diff --git a/jeeps/gpsutil.h b/jeeps/gpsutil.h index 55ec8b0ba..212742833 100644 --- a/jeeps/gpsutil.h +++ b/jeeps/gpsutil.h @@ -1,5 +1,5 @@ -#ifndef gpsutil_h -#define gpsutil_h +#ifndef JEEPS_GPSUTIL_H_INCLUDED_ +#define JEEPS_GPSUTIL_H_INCLUDED_ #include "jeeps/gps.h" @@ -37,4 +37,4 @@ void GPS_Disable_Diagnose(); -#endif +#endif // JEEPS_GPSUTIL_H_INCLUDED_ From 93511ca9aea8ce871dff3553feee749848826a6a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 15 Nov 2023 07:27:00 -0700 Subject: [PATCH 038/132] use c++11 fixed width integer types in jeeps. (#1217) * use c++11 fixed width integer types in jeeps. thanks resharper! * fix fixed width integers resharper missed. in non windows code. --- CMakeSettings.json | 26 ++ garmin.cc | 8 +- jeeps/gps.h | 76 ++--- jeeps/gpsapp.cc | 754 ++++++++++++++++++++--------------------- jeeps/gpsapp.h | 90 ++--- jeeps/gpscom.cc | 125 +++---- jeeps/gpscom.h | 54 +-- jeeps/gpsdevice.cc | 16 +- jeeps/gpsdevice.h | 26 +- jeeps/gpsdevice_usb.cc | 6 +- jeeps/gpsfmt.h | 10 +- jeeps/gpsmath.cc | 168 ++++----- jeeps/gpsmath.h | 72 ++-- jeeps/gpsmem.cc | 2 +- jeeps/gpsport.h | 4 - jeeps/gpsprot.cc | 12 +- jeeps/gpsprot.h | 118 +++---- jeeps/gpsread.cc | 4 +- jeeps/gpsread.h | 2 +- jeeps/gpsrqst.cc | 14 +- jeeps/gpsrqst.h | 4 +- jeeps/gpssend.cc | 6 +- jeeps/gpssend.h | 4 +- jeeps/gpsserial.cc | 66 ++-- jeeps/gpsserial.h | 16 +- jeeps/gpsusbint.h | 4 +- jeeps/gpsusbread.cc | 6 +- jeeps/gpsusbsend.cc | 2 +- jeeps/gpsutil.cc | 74 ++-- jeeps/gpsutil.h | 16 +- xcsv.cc | 2 +- 31 files changed, 905 insertions(+), 882 deletions(-) create mode 100644 CMakeSettings.json diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 000000000..8e1f10f59 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,26 @@ +{ + "configurations": [ + { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:/Qt/6.5.3/msvc2019_64", + "buildCommandArgs": "", + "ctestCommandArgs": "" + }, + { + "name": "x64-Clang-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:/Qt/6.5.3/msvc2019_64 -DCMAKE_VERBOSE_MAKEFILE=ON", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "clang_cl_x64_x64" ] + } + ] +} \ No newline at end of file diff --git a/garmin.cc b/garmin.cc index c8ab8f234..cfe7674a0 100644 --- a/garmin.cc +++ b/garmin.cc @@ -535,7 +535,7 @@ track_read() } - int32 ntracks = GPS_Command_Get_Track(portname, &array, waypt_read_cb); + int32_t ntracks = GPS_Command_Get_Track(portname, &array, waypt_read_cb); if (ntracks <= 0) { return; @@ -613,7 +613,7 @@ route_read() */ route_head* rte_head = nullptr; - int32 nroutepts = GPS_Command_Get_Route(portname, &array); + int32_t nroutepts = GPS_Command_Get_Route(portname, &array); // fprintf(stderr, "Routes %d\n", (int) nroutepts); #if 1 @@ -974,7 +974,7 @@ waypoint_write() { int n = waypoint_prepare(); - if (int32 ret = GPS_Command_Send_Waypoint(portname, tx_waylist, n, waypt_write_cb); ret < 0) { + if (int32_t ret = GPS_Command_Send_Waypoint(portname, tx_waylist, n, waypt_write_cb); ret < 0) { fatal(MYNAME ":communication error sending waypoints..\n"); } @@ -1103,7 +1103,7 @@ track_waypt_pr(const Waypoint* wpt) static int track_prepare() { - int32 n = track_waypt_count() + track_count(); + int32_t n = track_waypt_count() + track_count(); tx_tracklist = (GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack)); cur_tx_tracklist_entry = tx_tracklist; diff --git a/jeeps/gps.h b/jeeps/gps.h index a3701a998..7dd742c2a 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -20,17 +20,17 @@ #define ETX 0x03 -extern int32 gps_errno; -extern int32 gps_warning; -extern int32 gps_error; -extern int32 gps_user; -extern int32 gps_show_bytes; +extern int32_t gps_errno; +extern int32_t gps_warning; +extern int32_t gps_error; +extern int32_t gps_user; +extern int32_t gps_show_bytes; extern char gps_categories[16][17]; struct GPS_Packet { US type{0}; - uint32 n{0}; + uint32_t n{0}; UC data[MAX_GPS_PACKET_SIZE]{}; }; @@ -51,7 +51,7 @@ typedef struct GPS_SPvt_Data_Type { float epe; float eph; float epv; - int16 fix; + int16_t fix; double tow; double lat; double lon; @@ -59,8 +59,8 @@ typedef struct GPS_SPvt_Data_Type { float north; float up; float msl_hght; - int16 leap_scnds; - int32 wn_days; + int16_t leap_scnds; + int32_t wn_days; } GPS_OPvt_Data, *GPS_PPvt_Data; @@ -79,8 +79,8 @@ typedef struct GPS_STrack { unsigned int tnew:1; /* New track? */ unsigned int ishdr:1; /* Track header? */ unsigned int no_latlon:1; /* True if no valid lat/lon found. */ - int32 dspl; /* Display on map? */ - int32 colour; /* Colour */ + int32_t dspl; /* Display on map? */ + int32_t colour; /* Colour */ float distance; /* distance traveled in meters.*/ int distance_populated; /* True if above is valid. */ char trk_ident[256]; /* Track identifier */ @@ -91,7 +91,7 @@ GPS_OTrack, *GPS_PTrack; typedef struct GPS_SAlmanac { UC svid; - int16 wn; + int16_t wn; float toa; float af0; float af1; @@ -112,12 +112,12 @@ typedef struct GPS_SWay { double lon; char cmnt[256]; float dst; - int32 smbl; - int32 dspl; + int32_t smbl; + int32_t dspl; char wpt_ident[256]; char lnk_ident[256]; UC subclass[18]; - int32 colour; + int32_t colour; char cc[2]; UC wpt_class; UC alt_is_unknown; @@ -128,17 +128,17 @@ typedef struct GPS_SWay { char facility[32]; char addr[52]; char cross_road[52]; - int32 attr; + int32_t attr; float dpth; - int32 idx; - int32 prot; - int32 isrte; - int32 rte_prot; + int32_t idx; + int32_t prot; + int32_t isrte; + int32_t rte_prot; UC rte_num; char rte_cmnt[20]; char rte_ident[256]; - int32 islink; - int32 rte_link_class; + int32_t islink; + int32_t rte_link_class; char rte_link_subclass[18]; char rte_link_ident[256]; @@ -146,7 +146,7 @@ typedef struct GPS_SWay { time_t time; /* Unix time */ char temperature_populated; float temperature; /* Degrees celsius. */ - uint16 category; + uint16_t category; } GPS_OWay, *GPS_PWay; @@ -154,16 +154,16 @@ typedef struct GPS_SWay { * Forerunner/Edge Lap data. */ typedef struct GPS_SLap { - uint32 index; /* unique index in device or -1 */ + uint32_t index; /* unique index in device or -1 */ time_t start_time; - uint32 total_time; /* Hundredths of a second */ + uint32_t total_time; /* Hundredths of a second */ float total_distance; /* In meters */ double begin_lat; double begin_lon; double end_lat; double end_lon; - int16 calories; - uint32 track_index; /* ref to track or -1 */ + int16_t calories; + uint32_t track_index; /* ref to track or -1 */ float max_speed; /* In meters per second */ unsigned char avg_heart_rate; /* In beats-per-minute, 0 if invalid */ unsigned char max_heart_rate; /* In beats-per-minute, 0 if invalid */ @@ -179,17 +179,17 @@ typedef struct GPS_SLap { typedef struct GPS_SCourse { - uint32 index; /* Unique among courses on device */ + uint32_t index; /* Unique among courses on device */ char course_name[16]; /* Null-terminated unique course name */ - uint32 track_index; /* Index of the associated track + uint32_t track_index; /* Index of the associated track * Must be 0xFFFFFFFF if there is none*/ } GPS_OCourse, *GPS_PCourse; typedef struct GPS_SCourse_Lap { - uint32 course_index; /* Index of associated course */ - uint32 lap_index; /* This lap's index in the course */ - uint32 total_time; /* In hundredths of a second */ + uint32_t course_index; /* Index of associated course */ + uint32_t lap_index; /* This lap's index in the course */ + uint32_t total_time; /* In hundredths of a second */ float total_dist; /* [m] */ double begin_lat; /* Starting position of the lap */ double begin_lon; /* Invalid if lat,lon are 0x7FFFFFFF.*/ @@ -204,7 +204,7 @@ typedef struct GPS_SCourse_Lap { typedef struct GPS_SCourse_Point { char name[11]; /* Null-terminated name */ - uint32 course_index; /* Index of associated course */ + uint32_t course_index; /* Index of associated course */ time_t track_point_time; /* Time */ UC point_type; /* generic = 0, * summit = 1, @@ -225,10 +225,10 @@ typedef struct GPS_SCourse_Point { } GPS_OCourse_Point, *GPS_PCourse_Point; typedef struct GPS_SCourse_Limits { - int32 max_courses; - int32 max_course_laps; - int32 max_course_pnt; - int32 max_course_trk_pnt; + int32_t max_courses; + int32_t max_course_laps; + int32_t max_course_pnt; + int32_t max_course_trk_pnt; } GPS_OCourse_Limits, *GPS_PCourse_Limits; @@ -249,7 +249,7 @@ using pcb_fn = int (*)(int, GPS_SWay**); extern time_t gps_save_time; extern double gps_save_lat; extern double gps_save_lon; -extern int32 gps_save_id; +extern int32_t gps_save_id; extern double gps_save_version; extern char gps_save_string[GPS_ARB_LEN]; extern int gps_is_usb; diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index c66ad672c..43312fe37 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -46,7 +46,7 @@ double gps_save_lon; #define XMIN(a,b) (a < b? a : b) -static int32 GPS_A000(const char* port); +static int32_t GPS_A000(const char* port); static void GPS_A001(const GPS_Packet& packet); @@ -72,21 +72,21 @@ static void GPS_D152_Get(GPS_PWay* way, UC* s); static void GPS_D154_Get(GPS_PWay* way, UC* s); static void GPS_D155_Get(GPS_PWay* way, UC* s); -static void GPS_D100_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D101_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D102_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D103_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D104_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D105_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D106_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D107_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D108_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D109_Send(UC* data, GPS_PWay way, int32* len, int protoid); -static void GPS_D150_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D151_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D152_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D154_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D155_Send(UC* data, GPS_PWay way, int32* len); +static void GPS_D100_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D101_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D102_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D103_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D104_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D105_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D106_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D107_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D108_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D109_Send(UC* data, GPS_PWay way, int32_t* len, int protoid); +static void GPS_D150_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D151_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D152_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D154_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D155_Send(UC* data, GPS_PWay way, int32_t* len); static void GPS_D120_Get(int cat_num, char*s); @@ -94,17 +94,17 @@ static void GPS_D200_Get(GPS_PWay* way, const UC* s); static void GPS_D201_Get(GPS_PWay* way, UC* s); static void GPS_D202_Get(GPS_PWay* way, UC* s); static void GPS_D210_Get(GPS_PWay* way, UC* s); -static void GPS_D200_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D201_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D202_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D210_Send(UC* data, GPS_PWay way, int32* len); +static void GPS_D200_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D201_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D202_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D210_Send(UC* data, GPS_PWay way, int32_t* len); static void GPS_D400_Get(GPS_PWay* way, UC* s); static void GPS_D403_Get(GPS_PWay* way, UC* s); static void GPS_D450_Get(GPS_PWay* way, UC* s); -static void GPS_D400_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D403_Send(UC* data, GPS_PWay way, int32* len); -static void GPS_D450_Send(UC* data, GPS_PWay way, int32* len); +static void GPS_D400_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D403_Send(UC* data, GPS_PWay way, int32_t* len); +static void GPS_D450_Send(UC* data, GPS_PWay way, int32_t* len); static void GPS_D500_Send(UC* data, GPS_PAlmanac alm); static void GPS_D501_Send(UC* data, GPS_PAlmanac alm); @@ -114,7 +114,7 @@ static void GPS_D551_Send(UC* data, GPS_PAlmanac alm); static UC Is_Trackpoint_Invalid(GPS_PTrack trk); -int32 gps_save_id; +int32_t gps_save_id; int gps_is_usb; double gps_save_version; char gps_save_string[GPS_ARB_LEN]; @@ -161,9 +161,9 @@ void copy_char_array(UC** dst, char* src, int count, copycase mustupper) ** ** @return [int32] 1 if success -ve if error ************************************************************************/ -int32 GPS_Init(const char* port) +int32_t GPS_Init(const char* port) { - int32 ret; + int32_t ret; (void) GPS_Util_Little(); @@ -198,13 +198,13 @@ int32 GPS_Init(const char* port) ** ** @return [int32] 1 if success -ve if error ************************************************************************/ -static int32 GPS_A000(const char* port) +static int32_t GPS_A000(const char* port) { gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int16 version; - int16 id; + int16_t version; + int16_t id; if (!GPS_Device_On(port, &fd)) { return gps_errno; @@ -387,10 +387,10 @@ static void GPS_A001(const GPS_Packet& packet) { US lasta=0; - int32 entries = packet.n / 3; + int32_t entries = packet.n / 3; const UC* p = packet.data; - for (int32 i=0; ilat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1249,7 +1249,7 @@ static void GPS_D100_Get(GPS_PWay* way, UC* s) static void GPS_D101_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1259,12 +1259,12 @@ static void GPS_D101_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1292,7 +1292,7 @@ static void GPS_D101_Get(GPS_PWay* way, UC* s) static void GPS_D102_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1302,12 +1302,12 @@ static void GPS_D102_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1336,7 +1336,7 @@ static void GPS_D102_Get(GPS_PWay* way, UC* s) static void GPS_D103_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1346,12 +1346,12 @@ static void GPS_D103_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1378,7 +1378,7 @@ static void GPS_D103_Get(GPS_PWay* way, UC* s) static void GPS_D104_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1388,12 +1388,12 @@ static void GPS_D104_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1403,7 +1403,7 @@ static void GPS_D104_Get(GPS_PWay* way, UC* s) p+=sizeof(float); (*way)->smbl = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); (*way)->dspl = *p; @@ -1431,13 +1431,13 @@ static void GPS_D105_Get(GPS_PWay* way, UC* s) (*way)->prot = 105; (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->smbl = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); q = (UC*)(*way)->wpt_ident; while ((*q++ = *p++)); @@ -1460,7 +1460,7 @@ void GPS_D106_Get(GPS_PWay* way, UC* s) { UC* p; UC* q; - int32 i; + int32_t i; p=s; @@ -1473,13 +1473,13 @@ void GPS_D106_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->smbl = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); q = (UC*)(*way)->wpt_ident; while ((*q++ = *p++)); @@ -1503,7 +1503,7 @@ void GPS_D106_Get(GPS_PWay* way, UC* s) static void GPS_D107_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1513,12 +1513,12 @@ static void GPS_D107_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1551,7 +1551,7 @@ static void GPS_D108_Get(GPS_PWay* way, UC* s) UC* p; UC* q; - int32 i; + int32_t i; p=s; @@ -1562,16 +1562,16 @@ static void GPS_D108_Get(GPS_PWay* way, UC* s) (*way)->dspl = *p++; (*way)->attr = *p++; (*way)->smbl = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<18; ++i) { (*way)->subclass[i] = *p++; } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->alt = GPS_Util_Get_Float(p); p+=sizeof(float); @@ -1625,7 +1625,7 @@ static void GPS_D109_Get(GPS_PWay* way, UC* s, int protoid) UC* p; UC* q; - int32 i; + int32_t i; p=s; @@ -1637,16 +1637,16 @@ static void GPS_D109_Get(GPS_PWay* way, UC* s, int protoid) (*way)->dspl = (*p++ >> 5) & 3; (*way)->attr = *p++; (*way)->smbl = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<18; ++i) { (*way)->subclass[i] = *p++; } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->alt = GPS_Util_Get_Float(p); p+=sizeof(float); @@ -1672,7 +1672,7 @@ static void GPS_D109_Get(GPS_PWay* way, UC* s, int protoid) (*way)->temperature = gps_temp; } - uint32 gps_time = GPS_Util_Get_Uint(p); + uint32_t gps_time = GPS_Util_Get_Uint(p); p+=4; /* The spec says that 0xffffffff is unknown, but the 60CSX with * firmware 2.5.0 writes zero. @@ -1719,7 +1719,7 @@ static void GPS_D109_Get(GPS_PWay* way, UC* s, int protoid) static void GPS_D150_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1733,13 +1733,13 @@ static void GPS_D150_Get(GPS_PWay* way, UC* s) (*way)->wpt_class = *p++; (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->alt = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<24; ++i) { (*way)->city[i] = *p++; @@ -1771,7 +1771,7 @@ static void GPS_D150_Get(GPS_PWay* way, UC* s) static void GPS_D151_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1781,12 +1781,12 @@ static void GPS_D151_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1806,7 +1806,7 @@ static void GPS_D151_Get(GPS_PWay* way, UC* s) } (*way)->alt = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<2; ++i) { (*way)->cc[i] = *p++; @@ -1833,7 +1833,7 @@ static void GPS_D151_Get(GPS_PWay* way, UC* s) static void GPS_D152_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1843,12 +1843,12 @@ static void GPS_D152_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1868,7 +1868,7 @@ static void GPS_D152_Get(GPS_PWay* way, UC* s) } (*way)->alt = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<2; ++i) { (*way)->cc[i] = *p++; @@ -1894,7 +1894,7 @@ static void GPS_D152_Get(GPS_PWay* way, UC* s) static void GPS_D154_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1904,12 +1904,12 @@ static void GPS_D154_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1929,7 +1929,7 @@ static void GPS_D154_Get(GPS_PWay* way, UC* s) } (*way)->alt = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<2; ++i) { (*way)->cc[i] = *p++; @@ -1957,7 +1957,7 @@ static void GPS_D154_Get(GPS_PWay* way, UC* s) static void GPS_D155_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -1967,12 +1967,12 @@ static void GPS_D155_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -1992,7 +1992,7 @@ static void GPS_D155_Get(GPS_PWay* way, UC* s) } (*way)->alt = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<2; ++i) { (*way)->cc[i] = *p++; @@ -2003,7 +2003,7 @@ static void GPS_D155_Get(GPS_PWay* way, UC* s) (*way)->wpt_class = *p++; (*way)->smbl = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); (*way)->dspl = *p; @@ -2048,7 +2048,7 @@ void GPS_D120_Get(int cat_num, char* s) ** ** @return [void] ************************************************************************/ -static void GPS_D100_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D100_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; @@ -2056,11 +2056,11 @@ static void GPS_D100_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); *len = 58; @@ -2079,7 +2079,7 @@ static void GPS_D100_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D101_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D101_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; @@ -2087,11 +2087,11 @@ static void GPS_D101_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); @@ -2116,7 +2116,7 @@ static void GPS_D101_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D102_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D102_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; @@ -2124,11 +2124,11 @@ static void GPS_D102_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); GPS_Util_Put_Float(p,way->dst); @@ -2152,7 +2152,7 @@ static void GPS_D102_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D103_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D103_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; @@ -2161,11 +2161,11 @@ static void GPS_D103_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); *p++ = (UC) way->smbl; @@ -2187,7 +2187,7 @@ static void GPS_D103_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D104_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D104_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; @@ -2195,11 +2195,11 @@ static void GPS_D104_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); /* byonke confirms that sending lower case comment data to a III+ * results in the comment being truncated there. So we uppercase * the entire comment. @@ -2209,8 +2209,8 @@ static void GPS_D104_Send(UC* data, GPS_PWay way, int32* len) GPS_Util_Put_Float(p,way->dst); p+= sizeof(float); - GPS_Util_Put_Short(p, (int16) way->smbl); - p+=sizeof(int16); + GPS_Util_Put_Short(p, (int16_t) way->smbl); + p+=sizeof(int16_t); *p = 3; /* display symbol with waypoint name */ @@ -2230,7 +2230,7 @@ static void GPS_D104_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D105_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D105_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; UC* q; @@ -2238,12 +2238,12 @@ static void GPS_D105_Send(UC* data, GPS_PWay way, int32* len) p = data; GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); - GPS_Util_Put_Short(p, (int16) way->smbl); - p+=sizeof(int16); + GPS_Util_Put_Short(p, (int16_t) way->smbl); + p+=sizeof(int16_t); q = (UC*) way->wpt_ident; while ((*p++ = *q++)); @@ -2265,11 +2265,11 @@ static void GPS_D105_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D106_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D106_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; UC* q; - int32 i; + int32_t i; p = data; @@ -2278,12 +2278,12 @@ static void GPS_D106_Send(UC* data, GPS_PWay way, int32* len) *p++ = way->subclass[i]; } GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); - GPS_Util_Put_Short(p, (int16) way->smbl); - p+=sizeof(int16); + GPS_Util_Put_Short(p, (int16_t) way->smbl); + p+=sizeof(int16_t); q = (UC*) way->wpt_ident; while ((*p++ = *q++)); @@ -2306,7 +2306,7 @@ static void GPS_D106_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D107_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D107_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; @@ -2314,11 +2314,11 @@ static void GPS_D107_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); *p++ = way->smbl; @@ -2346,12 +2346,12 @@ static void GPS_D107_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D108_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D108_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; UC* q; - int32 i; + int32_t i; p = data; @@ -2360,14 +2360,14 @@ static void GPS_D108_Send(UC* data, GPS_PWay way, int32* len) *p++ = way->dspl; *p++ = 0x60; GPS_Util_Put_Short(p,(US) way->smbl); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<18; ++i) { *p++ = way->subclass[i]; } GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); if (way->alt_is_unknown) { GPS_Util_Put_Float(p, 1.0e25f); @@ -2424,12 +2424,12 @@ static void GPS_D108_Send(UC* data, GPS_PWay way, int32* len) ** @return [void] ** D109's and D110's are so similar, we handle them with the same code. ************************************************************************/ -static void GPS_D109_Send(UC* data, GPS_PWay way, int32* len, int protoid) +static void GPS_D109_Send(UC* data, GPS_PWay way, int32_t* len, int protoid) { UC* p; UC* q; - int32 i; + int32_t i; p = data; @@ -2446,14 +2446,14 @@ static void GPS_D109_Send(UC* data, GPS_PWay way, int32* len, int protoid) GPS_Warning("Unknown protoid in GPS_D109_Send."); } GPS_Util_Put_Short(p,(US) way->smbl); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<18; ++i) { *p++ = way->subclass[i]; } GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); if (way->alt_is_unknown) { GPS_Util_Put_Float(p, 1.0e25f); } else { @@ -2482,7 +2482,7 @@ static void GPS_D109_Send(UC* data, GPS_PWay way, int32* len, int protoid) if (way->time_populated) { GPS_Util_Put_Uint(p,GPS_Math_Utime_To_Gtime(way->time)); - p+=sizeof(uint32); + p+=sizeof(uint32_t); } else { for (i=0; i<4; ++i) { *p++ = 0xff; /* unknown time*/ @@ -2526,10 +2526,10 @@ static void GPS_D109_Send(UC* data, GPS_PWay way, int32* len, int protoid) ** ** @return [void] ************************************************************************/ -static void GPS_D150_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D150_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; - int32 i; + int32_t i; p = data; @@ -2544,12 +2544,12 @@ static void GPS_D150_Send(UC* data, GPS_PWay way, int32* len) *p++ = way->wpt_class; GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Short(p,(US) way->alt); - p+=sizeof(int16); + p+=sizeof(int16_t); copy_char_array(&p, way->city, 24, UpperYes); copy_char_array(&p, way->state, 2, UpperYes); @@ -2572,21 +2572,21 @@ static void GPS_D150_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D151_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D151_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; - int32 i; + int32_t i; p = data; copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); GPS_Util_Put_Float(p,way->dst); p+=sizeof(float); @@ -2596,7 +2596,7 @@ static void GPS_D151_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->state, 2, UpperYes); GPS_Util_Put_Short(p,(US) way->alt); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<2; ++i) { *p++ = way->cc[i]; @@ -2625,21 +2625,21 @@ static void GPS_D151_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D152_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D152_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; - int32 i; + int32_t i; p = data; copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); GPS_Util_Put_Float(p,way->dst); p+=sizeof(float); @@ -2649,7 +2649,7 @@ static void GPS_D152_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->state, 2, UpperYes); GPS_Util_Put_Short(p,(US) way->alt); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<2; ++i) { *p++ = way->cc[i]; @@ -2677,21 +2677,21 @@ static void GPS_D152_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D154_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D154_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; - int32 i; + int32_t i; p = data; copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); GPS_Util_Put_Float(p,way->dst); @@ -2702,7 +2702,7 @@ static void GPS_D154_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->state, 2, UpperYes); GPS_Util_Put_Short(p,(US) way->alt); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<2; ++i) { *p++ = way->cc[i]; @@ -2714,7 +2714,7 @@ static void GPS_D154_Send(UC* data, GPS_PWay way, int32* len) } *p++ = way->wpt_class; - GPS_Util_Put_Short(p,(int16)way->smbl); + GPS_Util_Put_Short(p,(int16_t)way->smbl); *len = 126; @@ -2733,7 +2733,7 @@ static void GPS_D154_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D155_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D155_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; @@ -2742,11 +2742,11 @@ static void GPS_D155_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->ident, 6, UpperYes); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); copy_char_array(&p, way->cmnt, 40, UpperYes); GPS_Util_Put_Float(p,way->dst); p+=sizeof(float); @@ -2756,7 +2756,7 @@ static void GPS_D155_Send(UC* data, GPS_PWay way, int32* len) copy_char_array(&p, way->state, 2, UpperYes); GPS_Util_Put_Short(p,(US) way->alt); - p+=sizeof(int16); + p+=sizeof(int16_t); copy_char_array(&p, way->cc, 2, UpperYes); *p++ = 0; @@ -2764,8 +2764,8 @@ static void GPS_D155_Send(UC* data, GPS_PWay way, int32* len) /* Ignore wpt_class; our D155 points are always user type which is "4". */ *p++ = 4; - GPS_Util_Put_Short(p,(int16)way->smbl); - p+=sizeof(int16); + GPS_Util_Put_Short(p,(int16_t)way->smbl); + p+=sizeof(int16_t); *p = way->dspl; @@ -2785,14 +2785,14 @@ static void GPS_D155_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [int32] number of waypoint entries ************************************************************************/ -int32 GPS_A200_Get(const char* port, GPS_PWay** way) +int32_t GPS_A200_Get(const char* port, GPS_PWay** way) { static UC data[2]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 n; - int32 i; + int32_t n; + int32_t i; if (!GPS_Device_On(port,&fd)) { @@ -2957,14 +2957,14 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way) ** ** @return [int32] number of waypoint entries ************************************************************************/ -int32 GPS_A201_Get(const char* port, GPS_PWay** way) +int32_t GPS_A201_Get(const char* port, GPS_PWay** way) { static UC data[2]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 n; - int32 i; + int32_t n; + int32_t i; if (!GPS_Device_On(port,&fd)) { @@ -3146,14 +3146,14 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A200_Send(const char* port, GPS_PWay* way, int32 n) +int32_t GPS_A200_Send(const char* port, GPS_PWay* way, int32_t n) { UC data[GPS_ARB_LEN]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; + int32_t i; + int32_t len; US method; if (!GPS_Device_On(port,&fd)) { @@ -3285,14 +3285,14 @@ int32 GPS_A200_Send(const char* port, GPS_PWay* way, int32 n) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A201_Send(const char* port, GPS_PWay* way, int32 n) +int32_t GPS_A201_Send(const char* port, GPS_PWay* way, int32_t n) { UC data[GPS_ARB_LEN]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; + int32_t i; + int32_t len; US method; if (!GPS_Device_On(port,&fd)) { @@ -3465,7 +3465,7 @@ static void GPS_D200_Get(GPS_PWay* way, const UC* s) static void GPS_D201_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -3524,12 +3524,12 @@ static void GPS_D210_Get(GPS_PWay* way, UC* s) { UC* p; UC* q; - int32 i; + int32_t i; p=s; (*way)->rte_link_class = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<18; ++i) { (*way)->rte_link_subclass[i] = *p++; } @@ -3551,7 +3551,7 @@ static void GPS_D210_Get(GPS_PWay* way, UC* s) ** ** @return [void] ************************************************************************/ -static void GPS_D200_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D200_Send(UC* data, GPS_PWay way, int32_t* len) { *data = way->rte_num; @@ -3572,7 +3572,7 @@ static void GPS_D200_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D201_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D201_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; @@ -3597,7 +3597,7 @@ static void GPS_D201_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D202_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D202_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; UC* q; @@ -3624,16 +3624,16 @@ static void GPS_D202_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D210_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D210_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; UC* q; - int32 i; + int32_t i; p = data; GPS_Util_Put_Short(p,(US) way->rte_link_class); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<18; ++i) { *p++ = way->rte_link_subclass[i]; } @@ -3657,15 +3657,15 @@ static void GPS_D210_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [int32] number of track entries ************************************************************************/ -int32 GPS_A300_Get(const char* port , GPS_PTrack** trk, pcb_fn /*unused*/) +int32_t GPS_A300_Get(const char* port, GPS_PTrack** trk, pcb_fn /*unused*/) { static UC data[2]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 n; - int32 i; - int32 ret; + int32_t n; + int32_t i; + int32_t ret; if (gps_trk_transfer == -1) { @@ -3791,16 +3791,16 @@ drain_run_cmd(gpsdevh* fd) ** ** @return [int32] number of track entries ************************************************************************/ -int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) +int32_t GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) { static UC data[2]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 n; - int32 i; + int32_t n; + int32_t i; US Pid_Trk_Data, Pid_Trk_Hdr, Cmnd_Transfer_Trk; - int32 trk_type, trk_hdr_type; + int32_t trk_type, trk_hdr_type; if (gps_trk_transfer == -1) { return GPS_UNSUPPORTED; @@ -3971,14 +3971,14 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A300_Send(const char* port, GPS_PTrack* trk, int32 n) +int32_t GPS_A300_Send(const char* port, GPS_PTrack* trk, int32_t n) { UC data[GPS_ARB_LEN]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; + int32_t i; + int32_t len; if (gps_trk_transfer == -1) { return GPS_UNSUPPORTED; @@ -4063,17 +4063,17 @@ int32 GPS_A300_Send(const char* port, GPS_PTrack* trk, int32 n) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A301_Send(const char* port, GPS_PTrack* trk, int32 n, int protoid, - gpsdevh* fd) +int32_t GPS_A301_Send(const char* port, GPS_PTrack* trk, int32_t n, int protoid, + gpsdevh* fd) { UC data[GPS_ARB_LEN]; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; + int32_t i; + int32_t len; US method; US Pid_Trk_Data, Pid_Trk_Hdr, Cmnd_Transfer_Trk; - int32 trk_type, trk_hdr_type; + int32_t trk_type, trk_hdr_type; if (gps_trk_transfer == -1) { return GPS_UNSUPPORTED; @@ -4202,11 +4202,11 @@ int32 GPS_A301_Send(const char* port, GPS_PTrack* trk, int32 n, int protoid, ** ** @return [int32] number of entries read ************************************************************************/ -int32 GPS_D300_Get(GPS_PTrack* trk, int32 entries, gpsdevh* fd) +int32_t GPS_D300_Get(GPS_PTrack* trk, int32_t entries, gpsdevh* fd) { GPS_Packet tra; GPS_Packet rec; - int32 i; + int32_t i; for (i=0; ilat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*trk)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); t = GPS_Util_Get_Uint(p); if (!t || t==0x7fffffff || t==0xffffffff) { @@ -4285,7 +4285,7 @@ void GPS_D301b_Get(GPS_PTrack* trk, UC* data) } else { (*trk)->Time = GPS_Math_Gtime_To_Utime((time_t)t); } - p+=sizeof(uint32); + p+=sizeof(uint32_t); (*trk)->alt = GPS_Util_Get_Float(p); p+=sizeof(float); @@ -4310,16 +4310,16 @@ void GPS_D301b_Get(GPS_PTrack* trk, UC* data) void GPS_D302b_Get(GPS_PTrack* trk, UC* data) { UC* p; - uint32 t; + uint32_t t; double gps_temp; p=data; (*trk)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*trk)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); t = GPS_Util_Get_Uint(p); if (!t || t==0x7fffffff || t==0xffffffff) { @@ -4327,7 +4327,7 @@ void GPS_D302b_Get(GPS_PTrack* trk, UC* data) } else { (*trk)->Time = GPS_Math_Gtime_To_Utime((time_t)t); } - p+=sizeof(uint32); + p+=sizeof(uint32_t); (*trk)->alt = GPS_Util_Get_Float(p); p+=sizeof(float); @@ -4364,8 +4364,8 @@ void GPS_D302b_Get(GPS_PTrack* trk, UC* data) void GPS_D303b_Get(GPS_PTrack* trk, UC* data) { UC* p; - uint32 t; - uint32 raw_lat, raw_lon; + uint32_t t; + uint32_t raw_lat, raw_lon; int lat_undefined, lon_undefined; p=data; @@ -4381,7 +4381,7 @@ void GPS_D303b_Get(GPS_PTrack* trk, UC* data) } else { (*trk)->lat = GPS_Math_Semi_To_Deg(raw_lat); } - p+=sizeof(int32); + p+=sizeof(int32_t); raw_lon = GPS_Util_Get_Int(p); lon_undefined = !raw_lon || raw_lon==0x7fffffff || raw_lon==0xffffffff; @@ -4390,7 +4390,7 @@ void GPS_D303b_Get(GPS_PTrack* trk, UC* data) } else { (*trk)->lon = GPS_Math_Semi_To_Deg(raw_lon); } - p+=sizeof(int32); + p+=sizeof(int32_t); /* * Let the caller decide if it wants to toss trackpionts with only @@ -4411,7 +4411,7 @@ void GPS_D303b_Get(GPS_PTrack* trk, UC* data) } else { (*trk)->Time = GPS_Math_Gtime_To_Utime((time_t)t); } - p+=sizeof(uint32); + p+=sizeof(uint32_t); (*trk)->alt = GPS_Util_Get_Float(p); p+=sizeof(float); @@ -4502,7 +4502,7 @@ void GPS_D311_Get(GPS_PTrack* trk, UC* s) ** ** @return [void] ************************************************************************/ -void GPS_D300_Send(UC* data, GPS_PTrack trk, int32* len) +void GPS_D300_Send(UC* data, GPS_PTrack trk, int32_t* len) { UC* p; @@ -4527,7 +4527,7 @@ void GPS_D300_Send(UC* data, GPS_PTrack trk, int32* len) ** ** @return [void] ************************************************************************/ -void GPS_D301_Send(UC* data, GPS_PTrack trk, int32* len, int type) +void GPS_D301_Send(UC* data, GPS_PTrack trk, int32_t* len, int type) { UC* p; @@ -4566,7 +4566,7 @@ void GPS_D301_Send(UC* data, GPS_PTrack trk, int32* len, int type) ** ** @return [void] ************************************************************************/ -void GPS_D303_Send(UC* data, GPS_PTrack trk, int32* len, int protoid) +void GPS_D303_Send(UC* data, GPS_PTrack trk, int32_t* len, int protoid) { UC* p; @@ -4606,7 +4606,7 @@ void GPS_D303_Send(UC* data, GPS_PTrack trk, int32* len, int protoid) ** ** @return [void] ************************************************************************/ -void GPS_D311_Send(UC* data, GPS_PTrack trk, int32* len) +void GPS_D311_Send(UC* data, GPS_PTrack trk, int32_t* len) { UC* p; @@ -4626,7 +4626,7 @@ void GPS_D311_Send(UC* data, GPS_PTrack trk, int32* len) ** ** @return [void] ************************************************************************/ -void GPS_D310_Send(UC* data, GPS_PTrack trk, int32* len) +void GPS_D310_Send(UC* data, GPS_PTrack trk, int32_t* len) { UC* p; UC* q; @@ -4655,15 +4655,15 @@ void GPS_D310_Send(UC* data, GPS_PTrack trk, int32* len) static void GPS_A300_Translate(UC* s, GPS_PTrack* trk) { UC* p; - uint32 t; + uint32_t t; p=s; (*trk)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*trk)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); t = GPS_Util_Get_Uint(p); if (!t || t==0x7fffffff || t==0xffffffff) { @@ -4671,7 +4671,7 @@ static void GPS_A300_Translate(UC* s, GPS_PTrack* trk) } else { (*trk)->Time = GPS_Math_Gtime_To_Utime((time_t)t); } - p+=sizeof(uint32); + p+=sizeof(uint32_t); (*trk)->tnew = *p; } @@ -4697,13 +4697,13 @@ static void GPS_A300_Encode(UC* s, GPS_PTrack trk) * caller shouldn't set no_latlon unless one of these protocols actually * is in use */ GPS_Util_Put_Int(p,trk->no_latlon ? 0x7fffffff : GPS_Math_Deg_To_Semi(trk->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,trk->no_latlon ? 0x7fffffff : GPS_Math_Deg_To_Semi(trk->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,GPS_Math_Utime_To_Gtime(trk->Time)); - p+=sizeof(uint32); + p+=sizeof(uint32_t); *p = (UC) trk->tnew; } @@ -4719,14 +4719,14 @@ static void GPS_A300_Encode(UC* s, GPS_PTrack trk) ** ** @return [int32] number of waypoint entries ************************************************************************/ -int32 GPS_A400_Get(const char* port, GPS_PWay** way) +int32_t GPS_A400_Get(const char* port, GPS_PWay** way) { static UC data[2]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 n; - int32 i; + int32_t n; + int32_t i; if (gps_prx_waypt_transfer == -1) { return GPS_UNSUPPORTED; @@ -4880,14 +4880,14 @@ int32 GPS_A400_Get(const char* port, GPS_PWay** way) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A400_Send(const char* port, GPS_PWay* way, int32 n) +int32_t GPS_A400_Send(const char* port, GPS_PWay* way, int32_t n) { UC data[GPS_ARB_LEN]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; + int32_t i; + int32_t len; if (gps_prx_waypt_transfer == -1) { return GPS_UNSUPPORTED; @@ -5004,7 +5004,7 @@ int32 GPS_A400_Send(const char* port, GPS_PWay* way, int32 n) static void GPS_D400_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -5014,12 +5014,12 @@ static void GPS_D400_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -5041,7 +5041,7 @@ static void GPS_D400_Get(GPS_PWay* way, UC* s) static void GPS_D403_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; @@ -5051,12 +5051,12 @@ static void GPS_D403_Get(GPS_PWay* way, UC* s) } (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { (*way)->cmnt[i] = *p++; @@ -5081,14 +5081,14 @@ static void GPS_D403_Get(GPS_PWay* way, UC* s) static void GPS_D450_Get(GPS_PWay* way, UC* s) { UC* p; - int32 i; + int32_t i; p=s; (*way)->prot = 450; (*way)->idx = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<6; ++i) { (*way)->ident[i] = *p++; @@ -5099,13 +5099,13 @@ static void GPS_D450_Get(GPS_PWay* way, UC* s) (*way)->wpt_class = *p++; (*way)->lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*way)->alt = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<24; ++i) { (*way)->city[i] = *p++; @@ -5134,10 +5134,10 @@ static void GPS_D450_Get(GPS_PWay* way, UC* s) ** ** @return [void] ************************************************************************/ -static void GPS_D400_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D400_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; - int32 i; + int32_t i; p = data; @@ -5145,11 +5145,11 @@ static void GPS_D400_Send(UC* data, GPS_PWay way, int32* len) *p++ = way->ident[i]; } GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { *p++ = way->cmnt[i]; } @@ -5170,10 +5170,10 @@ static void GPS_D400_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D403_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D403_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; - int32 i; + int32_t i; p = data; @@ -5181,11 +5181,11 @@ static void GPS_D403_Send(UC* data, GPS_PWay way, int32* len) *p++ = way->ident[i]; } GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Uint(p,0); - p+=sizeof(int32); + p+=sizeof(int32_t); for (i=0; i<40; ++i) { *p++ = way->cmnt[i]; } @@ -5209,15 +5209,15 @@ static void GPS_D403_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [void] ************************************************************************/ -static void GPS_D450_Send(UC* data, GPS_PWay way, int32* len) +static void GPS_D450_Send(UC* data, GPS_PWay way, int32_t* len) { UC* p; - int32 i; + int32_t i; p = data; GPS_Util_Put_Short(p,(US) way->idx); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<6; ++i) { *p++ = way->ident[i]; @@ -5228,12 +5228,12 @@ static void GPS_D450_Send(UC* data, GPS_PWay way, int32* len) *p++ = way->wpt_class; GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(way->lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Short(p,(US) way->alt); - p+=sizeof(int16); + p+=sizeof(int16_t); for (i=0; i<24; ++i) { *p++ = way->city[i]; @@ -5265,13 +5265,13 @@ static void GPS_D450_Send(UC* data, GPS_PWay way, int32* len) ** ** @return [int32] number of almanac entries ************************************************************************/ -int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm) +int32_t GPS_A500_Get(const char* port, GPS_PAlmanac** alm) { static UC data[2]; gpsdevh* fd; GPS_Packet trapkt; GPS_Packet recpkt; - int32 i, n; + int32_t i, n; if (gps_almanac_transfer == -1) { return GPS_UNSUPPORTED; @@ -5377,17 +5377,17 @@ int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n) +int32_t GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32_t n) { UC data[GPS_ARB_LEN]; gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; - int32 timesent; - int32 posnsent; - int32 ret; + int32_t i; + int32_t len; + int32_t timesent; + int32_t posnsent; + int32_t ret; if (!GPS_Device_On(port, &fd)) { return gps_errno; @@ -5556,7 +5556,7 @@ static void GPS_A500_Translate(UC* s, GPS_PAlmanac* alm) p=s; (*alm)->wn = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); (*alm)->toa = GPS_Util_Get_Float(p); p+=sizeof(float); @@ -5686,7 +5686,7 @@ static void GPS_A500_Encode(UC* s, GPS_PAlmanac alm) p=s; GPS_Util_Put_Short(p,alm->wn); - p+=sizeof(int16); + p+=sizeof(int16_t); GPS_Util_Put_Float(p,alm->toa); p+=sizeof(float); @@ -5786,13 +5786,13 @@ time_t GPS_A600_Get(const char* port) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A600_Send(const char* port, time_t Time) +int32_t GPS_A600_Send(const char* port, time_t Time) { gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32 posnsent=0; - int32 ret=0; + int32_t posnsent = 0; + int32_t ret = 0; if (!GPS_Device_On(port, &fd)) { return gps_errno; @@ -5878,9 +5878,9 @@ time_t GPS_D600_Get(const GPS_Packet& packet) ts.tm_mon = *p++ - 1; ts.tm_mday = *p++; - ts.tm_year = (int32) GPS_Util_Get_Short(p) - 1900; + ts.tm_year = (int32_t) GPS_Util_Get_Short(p) - 1900; p+=2; - ts.tm_hour = (int32) GPS_Util_Get_Short(p); + ts.tm_hour = (int32_t) GPS_Util_Get_Short(p); p+=2; ts.tm_min = *p++; ts.tm_sec = *p++; @@ -5933,7 +5933,7 @@ void GPS_D600_Send(GPS_Packet& packet, time_t Time) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A700_Get(const char* port, double* lat, double* lon) +int32_t GPS_A700_Get(const char* port, double* lat, double* lon) { static UC data[2]; gpsdevh* fd; @@ -5991,7 +5991,7 @@ int32 GPS_A700_Get(const char* port, double* lat, double* lon) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A700_Send(const char* port, double lat, double lon) +int32_t GPS_A700_Send(const char* port, double lat, double lon) { gpsdevh* fd; GPS_Packet tra; @@ -6094,7 +6094,7 @@ void GPS_D700_Send(GPS_Packet& packet, double lat, double lon) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A800_On(const char* port, gpsdevh** fd) +int32_t GPS_A800_On(const char* port, gpsdevh** fd) { static UC data[2]; GPS_Packet tra; @@ -6131,7 +6131,7 @@ int32 GPS_A800_On(const char* port, gpsdevh** fd) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A800_Off(const char* /*unused*/, gpsdevh** fd) +int32_t GPS_A800_Off(const char* /*unused*/, gpsdevh** fd) { static UC data[2]; GPS_Packet tra; @@ -6167,7 +6167,7 @@ int32 GPS_A800_Off(const char* /*unused*/, gpsdevh** fd) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet) +int32_t GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet) { GPS_Packet tra; GPS_Packet rec; @@ -6227,7 +6227,7 @@ void GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt) p+=sizeof(float); (*pvt)->fix = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); (*pvt)->tow = GPS_Util_Get_Double(p); p+=sizeof(double); @@ -6251,7 +6251,7 @@ void GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt) p+=sizeof(float); (*pvt)->leap_scnds = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); (*pvt)->wn_days = GPS_Util_Get_Int(p); } @@ -6266,13 +6266,13 @@ void GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt) ** @return [int32] number of lap entries ************************************************************************/ -int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb) +int32_t GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb) { static UC data[2]; gpsdevh* fd; GPS_Packet trapkt; GPS_Packet recpkt; - int32 i, n; + int32_t i, n; if (gps_lap_transfer == -1) { return GPS_UNSUPPORTED; @@ -6368,7 +6368,7 @@ int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb) ************************************************************************/ void GPS_D1011b_Get(GPS_PLap* Lap, UC* p) { - uint32 t; + uint32_t t; /* Lap index (not in D906) */ switch (gps_lap_type) { @@ -6377,13 +6377,13 @@ void GPS_D1011b_Get(GPS_PLap* Lap, UC* p) break; case pD1001: (*Lap)->index = GPS_Util_Get_Uint(p); - p+=sizeof(uint32); + p+=sizeof(uint32_t); break; case pD1011: case pD1015: (*Lap)->index = GPS_Util_Get_Short(p); - p+=sizeof(uint16); - p+=sizeof(uint16); /*unused*/ + p+=sizeof(uint16_t); + p+=sizeof(uint16_t); /*unused*/ break; default: break; @@ -6391,10 +6391,10 @@ void GPS_D1011b_Get(GPS_PLap* Lap, UC* p) t = GPS_Util_Get_Uint(p); (*Lap)->start_time = GPS_Math_Gtime_To_Utime((time_t)t); - p+=sizeof(uint32); + p+=sizeof(uint32_t); (*Lap)->total_time = GPS_Util_Get_Int(p); - p+=sizeof(int32); + p+=sizeof(int32_t); (*Lap)->total_distance = GPS_Util_Get_Float(p); p+=sizeof(float); @@ -6404,16 +6404,16 @@ void GPS_D1011b_Get(GPS_PLap* Lap, UC* p) } (*Lap)->begin_lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*Lap)->begin_lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*Lap)->end_lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*Lap)->end_lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*Lap)->calories = GPS_Util_Get_Short(p); - p+=sizeof(int16); + p+=sizeof(int16_t); /* Track index, only in D906*/ if (gps_lap_type == pD906) { @@ -6478,7 +6478,7 @@ void GPS_D1011b_Get(GPS_PLap* Lap, UC* p) ** @return [int32] number of course entries ************************************************************************/ -int32 GPS_A1006_Get +int32_t GPS_A1006_Get (const char* port, GPS_PCourse** crs, pcb_fn cb) @@ -6488,7 +6488,7 @@ int32 GPS_A1006_Get gpsdevh* fd; GPS_Packet trapkt; GPS_Packet recpkt; - int32 i, n; + int32_t i, n; if (gps_course_transfer == -1) { return GPS_UNSUPPORTED; @@ -6590,16 +6590,16 @@ int32 GPS_A1006_Get ** ** @return [int32] success ************************************************************************/ -int32 GPS_A1006_Send(const char* /*unused*/, - GPS_PCourse* crs, - int32 n_crs, - gpsdevh* fd) +int32_t GPS_A1006_Send(const char* /*unused*/, + GPS_PCourse* crs, + int32_t n_crs, + gpsdevh* fd) { UC data[GPS_ARB_LEN]; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; + int32_t i; + int32_t len; GPS_Util_Put_Short(data,(US) n_crs); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, @@ -6664,13 +6664,13 @@ void GPS_D1006_Get(GPS_PCourse* crs, UC* p) { int i; (*crs)->index = GPS_Util_Get_Short(p); - p+=sizeof(uint16); - p+=sizeof(uint16); // unused + p+=sizeof(uint16_t); + p+=sizeof(uint16_t); // unused for (i=0; i<16; ++i) { (*crs)->course_name[i] = *p++; } (*crs)->track_index = GPS_Util_Get_Short(p); - p+=sizeof(uint16); + p+=sizeof(uint16_t); } @@ -6684,7 +6684,7 @@ void GPS_D1006_Get(GPS_PCourse* crs, UC* p) ** ** @return [void] ************************************************************************/ -void GPS_D1006_Send(UC* data, GPS_PCourse crs, int32* len) +void GPS_D1006_Send(UC* data, GPS_PCourse crs, int32_t* len) { UC* p; int j; @@ -6694,7 +6694,7 @@ void GPS_D1006_Send(UC* data, GPS_PCourse crs, int32* len) p += 2; GPS_Util_Put_Uint(p,0); - p+=sizeof(uint16); + p+=sizeof(uint16_t); for (j=0; j<16; ++j) { *p++ = crs->course_name[j]; @@ -6717,13 +6717,13 @@ void GPS_D1006_Send(UC* data, GPS_PCourse crs, int32* len) ** @return [int32] number of lap entries ************************************************************************/ -int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) +int32_t GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) { static UC data[2]; gpsdevh* fd; GPS_Packet trapkt; GPS_Packet recpkt; - int32 i, n; + int32_t i, n; if (gps_course_lap_transfer == -1) { return GPS_UNSUPPORTED; @@ -6825,16 +6825,16 @@ int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A1007_Send(const char* /*unused*/, - GPS_PCourse_Lap* clp, - int32 n_clp, - gpsdevh* fd) +int32_t GPS_A1007_Send(const char* /*unused*/, + GPS_PCourse_Lap* clp, + int32_t n_clp, + gpsdevh* fd) { UC data[GPS_ARB_LEN]; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; + int32_t i; + int32_t len; GPS_Util_Put_Short(data,(US) n_clp); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, @@ -6898,25 +6898,25 @@ int32 GPS_A1007_Send(const char* /*unused*/, void GPS_D1007_Get(GPS_PCourse_Lap* clp, UC* p) { (*clp)->course_index = GPS_Util_Get_Short(p); - p+=sizeof(uint16); + p+=sizeof(uint16_t); (*clp)->lap_index = GPS_Util_Get_Short(p); - p+=sizeof(uint16); + p+=sizeof(uint16_t); (*clp)->total_time = GPS_Util_Get_Int(p); - p+=sizeof(uint32); + p+=sizeof(uint32_t); (*clp)->total_dist = GPS_Util_Get_Float(p); p+=sizeof(float); (*clp)->begin_lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*clp)->begin_lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*clp)->end_lat = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*clp)->end_lon = GPS_Math_Semi_To_Deg(GPS_Util_Get_Int(p)); - p+=sizeof(int32); + p+=sizeof(int32_t); (*clp)->avg_heart_rate = *p++; (*clp)->max_heart_rate = *p++; @@ -6938,7 +6938,7 @@ void GPS_D1007_Get(GPS_PCourse_Lap* clp, UC* p) ** ** @return [void] ************************************************************************/ -void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32* len) +void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32_t* len) { UC* p; p = data; @@ -6950,20 +6950,20 @@ void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32* len) p += 2; GPS_Util_Put_Uint(p, clp->total_time); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Float(p,clp->total_dist); p+= sizeof(float); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(clp->begin_lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(clp->begin_lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(clp->end_lat)); - p+=sizeof(int32); + p+=sizeof(int32_t); GPS_Util_Put_Int(p,GPS_Math_Deg_To_Semi(clp->end_lon)); - p+=sizeof(int32); + p+=sizeof(int32_t); *p++ = clp->avg_heart_rate; @@ -6987,13 +6987,13 @@ void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32* len) ** @return [int32] number of course point entries ************************************************************************/ -int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) +int32_t GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) { static UC data[2]; gpsdevh* fd; GPS_Packet trapkt; GPS_Packet recpkt; - int32 i, n; + int32_t i, n; if (gps_course_point_transfer == -1) { return GPS_UNSUPPORTED; @@ -7096,16 +7096,16 @@ int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb) ** ** @return [int32] success ************************************************************************/ -int32 GPS_A1008_Send(const char* /*unused*/, - GPS_PCourse_Point* cpt, - int32 n_cpt, - gpsdevh* fd) +int32_t GPS_A1008_Send(const char* /*unused*/, + GPS_PCourse_Point* cpt, + int32_t n_cpt, + gpsdevh* fd) { UC data[GPS_ARB_LEN]; GPS_Packet tra; GPS_Packet rec; - int32 i; - int32 len; + int32_t i; + int32_t len; GPS_Util_Put_Short(data,(US) n_cpt); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Records, @@ -7169,19 +7169,19 @@ int32 GPS_A1008_Send(const char* /*unused*/, void GPS_D1012_Get(GPS_PCourse_Point* cpt, UC* p) { int i; - uint32 t; + uint32_t t; for (i=0; i<11; ++i) { (*cpt)->name[i] = *p++; } p++; //unused (*cpt)->course_index = GPS_Util_Get_Short(p); - p+=sizeof(uint16); - p+=sizeof(uint16); // unused + p+=sizeof(uint16_t); + p+=sizeof(uint16_t); // unused t = GPS_Util_Get_Uint(p); (*cpt)->track_point_time = GPS_Math_Gtime_To_Utime((time_t)t); - p+=sizeof(uint32); + p+=sizeof(uint32_t); (*cpt)->point_type = *p++; @@ -7198,7 +7198,7 @@ void GPS_D1012_Get(GPS_PCourse_Point* cpt, UC* p) ** ** @return [void] ************************************************************************/ -void GPS_D1012_Send(UC* data, GPS_PCourse_Point cpt, int32* len) +void GPS_D1012_Send(UC* data, GPS_PCourse_Point cpt, int32_t* len) { UC* p; int j; @@ -7215,10 +7215,10 @@ void GPS_D1012_Send(UC* data, GPS_PCourse_Point cpt, int32* len) p += 2; GPS_Util_Put_Uint(p,0); - p+=sizeof(uint16); + p+=sizeof(uint16_t); GPS_Util_Put_Uint(p,GPS_Math_Utime_To_Gtime(cpt->track_point_time)); - p+=sizeof(uint32); + p+=sizeof(uint32_t); *p++ = cpt->point_type; @@ -7236,7 +7236,7 @@ void GPS_D1012_Send(UC* data, GPS_PCourse_Point cpt, int32* len) ** @return [int32] success ************************************************************************/ -int32 GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits) +int32_t GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits) { static UC data[2]; gpsdevh* fd; @@ -7297,16 +7297,16 @@ int32 GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits) void GPS_D1013_Get(GPS_PCourse_Limits limits, UC* p) { limits->max_courses = GPS_Util_Get_Uint(p); - p+=sizeof(uint32); + p+=sizeof(uint32_t); limits->max_course_laps = GPS_Util_Get_Uint(p); - p+=sizeof(uint32); + p+=sizeof(uint32_t); limits->max_course_pnt = GPS_Util_Get_Uint(p); - p+=sizeof(uint32); + p+=sizeof(uint32_t); limits->max_course_trk_pnt = GPS_Util_Get_Uint(p); - p+=sizeof(uint32); + p+=sizeof(uint32_t); } @@ -7548,7 +7548,7 @@ static UC Is_Trackpoint_Invalid(GPS_PTrack trk) ** @param [r] trk [GPS_PTrack **] track ** @param [r] n [int32 *] Number of trackpoints ************************************************************************/ -void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n) +void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32_t* n) { /* D303/304 marks track segments with two consecutive invalid track * points instead of the tnew flag. Create them unless we're at the @@ -7557,12 +7557,12 @@ void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n) * done here because it will change the number of track points. */ if (gps_trk_type == pD303 || gps_trk_type == pD304) { - for (int32 i=0; i<*n; ++i) { + for (int32_t i = 0; i<*n; ++i) { if ((*trk)[i]->tnew && i>0 && !(*trk)[i]->ishdr && !(*trk)[i-1]->ishdr) { /* Create invalid points based on the data from the point * marked with tnew and the one before it. */ - for (int32 j=i-1; j<=i; ++j) { + for (int32_t j = i - 1; j<=i; ++j) { if (!Is_Trackpoint_Invalid((*trk)[j])) { GPS_PTrack trkpt = GPS_Track_New(); *trkpt = *((*trk)[j]); @@ -7584,7 +7584,7 @@ void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n) } } -int32 GPS_Set_Baud_Rate(const char* port, int br) +int32_t GPS_Set_Baud_Rate(const char* port, int br) { gpsdevh* fd; diff --git a/jeeps/gpsapp.h b/jeeps/gpsapp.h index 12b33a211..00f2736bb 100644 --- a/jeeps/gpsapp.h +++ b/jeeps/gpsapp.h @@ -4,79 +4,79 @@ #include "jeeps/gps.h" - int32 GPS_Init(const char* port); +int32_t GPS_Init(const char* port); - int32 GPS_A100_Get(const char* port, GPS_PWay** way, int (*cb)(int ct, GPS_PWay*)); - int32 GPS_A101_Get(const char* port); - int32 GPS_A100_Send(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_PWay*)); +int32_t GPS_A100_Get(const char* port, GPS_PWay** way, int (*cb)(int ct, GPS_PWay*)); +int32_t GPS_A101_Get(const char* port); +int32_t GPS_A100_Send(const char* port, GPS_PWay* way, int32_t n, int (*cb)(GPS_PWay*)); - int32 GPS_A200_Get(const char* port, GPS_PWay** way); - int32 GPS_A201_Get(const char* port, GPS_PWay** way); - int32 GPS_A200_Send(const char* port, GPS_PWay* way, int32 n); - int32 GPS_A201_Send(const char* port, GPS_PWay* way, int32 n); +int32_t GPS_A200_Get(const char* port, GPS_PWay** way); +int32_t GPS_A201_Get(const char* port, GPS_PWay** way); +int32_t GPS_A200_Send(const char* port, GPS_PWay* way, int32_t n); +int32_t GPS_A201_Send(const char* port, GPS_PWay* way, int32_t n); - int32 GPS_A300_Get(const char* port, GPS_PTrack** trk, pcb_fn cb); - int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid); - int32 GPS_A300_Send(const char* port, GPS_PTrack* trk, int32 n); - int32 GPS_A301_Send(const char* port, GPS_PTrack* trk, int32 n, int protoid, - gpsdevh* fd); +int32_t GPS_A300_Get(const char* port, GPS_PTrack** trk, pcb_fn cb); +int32_t GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid); +int32_t GPS_A300_Send(const char* port, GPS_PTrack* trk, int32_t n); +int32_t GPS_A301_Send(const char* port, GPS_PTrack* trk, int32_t n, int protoid, + gpsdevh* fd); - int32 GPS_D300_Get(GPS_PTrack* trk, int32 entries, gpsdevh* h); +int32_t GPS_D300_Get(GPS_PTrack* trk, int32_t entries, gpsdevh* h); void GPS_D300b_Get(GPS_PTrack* trk, UC* data); void GPS_D301b_Get(GPS_PTrack* trk, UC* data); void GPS_D302b_Get(GPS_PTrack* trk, UC* data); void GPS_D303b_Get(GPS_PTrack* trk, UC* data); /*D304*/ void GPS_D310_Get(GPS_PTrack* trk, UC* s); void GPS_D311_Get(GPS_PTrack* trk, UC* s); - void GPS_D300_Send(UC* data, GPS_PTrack trk, int32* len); - void GPS_D301_Send(UC* data, GPS_PTrack trk, int32* len, int type); - void GPS_D303_Send(UC* data, GPS_PTrack trk, int32* len, int protoid); - void GPS_D310_Send(UC* data, GPS_PTrack trk, int32* len); - void GPS_D311_Send(UC* data, GPS_PTrack trk, int32* len); + void GPS_D300_Send(UC* data, GPS_PTrack trk, int32_t* len); + void GPS_D301_Send(UC* data, GPS_PTrack trk, int32_t* len, int type); + void GPS_D303_Send(UC* data, GPS_PTrack trk, int32_t* len, int protoid); + void GPS_D310_Send(UC* data, GPS_PTrack trk, int32_t* len); + void GPS_D311_Send(UC* data, GPS_PTrack trk, int32_t* len); - int32 GPS_A400_Get(const char* port, GPS_PWay** way); - int32 GPS_A400_Send(const char* port, GPS_PWay* way, int32 n); +int32_t GPS_A400_Get(const char* port, GPS_PWay** way); +int32_t GPS_A400_Send(const char* port, GPS_PWay* way, int32_t n); - int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm); - int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n); +int32_t GPS_A500_Get(const char* port, GPS_PAlmanac** alm); +int32_t GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32_t n); time_t GPS_A600_Get(const char* port); time_t GPS_D600_Get(const GPS_Packet& packet); - int32 GPS_A600_Send(const char* port, time_t Time); +int32_t GPS_A600_Send(const char* port, time_t Time); void GPS_D600_Send(GPS_Packet& packet, time_t Time); - int32 GPS_A700_Get(const char* port, double* lat, double* lon); - int32 GPS_A700_Send(const char* port, double lat, double lon); +int32_t GPS_A700_Get(const char* port, double* lat, double* lon); +int32_t GPS_A700_Send(const char* port, double lat, double lon); void GPS_D700_Get(const GPS_Packet& packet, double* lat, double* lon); void GPS_D700_Send(GPS_Packet& packet, double lat, double lon); - int32 GPS_A800_On(const char* port, gpsdevh** fd); - int32 GPS_A800_Off(const char* port, gpsdevh** fd); - int32 GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet); +int32_t GPS_A800_On(const char* port, gpsdevh** fd); +int32_t GPS_A800_Off(const char* port, gpsdevh** fd); +int32_t GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet); void GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt); - int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb); +int32_t GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb); void GPS_D1011b_Get(GPS_PLap* Lap,UC* data); /*D906 D1001 D1015*/ - int32 GPS_A1006_Get(const char* port, GPS_PCourse** crs, pcb_fn cb); - int32 GPS_A1006_Send(const char* port, GPS_PCourse* crs, int32 n_crs, - gpsdevh* fd); +int32_t GPS_A1006_Get(const char* port, GPS_PCourse** crs, pcb_fn cb); +int32_t GPS_A1006_Send(const char* port, GPS_PCourse* crs, int32_t n_crs, + gpsdevh* fd); void GPS_D1006_Get(GPS_PCourse* crs, UC* p); - void GPS_D1006_Send(UC* data, GPS_PCourse crs, int32* len); + void GPS_D1006_Send(UC* data, GPS_PCourse crs, int32_t* len); - int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb); - int32 GPS_A1007_Send(const char* port, GPS_PCourse_Lap* clp, int32 n_clp, - gpsdevh* fd); +int32_t GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb); +int32_t GPS_A1007_Send(const char* port, GPS_PCourse_Lap* clp, int32_t n_clp, + gpsdevh* fd); void GPS_D1007_Get(GPS_PCourse_Lap* clp, UC* p); - void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32* len); + void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32_t* len); - int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb); - int32 GPS_A1008_Send(const char* port, GPS_PCourse_Point* cpt, int32 n_cpt, - gpsdevh* fd); +int32_t GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb); +int32_t GPS_A1008_Send(const char* port, GPS_PCourse_Point* cpt, int32_t n_cpt, + gpsdevh* fd); void GPS_D1012_Get(GPS_PCourse_Point* cpt, UC* p); - void GPS_D1012_Send(UC* data, GPS_PCourse_Point cpt, int32* len); + void GPS_D1012_Send(UC* data, GPS_PCourse_Point cpt, int32_t* len); - int32 GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits); +int32_t GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits); void GPS_D1013_Get(GPS_PCourse_Limits limits, UC* p); /* Unhandled documented protocols, as of: @@ -109,7 +109,7 @@ const char* Get_Pkt_Type(US p, US d0, const char** xinfo); - void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n); - int32 GPS_Set_Baud_Rate(const char* port, int br); + void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32_t* n); +int32_t GPS_Set_Baud_Rate(const char* port, int br); #endif // JEEPS_GPSAPP_H_INCLUDED_ diff --git a/jeeps/gpscom.cc b/jeeps/gpscom.cc index ca25a7733..f6fe19e07 100644 --- a/jeeps/gpscom.cc +++ b/jeeps/gpscom.cc @@ -37,7 +37,7 @@ ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Off(const char* port) +int32_t GPS_Command_Off(const char* port) { static UC data[2]; gpsdevh* fd; @@ -84,9 +84,9 @@ int32 GPS_Command_Off(const char* port) ** @return [int32] number of waypoint entries ************************************************************************/ -int32 GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way, pcb_fn cb) +int32_t GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way, pcb_fn cb) { - int32 ret=0; + int32_t ret = 0; /* * It's a bit tacky to do this up front without ticking the @@ -126,9 +126,9 @@ int32 GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way, pcb_fn cb) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_SWay**)) +int32_t GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32_t n, int (*cb)(GPS_SWay**)) { - int32 ret=0; + int32_t ret = 0; switch (gps_waypt_transfer) { case pA100: @@ -153,9 +153,9 @@ int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (* ** @return [int32] number of waypoint entries ************************************************************************/ -int32 GPS_Command_Get_Route(const char* port, GPS_PWay** way) +int32_t GPS_Command_Get_Route(const char* port, GPS_PWay** way) { - int32 ret=0; + int32_t ret = 0; switch (gps_route_transfer) { case pA200: @@ -185,9 +185,9 @@ int32 GPS_Command_Get_Route(const char* port, GPS_PWay** way) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Route(const char* port, GPS_PWay* way, int32 n) +int32_t GPS_Command_Send_Route(const char* port, GPS_PWay* way, int32_t n) { - int32 ret=0; + int32_t ret = 0; switch (gps_route_transfer) { @@ -216,9 +216,9 @@ int32 GPS_Command_Send_Route(const char* port, GPS_PWay* way, int32 n) ** @return [int32] number of track entries ************************************************************************/ -int32 GPS_Command_Get_Track(const char* port, GPS_PTrack** trk, pcb_fn cb) +int32_t GPS_Command_Get_Track(const char* port, GPS_PTrack** trk, pcb_fn cb) { - int32 ret=0; + int32_t ret = 0; if (gps_trk_transfer == -1) { return GPS_UNSUPPORTED; @@ -253,9 +253,9 @@ int32 GPS_Command_Get_Track(const char* port, GPS_PTrack** trk, pcb_fn cb) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Track(const char* port, GPS_PTrack* trk, int32 n, int eraset) +int32_t GPS_Command_Send_Track(const char* port, GPS_PTrack* trk, int32_t n, int eraset) { - int32 ret=0; + int32_t ret = 0; if (gps_trk_transfer == -1) { return GPS_UNSUPPORTED; @@ -293,9 +293,9 @@ int32 GPS_Command_Send_Track(const char* port, GPS_PTrack* trk, int32 n, int era ** @return [int32] number of waypoint entries ************************************************************************/ -int32 GPS_Command_Get_Proximity(const char* port, GPS_PWay** way) +int32_t GPS_Command_Get_Proximity(const char* port, GPS_PWay** way) { - int32 ret=0; + int32_t ret = 0; if (gps_prx_waypt_transfer == -1) { return GPS_UNSUPPORTED; @@ -326,9 +326,9 @@ int32 GPS_Command_Get_Proximity(const char* port, GPS_PWay** way) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Proximity(const char* port, GPS_PWay* way, int32 n) +int32_t GPS_Command_Send_Proximity(const char* port, GPS_PWay* way, int32_t n) { - int32 ret=0; + int32_t ret = 0; if (gps_prx_waypt_transfer == -1) { @@ -360,9 +360,9 @@ int32 GPS_Command_Send_Proximity(const char* port, GPS_PWay* way, int32 n) ** @return [int32] number of almanac entries ************************************************************************/ -int32 GPS_Command_Get_Almanac(const char* port, GPS_PAlmanac** alm) +int32_t GPS_Command_Get_Almanac(const char* port, GPS_PAlmanac** alm) { - int32 ret=0; + int32_t ret = 0; if (gps_almanac_transfer == -1) { return GPS_UNSUPPORTED; @@ -393,9 +393,9 @@ int32 GPS_Command_Get_Almanac(const char* port, GPS_PAlmanac** alm) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Almanac(const char* port, GPS_PAlmanac* alm, int32 n) +int32_t GPS_Command_Send_Almanac(const char* port, GPS_PAlmanac* alm, int32_t n) { - int32 ret=0; + int32_t ret = 0; if (gps_almanac_transfer == -1) { return GPS_UNSUPPORTED; @@ -458,7 +458,7 @@ time_t GPS_Command_Get_Time(const char* port) ** @return [int32] true if OK ************************************************************************/ -int32 GPS_Command_Send_Time(const char* port, time_t Time) +int32_t GPS_Command_Send_Time(const char* port, time_t Time) { time_t ret=0; @@ -488,9 +488,9 @@ int32 GPS_Command_Send_Time(const char* port, time_t Time) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Get_Position(const char* port, double* lat, double* lon) +int32_t GPS_Command_Get_Position(const char* port, double* lat, double* lon) { - int32 ret=0; + int32_t ret = 0; switch (gps_position_transfer) { case pA700: @@ -524,9 +524,9 @@ int32 GPS_Command_Get_Position(const char* port, double* lat, double* lon) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Position(const char* port, double lat, double lon) +int32_t GPS_Command_Send_Position(const char* port, double lat, double lon) { - int32 ret=0; + int32_t ret = 0; switch (gps_position_transfer) { case pA700: @@ -551,9 +551,9 @@ int32 GPS_Command_Send_Position(const char* port, double lat, double lon) ** @return [int32] success if supported and GPS starts sending ************************************************************************/ -int32 GPS_Command_Pvt_On(const char* port, gpsdevh** fd) +int32_t GPS_Command_Pvt_On(const char* port, gpsdevh** fd) { - int32 ret=0; + int32_t ret = 0; if (gps_pvt_transfer == -1) { @@ -586,9 +586,9 @@ int32 GPS_Command_Pvt_On(const char* port, gpsdevh** fd) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Pvt_Off(const char* port, gpsdevh** fd) +int32_t GPS_Command_Pvt_Off(const char* port, gpsdevh** fd) { - int32 ret=0; + int32_t ret = 0; if (gps_pvt_transfer == -1) { @@ -619,9 +619,9 @@ int32 GPS_Command_Pvt_Off(const char* port, gpsdevh** fd) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Pvt_Get(gpsdevh** fd, GPS_PPvt_Data* pvt) +int32_t GPS_Command_Pvt_Get(gpsdevh** fd, GPS_PPvt_Data* pvt) { - int32 ret=0; + int32_t ret = 0; if (gps_pvt_transfer == -1) { return GPS_UNSUPPORTED; @@ -651,9 +651,9 @@ int32 GPS_Command_Pvt_Get(gpsdevh** fd, GPS_PPvt_Data* pvt) ** @return [int32] number of lap entries ************************************************************************/ -int32 GPS_Command_Get_Lap(const char* port, GPS_PLap** lap, pcb_fn cb) +int32_t GPS_Command_Get_Lap(const char* port, GPS_PLap** lap, pcb_fn cb) { - int32 ret=0; + int32_t ret = 0; if (gps_lap_transfer == -1) { return GPS_UNSUPPORTED; @@ -688,18 +688,18 @@ int32 GPS_Command_Get_Lap(const char* port, GPS_PLap** lap, pcb_fn cb) ** ** @return [int32] number of course entries ************************************************************************/ -int32 GPS_Command_Get_Course +int32_t GPS_Command_Get_Course (const char* port, GPS_PCourse** crs, GPS_PCourse_Lap** clp, GPS_PTrack** trk, GPS_PCourse_Point** cpt, - int32* n_clp, - int32* n_trk, - int32* n_cpt, + int32_t* n_clp, + int32_t* n_trk, + int32_t* n_cpt, pcb_fn cb) { - int32 ret=0; + int32_t ret = 0; if (gps_course_transfer == -1) { return GPS_UNSUPPORTED; @@ -768,24 +768,24 @@ int32 GPS_Command_Get_Course ** ** @return [int32] Success ************************************************************************/ -int32 GPS_Command_Send_Course +int32_t GPS_Command_Send_Course (const char* port, GPS_PCourse* crs, GPS_PCourse_Lap* clp, GPS_PTrack* trk, GPS_PCourse_Point* cpt, - int32 n_crs, - int32 n_clp, - int32 n_trk, - int32 n_cpt) + int32_t n_crs, + int32_t n_clp, + int32_t n_trk, + int32_t n_cpt) { gpsdevh* fd; GPS_OCourse_Limits limits; - int32 ret; - int32 ret_crs=0; - int32 ret_clp=0; - int32 ret_trk=0; - int32 ret_cpt=0; + int32_t ret; + int32_t ret_crs = 0; + int32_t ret_clp = 0; + int32_t ret_trk = 0; + int32_t ret_cpt = 0; if (gps_course_transfer == -1 || gps_course_limits_transfer == -1) { return GPS_UNSUPPORTED; @@ -886,9 +886,9 @@ int32 GPS_Command_Send_Course ** ** @return [uint32] course index ************************************************************************/ -static uint32 Unique_Course_Index(GPS_PCourse* crs, int n_crs) +static uint32_t Unique_Course_Index(GPS_PCourse* crs, int n_crs) { - uint32 idx; + uint32_t idx; int i; for (idx=0; ; idx++) { @@ -913,9 +913,9 @@ static uint32 Unique_Course_Index(GPS_PCourse* crs, int n_crs) ** ** @return [uint32] track index ************************************************************************/ -static uint32 Unique_Track_Index(GPS_PCourse* crs, int n_crs) +static uint32_t Unique_Track_Index(GPS_PCourse* crs, int n_crs) { - uint32 idx; + uint32_t idx; int i; for (idx=0; ; idx++) { @@ -1082,7 +1082,7 @@ Course_Garbage_Collect(GPS_PCourse* crs, int* n_crs, /* Remove unreferenced tracks */ restart_tracks: for (i=0; i<*n_ctk; i++) { - uint32 trk_idx; + uint32_t trk_idx; if (!ctk[i]->ishdr) { continue; @@ -1150,8 +1150,8 @@ Course_Garbage_Collect(GPS_PCourse* crs, int* n_crs, ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 n_trk, - GPS_PWay* wpt, int32 n_wpt, int eraset) +int32_t GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32_t n_trk, + GPS_PWay* wpt, int32_t n_wpt, int eraset) { GPS_PCourse* crs = nullptr; GPS_PCourse_Lap* clp = nullptr; @@ -1159,7 +1159,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 GPS_PCourse_Point* cpt = nullptr; int n_crs, n_clp=0, n_ctk=0, n_cpt=0; int i, j, trk_end, new_crs, first_new_ctk; - int32 ret; + int32_t ret; /* Read existing courses from device */ if (eraset) { @@ -1248,7 +1248,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 cpt = (GPS_SCourse_Point**) xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point)); for (i=0; i - int32 GPS_Command_Off(const char* port); +int32_t GPS_Command_Off(const char* port); time_t GPS_Command_Get_Time(const char* port); - int32 GPS_Command_Send_Time(const char* port, time_t Time); +int32_t GPS_Command_Send_Time(const char* port, time_t Time); - int32 GPS_Command_Get_Position(const char* port, double* lat, double* lon); - int32 GPS_Command_Send_Position(const char* port, double lat, double lon); +int32_t GPS_Command_Get_Position(const char* port, double* lat, double* lon); +int32_t GPS_Command_Send_Position(const char* port, double lat, double lon); - int32 GPS_Command_Pvt_On(const char* port, gpsdevh** fd); - int32 GPS_Command_Pvt_Off(const char* port, gpsdevh** fd); - int32 GPS_Command_Pvt_Get(gpsdevh** fd, GPS_PPvt_Data* pvt); +int32_t GPS_Command_Pvt_On(const char* port, gpsdevh** fd); +int32_t GPS_Command_Pvt_Off(const char* port, gpsdevh** fd); +int32_t GPS_Command_Pvt_Get(gpsdevh** fd, GPS_PPvt_Data* pvt); - int32 GPS_Command_Get_Almanac(const char* port, GPS_PAlmanac** alm); - int32 GPS_Command_Send_Almanac(const char* port, GPS_PAlmanac* alm, int32 n); +int32_t GPS_Command_Get_Almanac(const char* port, GPS_PAlmanac** alm); +int32_t GPS_Command_Send_Almanac(const char* port, GPS_PAlmanac* alm, int32_t n); - int32 GPS_Command_Get_Track(const char* port, GPS_PTrack** trk, int (*cb)(int, GPS_SWay**)); - int32 GPS_Command_Send_Track(const char* port, GPS_PTrack* trk, int32 n, int eraset); +int32_t GPS_Command_Get_Track(const char* port, GPS_PTrack** trk, int (*cb)(int, GPS_SWay**)); +int32_t GPS_Command_Send_Track(const char* port, GPS_PTrack* trk, int32_t n, int eraset); - int32 GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way,int (*cb)(int, GPS_SWay**)); - int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_SWay**)); +int32_t GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way, int (*cb)(int, GPS_SWay**)); +int32_t GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32_t n, int (*cb)(GPS_SWay**)); - int32 GPS_Command_Get_Proximity(const char* port, GPS_PWay** way); - int32 GPS_Command_Send_Proximity(const char* port, GPS_PWay* way, int32 n); +int32_t GPS_Command_Get_Proximity(const char* port, GPS_PWay** way); +int32_t GPS_Command_Send_Proximity(const char* port, GPS_PWay* way, int32_t n); - int32 GPS_Command_Get_Route(const char* port, GPS_PWay** way); - int32 GPS_Command_Send_Route(const char* port, GPS_PWay* way, int32 n); +int32_t GPS_Command_Get_Route(const char* port, GPS_PWay** way); +int32_t GPS_Command_Send_Route(const char* port, GPS_PWay* way, int32_t n); - int32 GPS_Command_Get_Lap(const char* port, GPS_PLap** lap, int (*cb)(int, GPS_SWay**)); +int32_t GPS_Command_Get_Lap(const char* port, GPS_PLap** lap, int (*cb)(int, GPS_SWay**)); - int32 GPS_Command_Send_Course(const char* port, GPS_PCourse* crs, GPS_PCourse_Lap* clp, - GPS_PTrack* trk, GPS_PCourse_Point* cpt, - int32 n_crs, int32 n_clp, int32 n_trk, int32 n_cpt); - int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 n_trk, - GPS_PWay* wpt, int32 n_wpt, int eraset); +int32_t GPS_Command_Send_Course(const char* port, GPS_PCourse* crs, GPS_PCourse_Lap* clp, + GPS_PTrack* trk, GPS_PCourse_Point* cpt, + int32_t n_crs, int32_t n_clp, int32_t n_trk, int32_t n_cpt); +int32_t GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32_t n_trk, + GPS_PWay* wpt, int32_t n_wpt, int eraset); - int32 GPS_Command_Get_Workout(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); - int32 GPS_Command_Get_Fitness_User_Profile(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); - int32 GPS_Command_Get_Workout_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); - int32 GPS_Command_Get_Course_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); +int32_t GPS_Command_Get_Workout(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); +int32_t GPS_Command_Get_Fitness_User_Profile(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); +int32_t GPS_Command_Get_Workout_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); +int32_t GPS_Command_Get_Course_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); #endif // JEEPS_GPSCOM_H_INCLUDED_ diff --git a/jeeps/gpsdevice.cc b/jeeps/gpsdevice.cc index 1294b3da8..654da137a 100644 --- a/jeeps/gpsdevice.cc +++ b/jeeps/gpsdevice.cc @@ -27,7 +27,7 @@ extern gps_device_ops gps_serial_ops; extern gps_device_ops gps_usb_ops; static gps_device_ops* ops = nullptr; -int32 GPS_Device_On(const char* port, gpsdevh** fd) +int32_t GPS_Device_On(const char* port, gpsdevh** fd) { gps_is_usb = (0 == case_ignore_strncmp(port, "usb:", 4)); @@ -40,32 +40,32 @@ int32 GPS_Device_On(const char* port, gpsdevh** fd) return (ops->Device_On)(port, fd); } -int32 GPS_Device_Off(gpsdevh* fd) +int32_t GPS_Device_Off(gpsdevh* fd) { return (ops->Device_Off)(fd); } -int32 GPS_Device_Wait(gpsdevh* fd) +int32_t GPS_Device_Wait(gpsdevh* fd) { return (ops->Device_Wait)(fd); } -int32 GPS_Device_Chars_Ready(gpsdevh* fd) +int32_t GPS_Device_Chars_Ready(gpsdevh* fd) { return (ops->Device_Chars_Ready)(fd); } -int32 GPS_Device_Flush(gpsdevh* fd) +int32_t GPS_Device_Flush(gpsdevh* fd) { return (ops->Device_Flush)(fd); } -int32 GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet) +int32_t GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet) { return (ops->Write_Packet)(fd, packet); } -int32 GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet) +int32_t GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet) { return (ops->Read_Packet)(fd, packet); } @@ -80,7 +80,7 @@ bool GPS_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec) return (ops->Get_Ack)(fd, tra, rec); } -void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32 n) +void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32_t n) { packet->type = type; if (n > 0) { diff --git a/jeeps/gpsdevice.h b/jeeps/gpsdevice.h index 5abf56b0a..444e869a6 100644 --- a/jeeps/gpsdevice.h +++ b/jeeps/gpsdevice.h @@ -29,24 +29,24 @@ #define usecDELAY 180000 /* Microseconds before GPS sends A001 */ - int32 GPS_Device_Chars_Ready(gpsdevh* fd); - int32 GPS_Device_On(const char* port, gpsdevh** fd); - int32 GPS_Device_Off(gpsdevh* fd); - int32 GPS_Device_Wait(gpsdevh* fd); - int32 GPS_Device_Flush(gpsdevh* fd); - int32 GPS_Device_Read(int32 ignored, void* ibuf, int size); - int32 GPS_Device_Write(int32 ignored, const void* obuf, int size); +int32_t GPS_Device_Chars_Ready(gpsdevh* fd); +int32_t GPS_Device_On(const char* port, gpsdevh** fd); +int32_t GPS_Device_Off(gpsdevh* fd); +int32_t GPS_Device_Wait(gpsdevh* fd); +int32_t GPS_Device_Flush(gpsdevh* fd); +int32_t GPS_Device_Read(int32_t ignored, void* ibuf, int size); +int32_t GPS_Device_Write(int32_t ignored, const void* obuf, int size); void GPS_Device_Error(char* hdr, ...); - int32 GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet); +int32_t GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet); bool GPS_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); - int32 GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet); +int32_t GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet); bool GPS_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); - using gps_device_op = int32 (*)(gpsdevh*); - using gps_device_op5 = int32 (*)(const char*, gpsdevh** fd); + using gps_device_op = int32_t (*)(gpsdevh*); + using gps_device_op5 = int32_t (*)(const char*, gpsdevh** fd); using gps_device_op10 = bool (*)(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); - using gps_device_op12 = int32 (*)(gpsdevh* fd, const GPS_Packet& packet); - using gps_device_op13 = int32 (*)(gpsdevh* fd, GPS_Packet* packet); + using gps_device_op12 = int32_t (*)(gpsdevh* fd, const GPS_Packet& packet); + using gps_device_op13 = int32_t (*)(gpsdevh* fd, GPS_Packet* packet); typedef struct { gps_device_op5 Device_On; diff --git a/jeeps/gpsdevice_usb.cc b/jeeps/gpsdevice_usb.cc index 15e37c19e..3ab6d8a72 100644 --- a/jeeps/gpsdevice_usb.cc +++ b/jeeps/gpsdevice_usb.cc @@ -32,17 +32,17 @@ static bool success_stub() return true; } -static int32 gdu_on(const char* port, gpsdevh** fd) +static int32_t gdu_on(const char* port, gpsdevh** fd) { return gusb_init(port, fd); } -static int32 gdu_off(gpsdevh* dh) +static int32_t gdu_off(gpsdevh* dh) { return gusb_close(dh); } -static int32 gdu_read(gpsdevh* fd, GPS_Packet* packet) +static int32_t gdu_read(gpsdevh* fd, GPS_Packet* packet) { /* Default is to eat bulk request packets. */ return GPS_Packet_Read_usb(fd, packet, 1); diff --git a/jeeps/gpsfmt.h b/jeeps/gpsfmt.h index 3cf101690..9471eb3f4 100644 --- a/jeeps/gpsfmt.h +++ b/jeeps/gpsfmt.h @@ -9,10 +9,10 @@ void GPS_Fmt_Print_Time(time_t Time, FILE* outf); void GPS_Fmt_Print_Position(double lat, double lon, FILE* outf); void GPS_Fmt_Print_Pvt(GPS_PPvt_Data pvt, FILE* outf); - void GPS_Fmt_Print_Almanac(GPS_PAlmanac* alm, int32 n, FILE* outf); - void GPS_Fmt_Print_Track(GPS_PTrack* trk, int32 n, FILE* outf); - int32 GPS_Fmt_Print_Waypoint(GPS_PWay* way, int32 n, FILE* outf); - int32 GPS_Fmt_Print_Proximity(GPS_PWay* way, int32 n, FILE* outf); - int32 GPS_Fmt_Print_Route(GPS_PWay* way, int32 n, FILE* outf); + void GPS_Fmt_Print_Almanac(GPS_PAlmanac* alm, int32_t n, FILE* outf); + void GPS_Fmt_Print_Track(GPS_PTrack* trk, int32_t n, FILE* outf); +int32_t GPS_Fmt_Print_Waypoint(GPS_PWay* way, int32_t n, FILE* outf); +int32_t GPS_Fmt_Print_Proximity(GPS_PWay* way, int32_t n, FILE* outf); +int32_t GPS_Fmt_Print_Route(GPS_PWay* way, int32_t n, FILE* outf); #endif // JEEPS_GPSFMT_H_INCLUDED_ diff --git a/jeeps/gpsmath.cc b/jeeps/gpsmath.cc index b489c5bf6..56a24581a 100644 --- a/jeeps/gpsmath.cc +++ b/jeeps/gpsmath.cc @@ -28,11 +28,11 @@ #include -static int32 GPS_Math_LatLon_To_UTM_Param(double lat, double lon, int32* zone, - char* zc, double* Mc, double* E0, - double* N0, double* F0); -static int32 GPS_Math_UTM_Param_To_Mc(int32 zone, char zc, double* Mc, - double* E0, double* N0, double* F0); +static int32_t GPS_Math_LatLon_To_UTM_Param(double lat, double lon, int32_t* zone, + char* zc, double* Mc, double* E0, + double* N0, double* F0); +static int32_t GPS_Math_UTM_Param_To_Mc(int32_t zone, char zc, double* Mc, + double* E0, double* N0, double* F0); @@ -79,9 +79,9 @@ double GPS_Math_Rad_To_Deg(double v) ** @return [void] ************************************************************************/ -void GPS_Math_Deg_To_DegMin(double v, int32* d, double* m) +void GPS_Math_Deg_To_DegMin(double v, int32_t* d, double* m) { - int32 sign; + int32_t sign; if (v<0.) { v *= -1.; @@ -90,7 +90,7 @@ void GPS_Math_Deg_To_DegMin(double v, int32* d, double* m) sign = 0; } - *d = (int32)v; + *d = (int32_t)v; *m = (v-(double)*d) * 60.0; if (*m>59.999) { ++*d; @@ -117,7 +117,7 @@ void GPS_Math_Deg_To_DegMin(double v, int32* d, double* m) ** @return [void] ************************************************************************/ -void GPS_Math_DegMin_To_Deg(int32 d, double m, double* deg) +void GPS_Math_DegMin_To_Deg(int32_t d, double m, double* deg) { *deg = ((double)abs(d)) + m / 60.0; @@ -142,9 +142,9 @@ void GPS_Math_DegMin_To_Deg(int32 d, double m, double* deg) ** @return [void] ************************************************************************/ -void GPS_Math_Deg_To_DegMinSec(double v, int32* d, int32* m, double* s) +void GPS_Math_Deg_To_DegMinSec(double v, int32_t* d, int32_t* m, double* s) { - int32 sign; + int32_t sign; double t; if (v<0.) { @@ -154,10 +154,10 @@ void GPS_Math_Deg_To_DegMinSec(double v, int32* d, int32* m, double* s) sign = 0; } - *d = (int32)v; + *d = (int32_t)v; t = (v -(double)*d) * 60.0; *m = (v-(double)*d) * 60.0; - *s = (t - (int32)t) * 60.0; + *s = (t - (int32_t)t) * 60.0; if (*s>59.999) { ++t; @@ -170,7 +170,7 @@ void GPS_Math_Deg_To_DegMinSec(double v, int32* d, int32* m, double* s) t = 0; } - *m = (int32)t; + *m = (int32_t)t; if (sign) { *d = -*d; @@ -193,7 +193,7 @@ void GPS_Math_Deg_To_DegMinSec(double v, int32* d, int32* m, double* s) ** @return [void] ************************************************************************/ -void GPS_Math_DegMinSec_To_Deg(int32 d, int32 m, double s, double* deg) +void GPS_Math_DegMinSec_To_Deg(int32_t d, int32_t m, double s, double* deg) { *deg = ((double)abs(d)) + ((double)m + s / 60.0) / 60.0; @@ -247,7 +247,7 @@ double GPS_Math_Feet_To_Metres(double v) ** @return [int32] semicircles ************************************************************************/ -int32 GPS_Math_Deg_To_Semi(double v) +int32_t GPS_Math_Deg_To_Semi(double v) { return round(((double)(1U<<31) / 180.0) * v); } @@ -263,7 +263,7 @@ int32 GPS_Math_Deg_To_Semi(double v) ** @return [double] degrees ************************************************************************/ -double GPS_Math_Semi_To_Deg(int32 v) +double GPS_Math_Semi_To_Deg(int32_t v) { return (((double)v / (double)(1U<<31)) * 180.0); } @@ -367,8 +367,8 @@ void GPS_Math_XYZ_To_LatLonH(double* phi, double* lambda, double* H, double phix; double nphi; double rho; - int32 t1=0; - int32 t2=0; + int32_t t1 = 0; + int32_t t2 = 0; if (x<0.0 && y>=0.0) { t1=1; @@ -689,8 +689,8 @@ void GPS_Math_Airy1830LatLonToNGEN(double phi, double lambda, double* E, ** @return [void] ************************************************************************/ -int32 GPS_Math_WGS84_To_Swiss_EN(double lat, double lon, double* E, - double* N) +int32_t GPS_Math_WGS84_To_Swiss_EN(double lat, double lon, double* E, + double* N) { const double phi0 = 46.95240556; const double lambda0 = 7.43958333; @@ -1086,8 +1086,8 @@ void GPS_Math_Cassini_EN_To_LatLon(double E, double N, double* phi, ** @return [void] ************************************************************************/ -int32 GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, - double* N) +int32_t GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, + double* N) { double const phi0 = 31.73409694444; // 31 44 2.749 double const lambda0 = 35.21208055556; // 35 12 43.49 @@ -1095,11 +1095,11 @@ int32 GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, double const N0 = 1126867.909; double phi, lambda, alt, a, b; - int32 datum = GPS_Lookup_Datum_Index("Palestine 1923"); + int32_t datum = GPS_Lookup_Datum_Index("Palestine 1923"); if (datum < 0) { fatal("Unable to find Palestine 1923 in internal tables"); } - int32 ellipse = GPS_Datum[datum].ellipse; + int32_t ellipse = GPS_Datum[datum].ellipse; a = GPS_Ellipse[ellipse].a; b = a - (a / GPS_Ellipse[ellipse].invf); @@ -1131,11 +1131,11 @@ void GPS_Math_ICS_EN_To_WGS84(double E, double N, double* lat, double* lon) double const E0 = 170251.555; double const N0 = 1126867.909; double phi, lambda, alt, a, b; - int32 datum = GPS_Lookup_Datum_Index("Palestine 1923"); + int32_t datum = GPS_Lookup_Datum_Index("Palestine 1923"); if (datum < 0) { fatal("Unable to find Palestine 1923 in internal tables"); } - int32 ellipse = GPS_Datum[datum].ellipse; + int32_t ellipse = GPS_Datum[datum].ellipse; a = GPS_Ellipse[ellipse].a; b = a - (a / GPS_Ellipse[ellipse].invf); @@ -1350,24 +1350,24 @@ void GPS_Math_INGENToAiry1830MLatLon(double E, double N, double* phi, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_EN_To_UKOSNG_Map(double E, double N, double* mE, - double* mN, char* map) +int32_t GPS_Math_EN_To_UKOSNG_Map(double E, double N, double* mE, + double* mN, char* map) { - int32 t; - int32 idx; + int32_t t; + int32_t idx; if (E>=700000. || E<0.0 || N<0.0 || N>=1300000.0) { return 0; } - idx = ((int32)N/100000)*7 + (int32)E/100000; + idx = ((int32_t)N/100000)*7 + (int32_t)E/100000; (void) strcpy(map,UKNG[idx]); - t = ((int32)E / 100000) * 100000; + t = ((int32_t)E / 100000) * 100000; *mE = E - (double)t; - t = ((int32)N / 100000) * 100000; + t = ((int32_t)N / 100000) * 100000; *mN = N - (double)t; return 1; @@ -1389,11 +1389,11 @@ int32 GPS_Math_EN_To_UKOSNG_Map(double E, double N, double* mE, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_UKOSNG_Map_To_EN(const char* map, double mapE, double mapN, - double* E, double* N) +int32_t GPS_Math_UKOSNG_Map_To_EN(const char* map, double mapE, double mapN, + double* E, double* N) { - int32 t; - int32 idx; + int32_t t; + int32_t idx; if (mapE>=100000.0 || mapE<0.0 || mapN<0.0 || mapN>100000.0) { @@ -1525,7 +1525,7 @@ void GPS_Math_Molodensky(double Sphi, double Slam, double SH, double Sa, ************************************************************************/ void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, - int32 n) + int32_t n) { double Sa; double Sif; @@ -1534,7 +1534,7 @@ void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, double x; double y; double z; - int32 idx; + int32_t idx; Da = 6378137.0; Dif = 298.257223563; @@ -1569,7 +1569,7 @@ void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, ************************************************************************/ void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, - int32 n) + int32_t n) { double Sa; double Sif; @@ -1578,7 +1578,7 @@ void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, double x; double y; double z; - int32 idx; + int32_t idx; Sa = 6378137.0; Sif = 298.257223563; @@ -1613,7 +1613,7 @@ void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, ************************************************************************/ void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, - int32 n) + int32_t n) { double Sa; double Sif; @@ -1624,7 +1624,7 @@ void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, double x; double y; double z; - int32 idx; + int32_t idx; double sx; double sy; double sz; @@ -1670,7 +1670,7 @@ void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, ************************************************************************/ void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, - int32 n) + int32_t n) { double Sa; double Sif; @@ -1679,7 +1679,7 @@ void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, double x; double y; double z; - int32 idx; + int32_t idx; double Sb; double Db; double dx; @@ -1728,7 +1728,7 @@ void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, ************************************************************************/ void GPS_Math_Known_Datum_To_Known_Datum_M(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, - double* DH, int32 n1, int32 n2) + double* DH, int32_t n1, int32_t n2) { double Sa; double Sif; @@ -1744,8 +1744,8 @@ void GPS_Math_Known_Datum_To_Known_Datum_M(double Sphi, double Slam, double SH, double y; double z; - int32 idx1; - int32 idx2; + int32_t idx1; + int32_t idx2; idx1 = GPS_Datum[n1].ellipse; @@ -1790,7 +1790,7 @@ void GPS_Math_Known_Datum_To_Known_Datum_M(double Sphi, double Slam, double SH, ************************************************************************/ void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, - double* DH, int32 n1, int32 n2) + double* DH, int32_t n1, int32_t n2) { double Sa; double Sif; @@ -1803,8 +1803,8 @@ void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, double y2; double z2; - int32 idx1; - int32 idx2; + int32_t idx1; + int32_t idx2; double Sb; double Db; @@ -1855,8 +1855,8 @@ void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_WGS84_To_UKOSMap_M(double lat, double lon, double* mE, - double* mN, char* map) +int32_t GPS_Math_WGS84_To_UKOSMap_M(double lat, double lon, double* mE, + double* mN, char* map) { double alat; double alon; @@ -1891,8 +1891,8 @@ int32 GPS_Math_WGS84_To_UKOSMap_M(double lat, double lon, double* mE, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_UKOSMap_To_WGS84_M(const char* map, double mE, double mN, - double* lat, double* lon) +int32_t GPS_Math_UKOSMap_To_WGS84_M(const char* map, double mE, double mN, + double* lat, double* lon) { double E; double N; @@ -1926,8 +1926,8 @@ int32 GPS_Math_UKOSMap_To_WGS84_M(const char* map, double mE, double mN, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_WGS84_To_UKOSMap_C(double lat, double lon, double* mE, - double* mN, char* map) +int32_t GPS_Math_WGS84_To_UKOSMap_C(double lat, double lon, double* mE, + double* mN, char* map) { double alat; double alon; @@ -1962,8 +1962,8 @@ int32 GPS_Math_WGS84_To_UKOSMap_C(double lat, double lon, double* mE, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_UKOSMap_To_WGS84_C(const char* map, double mE, double mN, - double* lat, double* lon) +int32_t GPS_Math_UKOSMap_To_WGS84_C(const char* map, double mE, double mN, + double* lat, double* lon) { double E; double N; @@ -1998,12 +1998,12 @@ int32 GPS_Math_UKOSMap_To_WGS84_C(const char* map, double mE, double mN, ** ** @return [int32] success ************************************************************************/ -static int32 GPS_Math_LatLon_To_UTM_Param(double lat, double lon, int32* zone, - char* zc, double* Mc, double* E0, - double* N0, double* F0) +static int32_t GPS_Math_LatLon_To_UTM_Param(double lat, double lon, int32_t* zone, + char* zc, double* Mc, double* E0, + double* N0, double* F0) { - int32 ilon; - int32 ilat; + int32_t ilon; + int32_t ilat; bool psign; bool lsign; @@ -2019,8 +2019,8 @@ static int32 GPS_Math_LatLon_To_UTM_Param(double lat, double lon, int32* zone, psign=true; } - ilon = abs((int32)lon); - ilat = abs((int32)lat); + ilon = abs((int32_t)lon); + ilat = abs((int32_t)lat); if (!lsign) { *zone = 31 + (ilon / 6); @@ -2098,8 +2098,8 @@ static int32 GPS_Math_LatLon_To_UTM_Param(double lat, double lon, int32* zone, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_NAD83_To_UTM_EN(double lat, double lon, double* E, - double* N, int32* zone, char* zc) +int32_t GPS_Math_NAD83_To_UTM_EN(double lat, double lon, double* E, + double* N, int32_t* zone, char* zc) { double phi0; double lambda0; @@ -2139,8 +2139,8 @@ int32 GPS_Math_NAD83_To_UTM_EN(double lat, double lon, double* E, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_WGS84_To_UTM_EN(double lat, double lon, double* E, - double* N, int32* zone, char* zc) +int32_t GPS_Math_WGS84_To_UTM_EN(double lat, double lon, double* E, + double* N, int32_t* zone, char* zc) { double phi; double lambda; @@ -2170,8 +2170,8 @@ int32 GPS_Math_WGS84_To_UTM_EN(double lat, double lon, double* E, ** ** @return [int32] success ************************************************************************/ -static int32 GPS_Math_UTM_Param_To_Mc(int32 zone, char zc, double* Mc, - double* E0, double* N0, double* F0) +static int32_t GPS_Math_UTM_Param_To_Mc(int32_t zone, char zc, double* Mc, + double* E0, double* N0, double* F0) { if (zone>60 || zone<0 || zc<'C' || zc>'X' || zc=='I' || zc=='O') { @@ -2210,8 +2210,8 @@ static int32 GPS_Math_UTM_Param_To_Mc(int32 zone, char zc, double* Mc, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_UTM_EN_To_NAD83(double* lat, double* lon, double E, - double N, int32 zone, char zc) +int32_t GPS_Math_UTM_EN_To_NAD83(double* lat, double* lon, double E, + double N, int32_t zone, char zc) { return GPS_Math_UTM_EN_To_Known_Datum(lat, lon, E, N, zone, zc, 77); } @@ -2231,8 +2231,8 @@ int32 GPS_Math_UTM_EN_To_NAD83(double* lat, double* lon, double E, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_UTM_EN_To_WGS84(double* lat, double* lon, double E, - double N, int32 zone, char zc) +int32_t GPS_Math_UTM_EN_To_WGS84(double* lat, double* lon, double E, + double N, int32_t zone, char zc) { double lambda0; double N0; @@ -2262,8 +2262,8 @@ int32 GPS_Math_UTM_EN_To_WGS84(double* lat, double* lon, double E, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, - double* N, int32* zone, char* zc, const int n) +int32_t GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, + double* N, int32_t* zone, char* zc, const int n) { double phi0; double lambda0; @@ -2272,7 +2272,7 @@ int32 GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, double F0; double a; double b; - int32 idx; + int32_t idx; if (!GPS_Math_LatLon_To_UTM_Param(lat,lon,zone,zc,&lambda0,&E0, &N0,&F0)) { @@ -2304,8 +2304,8 @@ int32 GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, ** ** @return [int32] success ************************************************************************/ -int32 GPS_Math_UTM_EN_To_Known_Datum(double* lat, double* lon, double E, - double N, int32 zone, char zc, const int n) +int32_t GPS_Math_UTM_EN_To_Known_Datum(double* lat, double* lon, double E, + double N, int32_t zone, char zc, const int n) { double lambda0; double N0; @@ -2547,7 +2547,7 @@ void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, /********************************************************************/ -int32 GPS_Lookup_Datum_Index(const char* n) +int32_t GPS_Lookup_Datum_Index(const char* n) { GPS_PDatum dp; GPS_PDatum_Alias al; @@ -2567,7 +2567,7 @@ int32 GPS_Lookup_Datum_Index(const char* n) return -1; } -int32 GPS_Lookup_Datum_Index(const QString& n) +int32_t GPS_Lookup_Datum_Index(const QString& n) { return GPS_Lookup_Datum_Index(CSTR(n)); } diff --git a/jeeps/gpsmath.h b/jeeps/gpsmath.h index fa35c1ce0..39dd394b1 100644 --- a/jeeps/gpsmath.h +++ b/jeeps/gpsmath.h @@ -14,26 +14,26 @@ double GPS_Math_Metres_To_Feet(double v); double GPS_Math_Feet_To_Metres(double v); - int32 GPS_Math_Deg_To_Semi(double v); - double GPS_Math_Semi_To_Deg(int32 v); +int32_t GPS_Math_Deg_To_Semi(double v); + double GPS_Math_Semi_To_Deg(int32_t v); time_t GPS_Math_Utime_To_Gtime(time_t v); time_t GPS_Math_Gtime_To_Utime(time_t v); - void GPS_Math_Deg_To_DegMin(double v, int32* d, double* m); - void GPS_Math_DegMin_To_Deg(int32 d, double m, double* deg); - void GPS_Math_Deg_To_DegMinSec(double v, int32* d, int32* m, double* s); - void GPS_Math_DegMinSec_To_Deg(int32 d, int32 m, double s, double* deg); + void GPS_Math_Deg_To_DegMin(double v, int32_t* d, double* m); + void GPS_Math_DegMin_To_Deg(int32_t d, double m, double* deg); + void GPS_Math_Deg_To_DegMinSec(double v, int32_t* d, int32_t* m, double* s); + void GPS_Math_DegMinSec_To_Deg(int32_t d, int32_t m, double s, double* deg); void GPS_Math_Airy1830LatLonToNGEN(double phi, double lambda, double* E, double* N); void GPS_Math_Airy1830M_LatLonToINGEN(double phi, double lambda, double* E, double* N); - int32 GPS_Math_EN_To_UKOSNG_Map(double E, double N, double* mE, - double* mN, char* map); - int32 GPS_Math_UKOSNG_Map_To_EN(const char* map, double mapE, double mapN, - double* E, double* N); +int32_t GPS_Math_EN_To_UKOSNG_Map(double E, double N, double* mE, + double* mN, char* map); +int32_t GPS_Math_UKOSNG_Map_To_EN(const char* map, double mapE, double mapN, + double* E, double* N); void GPS_Math_LatLonH_To_XYZ(double phi, double lambda, double H, double* x, double* y, double* z, @@ -72,48 +72,48 @@ double dy, double dz); void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, - int32 n); + int32_t n); void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, - int32 n); + int32_t n); void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, - int32 n); + int32_t n); void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, - int32 n); + int32_t n); void GPS_Math_Known_Datum_To_Known_Datum_M(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, - double* DH, int32 n1, int32 n2); + double* DH, int32_t n1, int32_t n2); void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, - double* DH, int32 n1, int32 n2); + double* DH, int32_t n1, int32_t n2); - int32 GPS_Math_WGS84_To_UKOSMap_M(double lat, double lon, double* mE, +int32_t GPS_Math_WGS84_To_UKOSMap_M(double lat, double lon, double* mE, double* mN, char* map); - int32 GPS_Math_UKOSMap_To_WGS84_M(const char* map, double mE, double mN, +int32_t GPS_Math_UKOSMap_To_WGS84_M(const char* map, double mE, double mN, double* lat, double* lon); - int32 GPS_Math_WGS84_To_UKOSMap_C(double lat, double lon, double* mE, +int32_t GPS_Math_WGS84_To_UKOSMap_C(double lat, double lon, double* mE, double* mN, char* map); - int32 GPS_Math_UKOSMap_To_WGS84_C(const char* map, double mE, double mN, +int32_t GPS_Math_UKOSMap_To_WGS84_C(const char* map, double mE, double mN, double* lat, double* lon); - int32 GPS_Math_NAD83_To_UTM_EN(double lat, double lon, double* E, - double* N, int32* zone, char* zc); - int32 GPS_Math_WGS84_To_UTM_EN(double lat, double lon, double* E, - double* N, int32* zone, char* zc); +int32_t GPS_Math_NAD83_To_UTM_EN(double lat, double lon, double* E, + double* N, int32_t* zone, char* zc); +int32_t GPS_Math_WGS84_To_UTM_EN(double lat, double lon, double* E, + double* N, int32_t* zone, char* zc); - int32 GPS_Math_UTM_EN_To_WGS84(double* lat, double* lon, double E, - double N, int32 zone, char zc); - int32 GPS_Math_UTM_EN_To_NAD83(double* lat, double* lon, double E, - double N, int32 zone, char zc); +int32_t GPS_Math_UTM_EN_To_WGS84(double* lat, double* lon, double E, + double N, int32_t zone, char zc); +int32_t GPS_Math_UTM_EN_To_NAD83(double* lat, double* lon, double E, + double N, int32_t zone, char zc); - int32 GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, - double* N, int32* zone, char* zc, int n); - int32 GPS_Math_UTM_EN_To_Known_Datum(double* lat, double* lon, double E, - double N, int32 zone, char zc, int n); +int32_t GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, + double* N, int32_t* zone, char* zc, int n); +int32_t GPS_Math_UTM_EN_To_Known_Datum(double* lat, double* lon, double E, + double N, int32_t zone, char zc, int n); void GPS_Math_Swiss_LatLon_To_EN(double phi, double lambda, double* E, double* N,double phi0,double lambda0, @@ -129,11 +129,11 @@ double* lambda, double phi0, double M0, double E0, double N0, double a, double b); - int32 GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, +int32_t GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, double* N); void GPS_Math_ICS_EN_To_WGS84(double E, double N, double* lat, double* lon); - int32 GPS_Math_WGS84_To_Swiss_EN(double phi, double lambda, double* E, double* N); +int32_t GPS_Math_WGS84_To_Swiss_EN(double phi, double lambda, double* E, double* N); void GPS_Math_Swiss_EN_To_WGS84(double E, double N, double* lat, double* lon); void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, @@ -141,8 +141,8 @@ double* Lat, double* Lon, double lambda0, double E0, double N0); - int32 GPS_Lookup_Datum_Index(const char* n); - int32 GPS_Lookup_Datum_Index(const QString& n); +int32_t GPS_Lookup_Datum_Index(const char* n); +int32_t GPS_Lookup_Datum_Index(const QString& n); const char* GPS_Math_Get_Datum_Name(int datum_index); #endif // JEEPS_GPSMATH_H_INCLUDED_ diff --git a/jeeps/gpsmem.cc b/jeeps/gpsmem.cc index 5489345ae..4757d9e79 100644 --- a/jeeps/gpsmem.cc +++ b/jeeps/gpsmem.cc @@ -167,7 +167,7 @@ void GPS_Track_Del(GPS_PTrack* thys) GPS_PWay GPS_Way_New() { GPS_PWay ret; - int32 i; + int32_t i; if (!(ret=(GPS_PWay)xcalloc(sizeof(GPS_OWay),1))) { perror("malloc"); diff --git a/jeeps/gpsport.h b/jeeps/gpsport.h index 3646a3e67..c161ee5d3 100644 --- a/jeeps/gpsport.h +++ b/jeeps/gpsport.h @@ -15,9 +15,5 @@ typedef unsigned char UC; typedef uint16_t US; -typedef uint16_t uint16; -typedef int16_t int16; -typedef uint32_t uint32; -typedef int32_t int32; #endif // JEEPS_GPSPORT_H_INCLUDED_ diff --git a/jeeps/gpsprot.cc b/jeeps/gpsprot.cc index f61bcf88d..fbf2b596c 100644 --- a/jeeps/gpsprot.cc +++ b/jeeps/gpsprot.cc @@ -29,9 +29,9 @@ #define GPS_TAGUNK 20 /* Storage for any unknown tags */ -static int32 gps_tag_unknown[GPS_TAGUNK]; -static int32 gps_tag_data_unknown[GPS_TAGUNK]; -static int32 gps_n_tag_unknown = 0; +static int32_t gps_tag_unknown[GPS_TAGUNK]; +static int32_t gps_tag_data_unknown[GPS_TAGUNK]; +static int32_t gps_n_tag_unknown = 0; COMMANDDATA COMMAND_ID[2]= { @@ -343,9 +343,9 @@ US GPS_Protocol_Version_Change(US id, US version) ** @return [int32] Success ************************************************************************/ -int32 GPS_Protocol_Table_Set(US id) +int32_t GPS_Protocol_Table_Set(US id) { - int32 i; + int32_t i; US v; i=0; @@ -411,7 +411,7 @@ void GPS_Protocol_Error(US tag, US data) void GPS_Unknown_Protocol_Print() { - int32 i; + int32_t i; (void) fprintf(stdout,"\nUnknown protocols: "); if (!gps_n_tag_unknown) { diff --git a/jeeps/gpsprot.h b/jeeps/gpsprot.h index 5a2a3cc6c..12d45b55d 100644 --- a/jeeps/gpsprot.h +++ b/jeeps/gpsprot.h @@ -62,7 +62,7 @@ #define pA010 10 #define pA011 11 - COMMON int32 gps_device_command; + COMMON int32_t gps_device_command; struct COMMANDDATA { @@ -99,20 +99,20 @@ * Waypoint Transfer Protocol */ #define pA100 100 - COMMON int32 gps_waypt_transfer; + COMMON int32_t gps_waypt_transfer; /* * Waypoint category transfer protocol */ #define pA101 101 - COMMON int32 gps_category_transfer; + COMMON int32_t gps_category_transfer; /* * Route Transfer Protocol */ #define pA200 200 #define pA201 201 - COMMON int32 gps_route_transfer; + COMMON int32_t gps_route_transfer; /* * Track Log Transfer Protocol @@ -121,26 +121,26 @@ #define pA301 301 #define pA302 302 #define pA304 304 - COMMON int32 gps_trk_transfer; + COMMON int32_t gps_trk_transfer; /* * Proximity Waypoint Transfer Protocol */ #define pA400 400 - COMMON int32 gps_prx_waypt_transfer; + COMMON int32_t gps_prx_waypt_transfer; /* * Almanac Transfer Protocol */ #define pA500 500 - COMMON int32 gps_almanac_transfer; + COMMON int32_t gps_almanac_transfer; /* * Date Time Transfer */ #define pA600 600 - COMMON int32 gps_date_time_transfer; + COMMON int32_t gps_date_time_transfer; /* * FlightBook Transfer Protocol @@ -152,42 +152,42 @@ * Position */ #define pA700 700 - COMMON int32 gps_position_transfer; + COMMON int32_t gps_position_transfer; /* * Pvt */ #define pA800 800 - COMMON int32 gps_pvt_transfer; + COMMON int32_t gps_pvt_transfer; /* * Lap Data Transfer */ #define pA906 906 - COMMON int32 gps_lap_transfer; + COMMON int32_t gps_lap_transfer; /* * Various fitness related */ #define pA1000 1000 - COMMON int32 gps_run_transfer; + COMMON int32_t gps_run_transfer; #define pA1002 1002 - COMMON int32 gps_workout_transfer; + COMMON int32_t gps_workout_transfer; #define pA1004 1004 - COMMON int32 gps_user_profile_transfer; + COMMON int32_t gps_user_profile_transfer; #define pA1005 1005 - COMMON int32 gps_workout_limits_transfer; + COMMON int32_t gps_workout_limits_transfer; #define pA1006 1006 - COMMON int32 gps_course_transfer; + COMMON int32_t gps_course_transfer; #define pA1007 1007 - COMMON int32 gps_course_lap_transfer; + COMMON int32_t gps_course_lap_transfer; #define pA1008 1008 - COMMON int32 gps_course_point_transfer; + COMMON int32_t gps_course_point_transfer; #define pA1009 1009 - COMMON int32 gps_course_limits_transfer; + COMMON int32_t gps_course_limits_transfer; #define pA1012 1012 - COMMON int32 gps_course_trk_transfer; + COMMON int32_t gps_course_trk_transfer; /* * Waypoint D Type @@ -209,14 +209,14 @@ #define pD154 154 #define pD155 155 - COMMON int32 gps_rte_type; - COMMON int32 gps_waypt_type; + COMMON int32_t gps_rte_type; + COMMON int32_t gps_waypt_type; /* * Waypoint category types */ #define pD120 120 - COMMON int32 gps_category_type; + COMMON int32_t gps_category_type; /* * Rte Header Type @@ -224,14 +224,14 @@ #define pD200 200 #define pD201 201 #define pD202 202 - COMMON int32 gps_rte_hdr_type; + COMMON int32_t gps_rte_hdr_type; /* * Rte Link Type */ #define pD210 210 - COMMON int32 gps_rte_link_type; + COMMON int32_t gps_rte_link_type; /* @@ -242,8 +242,8 @@ #define pD302 302 #define pD303 303 #define pD304 304 - COMMON int32 gps_trk_type; - COMMON int32 gps_run_crs_trk_type; + COMMON int32_t gps_trk_type; + COMMON int32_t gps_run_crs_trk_type; /* @@ -252,8 +252,8 @@ #define pD310 310 #define pD311 311 #define pD312 312 - COMMON int32 gps_trk_hdr_type; - COMMON int32 gps_run_crs_trk_hdr_type; + COMMON int32_t gps_trk_hdr_type; + COMMON int32_t gps_run_crs_trk_hdr_type; @@ -264,7 +264,7 @@ #define pD403 403 #define pD450 450 - COMMON int32 gps_prx_waypt_type; + COMMON int32_t gps_prx_waypt_type; /* @@ -275,7 +275,7 @@ #define pD550 550 #define pD551 551 - COMMON int32 gps_almanac_type; + COMMON int32_t gps_almanac_type; /* @@ -283,7 +283,7 @@ */ #define pD600 600 - COMMON int32 gps_date_time_type; + COMMON int32_t gps_date_time_type; @@ -292,7 +292,7 @@ */ #define pD700 700 - COMMON int32 gps_position_type; + COMMON int32_t gps_position_type; @@ -301,7 +301,7 @@ */ #define pD800 800 - COMMON int32 gps_pvt_type; + COMMON int32_t gps_pvt_type; /* * Lap Data Type @@ -311,7 +311,7 @@ #define pD1011 1011 #define pD1015 1015 - COMMON int32 gps_lap_type; + COMMON int32_t gps_lap_type; /* * Various fitness related @@ -319,24 +319,24 @@ #define pD1000 1000 #define pD1009 1009 #define pD1010 1010 - COMMON int32 gps_run_type; + COMMON int32_t gps_run_type; #define pD1002 1002 #define pD1008 1008 - COMMON int32 gps_workout_type; + COMMON int32_t gps_workout_type; #define pD1003 1003 - COMMON int32 gps_workout_occurrence_type; + COMMON int32_t gps_workout_occurrence_type; #define pD1004 1004 - COMMON int32 gps_user_profile_type; + COMMON int32_t gps_user_profile_type; #define pD1005 1005 - COMMON int32 gps_workout_limits_type; + COMMON int32_t gps_workout_limits_type; #define pD1006 1006 - COMMON int32 gps_course_type; + COMMON int32_t gps_course_type; #define pD1007 1007 - COMMON int32 gps_course_lap_type; + COMMON int32_t gps_course_lap_type; #define pD1012 1012 - COMMON int32 gps_course_point_type; + COMMON int32_t gps_course_point_type; #define pD1013 1013 - COMMON int32 gps_course_limits_type; + COMMON int32_t gps_course_limits_type; /* * Link protocol type @@ -345,29 +345,29 @@ #define pL001 1 #define pL002 2 - COMMON int32 gps_link_type; + COMMON int32_t gps_link_type; struct GPS_MODEL_PROTOCOL { US id; - int32 link; - int32 command; - int32 wayptt; - int32 wayptd; - int32 rtea; - int32 rted0; - int32 rted1; - int32 trka; - int32 trkd; - int32 prxa; - int32 prxd; - int32 alma; - int32 almd; + int32_t link; + int32_t command; + int32_t wayptt; + int32_t wayptd; + int32_t rtea; + int32_t rted0; + int32_t rted1; + int32_t trka; + int32_t trkd; + int32_t prxa; + int32_t prxd; + int32_t alma; + int32_t almd; }; US GPS_Protocol_Version_Change(US id, US version); - COMMON int32 GPS_Protocol_Table_Set(US id); + COMMON int32_t GPS_Protocol_Table_Set(US id); void GPS_Protocol_Error(US tag, US data); void GPS_Unknown_Protocol_Print(); diff --git a/jeeps/gpsread.cc b/jeeps/gpsread.cc index db9aef4bd..048e58ce4 100644 --- a/jeeps/gpsread.cc +++ b/jeeps/gpsread.cc @@ -69,10 +69,10 @@ time_t GPS_Time_Now() ** @return [int32] number of bytes read **********************************************************************/ -int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet) +int32_t GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet) { time_t start; - int32 len = 0; + int32_t len = 0; UC u; UC* p; UC chk = 0, chk_read; diff --git a/jeeps/gpsread.h b/jeeps/gpsread.h index 6bee1e7ab..c5937234c 100644 --- a/jeeps/gpsread.h +++ b/jeeps/gpsread.h @@ -5,7 +5,7 @@ #include "jeeps/gps.h" time_t GPS_Time_Now(); - int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet); +int32_t GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet); bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_Packet *tra, GPS_Packet *rec); #endif // JEEPS_GPSREAD_H_INCLUDED_ diff --git a/jeeps/gpsrqst.cc b/jeeps/gpsrqst.cc index 82a28adbc..79b2db57f 100644 --- a/jeeps/gpsrqst.cc +++ b/jeeps/gpsrqst.cc @@ -25,8 +25,8 @@ #include "jeeps/gps.h" -static int32 GPS_A600_Rqst(gpsdevh* fd, time_t Time); -static int32 GPS_A700_Rqst(gpsdevh* fd, double lat, double lon); +static int32_t GPS_A600_Rqst(gpsdevh* fd, time_t Time); +static int32_t GPS_A700_Rqst(gpsdevh* fd, double lat, double lon); @@ -40,7 +40,7 @@ static int32 GPS_A700_Rqst(gpsdevh* fd, double lat, double lon); ** @return [int32] true if OK ************************************************************************/ -int32 GPS_Rqst_Send_Time(gpsdevh* fd, time_t Time) +int32_t GPS_Rqst_Send_Time(gpsdevh* fd, time_t Time) { time_t ret=0; @@ -67,7 +67,7 @@ int32 GPS_Rqst_Send_Time(gpsdevh* fd, time_t Time) ** ** @return [int32] success ************************************************************************/ -static int32 GPS_A600_Rqst(gpsdevh* fd, time_t Time) +static int32_t GPS_A600_Rqst(gpsdevh* fd, time_t Time) { GPS_Packet tra; GPS_Packet rec; @@ -104,9 +104,9 @@ static int32 GPS_A600_Rqst(gpsdevh* fd, time_t Time) ** @return [int32] success ************************************************************************/ -int32 GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon) +int32_t GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon) { - int32 ret=0; + int32_t ret = 0; switch (gps_position_transfer) { case pA700: @@ -132,7 +132,7 @@ int32 GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon) ** ** @return [int32] success ************************************************************************/ -static int32 GPS_A700_Rqst(gpsdevh* fd, double lat, double lon) +static int32_t GPS_A700_Rqst(gpsdevh* fd, double lat, double lon) { GPS_Packet tra; GPS_Packet rec; diff --git a/jeeps/gpsrqst.h b/jeeps/gpsrqst.h index c97e01354..601a9ea65 100644 --- a/jeeps/gpsrqst.h +++ b/jeeps/gpsrqst.h @@ -4,8 +4,8 @@ #include "jeeps/gps.h" - int32 GPS_Rqst_Send_Time(gpsdevh* fd, time_t Time); - int32 GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon); +int32_t GPS_Rqst_Send_Time(gpsdevh* fd, time_t Time); +int32_t GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon); #endif // JEEPS_GPSRQST_H_INCLUDED_ diff --git a/jeeps/gpssend.cc b/jeeps/gpssend.cc index 07ff72e3d..55eaa5752 100644 --- a/jeeps/gpssend.cc +++ b/jeeps/gpssend.cc @@ -65,7 +65,7 @@ Build_Serial_Packet(const GPS_Packet& in, GPS_Serial_Packet* out) chk -= in.n; - for (uint32 i = 0; i < in.n; ++i) { + for (uint32_t i = 0; i < in.n; ++i) { if (*p == DLE) { ++bytes; *q++ = DLE; @@ -116,9 +116,9 @@ DiagS(void* buf, size_t sz) ** @return [int32] number of bytes in the packet ************************************************************************/ -int32 GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet) +int32_t GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet) { - int32 ret; + int32_t ret; const char* m1, *m2; GPS_Serial_Packet ser_pkt; UC ser_pkt_data[MAX_GPS_PACKET_SIZE * sizeof(UC)]; diff --git a/jeeps/gpssend.h b/jeeps/gpssend.h index 3f3b12e8d..a4954a9e4 100644 --- a/jeeps/gpssend.h +++ b/jeeps/gpssend.h @@ -6,10 +6,10 @@ #define GPS_ARB_LEN 1024 - int32 GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet); +int32_t GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet); bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); - void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32 n); + void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32_t n); #endif // JEEPS_GPSSEND_H_INCLUDED_ diff --git a/jeeps/gpsserial.cc b/jeeps/gpsserial.cc index 2a3cb4b2e..164054bc3 100644 --- a/jeeps/gpsserial.cc +++ b/jeeps/gpsserial.cc @@ -91,7 +91,7 @@ void GPS_Serial_Error(const char* fmt, ...) va_end(ap); } -int32 GPS_Serial_On(const char* port, gpsdevh** dh) +int32_t GPS_Serial_On(const char* port, gpsdevh** dh) { DCB tio; COMMTIMEOUTS timeout; @@ -161,7 +161,7 @@ int32 GPS_Serial_On(const char* port, gpsdevh** dh) return 1; } -int32 GPS_Serial_Off(gpsdevh* dh) +int32_t GPS_Serial_Off(gpsdevh* dh) { win_serial_data* wsd = (win_serial_data*)dh; CloseHandle(wsd->comport); @@ -170,7 +170,7 @@ int32 GPS_Serial_Off(gpsdevh* dh) return 1; } -int32 GPS_Serial_Chars_Ready(gpsdevh* dh) +int32_t GPS_Serial_Chars_Ready(gpsdevh* dh) { COMSTAT lpStat; DWORD lpErrors; @@ -180,7 +180,7 @@ int32 GPS_Serial_Chars_Ready(gpsdevh* dh) return (lpStat.cbInQue > 0); } -int32 GPS_Serial_Wait(gpsdevh* fd) +int32_t GPS_Serial_Wait(gpsdevh* fd) { /* Wait a short time before testing if data is ready. * The GPS II, in particular, has a noticable time responding @@ -193,12 +193,12 @@ int32 GPS_Serial_Wait(gpsdevh* fd) return GPS_Serial_Chars_Ready(fd); } -int32 GPS_Serial_Flush(gpsdevh* /* fd */) +int32_t GPS_Serial_Flush(gpsdevh* /* fd */) { return 1; } -int32 GPS_Serial_Write(gpsdevh* dh, const void* obuf, int size) +int32_t GPS_Serial_Write(gpsdevh* dh, const void* obuf, int size) { win_serial_data* wsd = (win_serial_data*)dh; DWORD len; @@ -220,7 +220,7 @@ int32 GPS_Serial_Write(gpsdevh* dh, const void* obuf, int size) return len; } -int32 GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size) +int32_t GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size) { DWORD cnt = 0; win_serial_data* wsd = (win_serial_data*)dh; @@ -231,7 +231,7 @@ int32 GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size) // Based on information by Kolesár András from // http://www.manualslib.com/manual/413938/Garmin-Gps-18x.html?page=32 -int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br) +int32_t GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br) { static UC data[4]; GPS_Packet tra; @@ -326,13 +326,13 @@ typedef struct { ** ** Open a serial port 8bits 1 stop bit 9600 baud ** -** @param [w] fd [int32 *] file descriptor +** @param [w] fd [int32_t *] file descriptor ** @param [r] port [const char *] port e.g. ttyS1 ** -** @return [int32] false upon error +** @return [int32_t] false upon error ************************************************************************/ -int32 GPS_Serial_Open(gpsdevh* dh, const char* port) +int32_t GPS_Serial_Open(gpsdevh* dh, const char* port) { struct termios tty; if (global_opts.debug_level >= 2) fprintf(stderr, "GPS Serial Open at %d\n", gps_baud_rate); @@ -394,7 +394,7 @@ void GPS_Serial_Error(const char* fmt, ...) va_end(ap); } -int32 GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size) +int32_t GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size) { auto* psd = (posix_serial_data*)dh; #if GARMULATOR @@ -426,7 +426,7 @@ int32 GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size) #endif } -int32 GPS_Serial_Write(gpsdevh* dh, const void* obuf, int size) +int32_t GPS_Serial_Write(gpsdevh* dh, const void* obuf, int size) { auto* psd = (posix_serial_data*)dh; return write(psd->fd, obuf, size); @@ -437,11 +437,11 @@ int32 GPS_Serial_Write(gpsdevh* dh, const void* obuf, int size) ** ** Flush the serial lines ** -** @param [w] fd [int32] file descriptor +** @param [w] fd [int32_t] file descriptor ** -** @return [int32] false upon error +** @return [int32_t] false upon error ************************************************************************/ -int32 GPS_Serial_Flush(gpsdevh* fd) +int32_t GPS_Serial_Flush(gpsdevh* fd) { auto* psd = (posix_serial_data*)fd; @@ -460,13 +460,13 @@ int32 GPS_Serial_Flush(gpsdevh* fd) ** ** Close serial port ** -** @param [r] fd [int32 ] file descriptor +** @param [r] fd [int32_t ] file descriptor ** @param [r] port [const char *] port e.g. ttyS1 ** -** @return [int32] false upon error +** @return [int32_t] false upon error ************************************************************************/ -int32 GPS_Serial_Close(gpsdevh* fd) +int32_t GPS_Serial_Close(gpsdevh* fd) { auto* psd = (posix_serial_data*)fd; @@ -490,17 +490,17 @@ int32 GPS_Serial_Close(gpsdevh* fd) ** ** Query port to see if characters are waiting to be read ** -** @param [r] fd [int32 ] file descriptor +** @param [r] fd [int32_t ] file descriptor ** -** @return [int32] true if chars waiting +** @return [int32_t] true if chars waiting ************************************************************************/ -int32 GPS_Serial_Chars_Ready(gpsdevh* dh) +int32_t GPS_Serial_Chars_Ready(gpsdevh* dh) { fd_set rec; struct timeval t; auto* psd = (posix_serial_data*)dh; - int32 fd = psd->fd; + int32_t fd = psd->fd; #if GARMULATOR static foo; @@ -533,12 +533,12 @@ int32 GPS_Serial_Chars_Ready(gpsdevh* dh) ** appears to be around 40-50 milliseconds. Doubling the value is to ** allow some leeway. ** -** @param [r] fd [int32 ] file descriptor +** @param [r] fd [int32_t ] file descriptor ** -** @return [int32] true if serial chars waiting +** @return [int32_t] true if serial chars waiting ************************************************************************/ -int32 GPS_Serial_Wait(gpsdevh* dh) +int32_t GPS_Serial_Wait(gpsdevh* dh) { fd_set rec; struct timeval t; @@ -565,12 +565,12 @@ int32 GPS_Serial_Wait(gpsdevh* dh) ** Set up port ** ** @param [r] port [const char *] port -** @param [w] fd [int32 *] file descriptor +** @param [w] fd [int32_t *] file descriptor ** -** @return [int32] success +** @return [int32_t] success ************************************************************************/ -int32 GPS_Serial_On(const char* port, gpsdevh** dh) +int32_t GPS_Serial_On(const char* port, gpsdevh** dh) { auto* psd = (posix_serial_data*) xcalloc(sizeof(posix_serial_data), 1); *dh = (gpsdevh*) psd; @@ -591,12 +591,12 @@ int32 GPS_Serial_On(const char* port, gpsdevh** dh) ** Done with port ** ** @param [r] port [const char *] port -** @param [r] fd [int32 ] file descriptor +** @param [r] fd [int32_t ] file descriptor ** -** @return [int32] success +** @return [int32_t] success ************************************************************************/ -int32 GPS_Serial_Off(gpsdevh* dh) +int32_t GPS_Serial_Off(gpsdevh* dh) { if (!GPS_Serial_Close(dh)) { @@ -609,7 +609,7 @@ int32 GPS_Serial_Off(gpsdevh* dh) // Based on information by Kolesár András from // http://www.manualslib.com/manual/413938/Garmin-Gps-18x.html?page=32 -int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br) +int32_t GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br) { struct termios tty; diff --git a/jeeps/gpsserial.h b/jeeps/gpsserial.h index c960234d3..aa871b3a7 100644 --- a/jeeps/gpsserial.h +++ b/jeeps/gpsserial.h @@ -7,21 +7,21 @@ #define usecDELAY 180000 /* Microseconds before GPS sends A001 */ #define DEFAULT_BAUD 9600 - int32 GPS_Serial_Chars_Ready(gpsdevh* fd); +int32_t GPS_Serial_Chars_Ready(gpsdevh* fd); // int32 GPS_Serial_Close(int32 fd, const char *port); // int32 GPS_Serial_Open(int32 *fd, const char *port); // int32 GPS_Serial_Open_NMEA(int32 *fd, const char *port); // int32 GPS_Serial_Restoretty(const char *port); // int32 GPS_Serial_Savetty(const char *port); - int32 GPS_Serial_On(const char* port, gpsdevh** fd); - int32 GPS_Serial_Off(gpsdevh* fd); - int32 GPS_Serial_Wait(gpsdevh* fd); - int32 GPS_Serial_Flush(gpsdevh* fd); +int32_t GPS_Serial_On(const char* port, gpsdevh** fd); +int32_t GPS_Serial_Off(gpsdevh* fd); +int32_t GPS_Serial_Wait(gpsdevh* fd); +int32_t GPS_Serial_Flush(gpsdevh* fd); // int32 GPS_Serial_On_NMEA(const char *port, gpsdevh **fd); - int32 GPS_Serial_Read(gpsdevh* fd, void* ibuf, int size); - int32 GPS_Serial_Write(gpsdevh* fd, const void* obuf, int size); +int32_t GPS_Serial_Read(gpsdevh* fd, void* ibuf, int size); +int32_t GPS_Serial_Write(gpsdevh* fd, const void* obuf, int size); -int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br); +int32_t GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br); #endif // JEEPS_GPSSERIAL_H_INCLUDED_ diff --git a/jeeps/gpsusbint.h b/jeeps/gpsusbint.h index 2e557d1c5..2689f5a42 100644 --- a/jeeps/gpsusbint.h +++ b/jeeps/gpsusbint.h @@ -24,8 +24,8 @@ #ifndef JEEPS_GPSUSBINT_H_INCLUDED_ #define JEEPS_GPSUSBINT_H_INCLUDED_ -int32 GPS_Packet_Read_usb(gpsdevh* fd, GPS_Packet* packet, int eatbulk); -int32 GPS_Write_Packet_usb(gpsdevh* fd, const GPS_Packet& packet); +int32_t GPS_Packet_Read_usb(gpsdevh* fd, GPS_Packet* packet, int eatbulk); +int32_t GPS_Write_Packet_usb(gpsdevh* fd, const GPS_Packet& packet); #endif // JEEPS_GPSUSBINT_H_INCLUDED_ diff --git a/jeeps/gpsusbread.cc b/jeeps/gpsusbread.cc index 59d83c352..4a524be12 100644 --- a/jeeps/gpsusbread.cc +++ b/jeeps/gpsusbread.cc @@ -28,10 +28,10 @@ * Negative on error. * 1 if read success - even if empty packet. */ -int32 GPS_Packet_Read_usb(gpsdevh* /*unused*/, GPS_Packet* packet, int eat_bulk) +int32_t GPS_Packet_Read_usb(gpsdevh* /*unused*/, GPS_Packet* packet, int eat_bulk) { - int32 n; - int32 payload_size; + int32_t n; + int32_t payload_size; garmin_usb_packet pkt; diff --git a/jeeps/gpsusbsend.cc b/jeeps/gpsusbsend.cc index 90da93d05..9aba7b534 100644 --- a/jeeps/gpsusbsend.cc +++ b/jeeps/gpsusbsend.cc @@ -25,7 +25,7 @@ #include #include -int32 +int32_t GPS_Write_Packet_usb(gpsdevh* /*unused*/, const GPS_Packet& packet) { garmin_usb_packet gp; diff --git a/jeeps/gpsutil.cc b/jeeps/gpsutil.cc index 68c5f926d..2628badb7 100644 --- a/jeeps/gpsutil.cc +++ b/jeeps/gpsutil.cc @@ -26,14 +26,14 @@ #include #include -static int32 gps_endian_called=0; -static int32 GPS_Little=0; +static int32_t gps_endian_called = 0; +static int32_t GPS_Little = 0; -int32 gps_warning = 0; -int32 gps_error = 0; -int32 gps_user = 0; -int32 gps_show_bytes = 0; -int32 gps_errno = 0; +int32_t gps_warning = 0; +int32_t gps_error = 0; +int32_t gps_user = 0; +int32_t gps_show_bytes = 0; +int32_t gps_errno = 0; /* @func GPS_Util_Little *********************************************** ** @@ -42,11 +42,11 @@ int32 gps_errno = 0; ** @return [int32] true if little-endian ************************************************************************/ -int32 GPS_Util_Little() +int32_t GPS_Util_Little() { static union lb { - char chars[sizeof(int32)]; - int32 i; + char chars[sizeof(int32_t)]; + int32_t i; } data; @@ -130,7 +130,7 @@ double GPS_Util_Get_Double(const UC* s) { double ret; UC* p; - int32 i; + int32_t i; p = (UC*)&ret; @@ -140,7 +140,7 @@ double GPS_Util_Get_Double(const UC* s) *p++ = s[i]; } else - for (i=0; i<(int32)sizeof(double); ++i) { + for (i=0; i<(int32_t)sizeof(double); ++i) { *p++ = s[i]; } @@ -161,7 +161,7 @@ double GPS_Util_Get_Double(const UC* s) void GPS_Util_Put_Double(UC* s, const double v) { - int32 i; + int32_t i; const auto* p = reinterpret_cast(&v); @@ -170,7 +170,7 @@ void GPS_Util_Put_Double(UC* s, const double v) s[i] = *p++; } else - for (i=0; i<(int32)sizeof(double); ++i) { + for (i=0; i<(int32_t)sizeof(double); ++i) { s[i] = *p++; } @@ -187,21 +187,21 @@ void GPS_Util_Put_Double(UC* s, const double v) ** @return [int32] value ************************************************************************/ -int32 GPS_Util_Get_Int(const UC* s) +int32_t GPS_Util_Get_Int(const UC* s) { - int32 ret; + int32_t ret; UC* p; - int32 i; + int32_t i; p = (UC*)&ret; if (!GPS_Little) - for (i=sizeof(int32)-1; i>-1; --i) { + for (i=sizeof(int32_t)-1; i>-1; --i) { *p++ = s[i]; } else - for (i=0; i<(int32)sizeof(int32); ++i) { + for (i=0; i<(int32_t)sizeof(int32_t); ++i) { *p++ = s[i]; } @@ -220,18 +220,18 @@ int32 GPS_Util_Get_Int(const UC* s) ** @return [void] ************************************************************************/ -void GPS_Util_Put_Int(UC* s, const int32 v) +void GPS_Util_Put_Int(UC* s, const int32_t v) { - int32 i; + int32_t i; const auto* p = reinterpret_cast(&v); if (!GPS_Little) - for (i=sizeof(int32)-1; i>-1; --i) { + for (i=sizeof(int32_t)-1; i>-1; --i) { s[i] = *p++; } else - for (i=0; i<(int32)sizeof(int32); ++i) { + for (i=0; i<(int32_t)sizeof(int32_t); ++i) { s[i] = *p++; } @@ -247,21 +247,21 @@ void GPS_Util_Put_Int(UC* s, const int32 v) ** @return [uint32] value ************************************************************************/ -uint32 GPS_Util_Get_Uint(const UC* s) +uint32_t GPS_Util_Get_Uint(const UC* s) { - uint32 ret; + uint32_t ret; UC* p; - int32 i; + int32_t i; p = (UC*)&ret; if (!GPS_Little) - for (i=sizeof(uint32)-1; i>-1; --i) { + for (i=sizeof(uint32_t)-1; i>-1; --i) { *p++ = s[i]; } else - for (i=0; i<(int32)sizeof(uint32); ++i) { + for (i=0; i<(int32_t)sizeof(uint32_t); ++i) { *p++ = s[i]; } @@ -280,18 +280,18 @@ uint32 GPS_Util_Get_Uint(const UC* s) ** @return [void] ************************************************************************/ -void GPS_Util_Put_Uint(UC* s, const uint32 v) +void GPS_Util_Put_Uint(UC* s, const uint32_t v) { - int32 i; + int32_t i; const auto* p = reinterpret_cast(&v); if (!GPS_Little) - for (i=sizeof(uint32)-1; i>-1; --i) { + for (i=sizeof(uint32_t)-1; i>-1; --i) { s[i] = *p++; } else - for (i=0; i<(int32)sizeof(uint32); ++i) { + for (i=0; i<(int32_t)sizeof(uint32_t); ++i) { s[i] = *p++; } @@ -311,7 +311,7 @@ float GPS_Util_Get_Float(const UC* s) { float ret; UC* p; - int32 i; + int32_t i; p = (UC*)&ret; @@ -321,7 +321,7 @@ float GPS_Util_Get_Float(const UC* s) *p++ = s[i]; } else - for (i=0; i<(int32)sizeof(float); ++i) { + for (i=0; i<(int32_t)sizeof(float); ++i) { *p++ = s[i]; } @@ -342,7 +342,7 @@ float GPS_Util_Get_Float(const UC* s) void GPS_Util_Put_Float(UC* s, const float v) { - int32 i; + int32_t i; const auto* p = reinterpret_cast(&v); @@ -351,7 +351,7 @@ void GPS_Util_Put_Float(UC* s, const float v) s[i] = *p++; } else - for (i=0; i<(int32)sizeof(float); ++i) { + for (i=0; i<(int32_t)sizeof(float); ++i) { s[i] = *p++; } @@ -637,7 +637,7 @@ void GPS_Enable_User() ** @@ ****************************************************************************/ -void GPS_Diagnose(int32 c) +void GPS_Diagnose(int32_t c) { if (!gps_show_bytes) { return; diff --git a/jeeps/gpsutil.h b/jeeps/gpsutil.h index 212742833..87f47e23d 100644 --- a/jeeps/gpsutil.h +++ b/jeeps/gpsutil.h @@ -4,20 +4,20 @@ #include "jeeps/gps.h" - int32 GPS_Util_Little(); +int32_t GPS_Util_Little(); US GPS_Util_Get_Short(const UC* s); void GPS_Util_Put_Short(UC* s, US v); - int32 GPS_Util_Get_Int(const UC* s); - void GPS_Util_Put_Int(UC* s, int32 v); +int32_t GPS_Util_Get_Int(const UC* s); + void GPS_Util_Put_Int(UC* s, int32_t v); double GPS_Util_Get_Double(const UC* s); void GPS_Util_Put_Double(UC* s, double v); float GPS_Util_Get_Float(const UC* s); void GPS_Util_Put_Float(UC* s, float v); - void GPS_Util_Canon(int32 state); - int32 GPS_Util_Block(int32 fd, int32 state); - void GPS_Util_Put_Uint(UC* s, uint32 v); - uint32 GPS_Util_Get_Uint(const UC* s); + void GPS_Util_Canon(int32_t state); +int32_t GPS_Util_Block(int32_t fd, int32_t state); + void GPS_Util_Put_Uint(UC* s, uint32_t v); +uint32_t GPS_Util_Get_Uint(const UC* s); void GPS_Warning(const char* s); [[gnu::format(printf, 1, 2)]] void GPS_Error(const char* fmt, ...); @@ -30,7 +30,7 @@ [[gnu::format(printf, 1, 2)]] void GPS_User(const char* fmt, ...); void GPS_Disable_User(); void GPS_Enable_User(); - void GPS_Diagnose(int32 c); + void GPS_Diagnose(int32_t c); [[gnu::format(printf, 1, 2)]] void GPS_Diag(const char* fmt, ...); void GPS_Enable_Diagnose(); diff --git a/xcsv.cc b/xcsv.cc index 9123cf606..004781481 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -988,7 +988,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) { QString buff; double latitude, longitude; - int32 utmz; + int32_t utmz; double utme, utmn; char utmzc; From 66fa37eb30c3a2739b4dedb22c76290575297b16 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 15 Nov 2023 10:36:59 -0700 Subject: [PATCH 039/132] gpsmath isolation (#1218) gpsmath/gpsdatum/gpsproj don't have dependencies on the rest of jeeps. cleanup typedefs, macros, const tables. --- jeeps/gpsdatum.h | 457 +++++++++++++++++++++++------------------------ jeeps/gpsmath.cc | 187 ++++++++++--------- jeeps/gpsmath.h | 182 +++++++++---------- jeeps/gpsmem.h | 2 + jeeps/gpsproj.cc | 8 +- jeeps/gpsproj.h | 244 +++++++++++++------------ 6 files changed, 547 insertions(+), 533 deletions(-) diff --git a/jeeps/gpsdatum.h b/jeeps/gpsdatum.h index 4444797dd..2cfbb366a 100644 --- a/jeeps/gpsdatum.h +++ b/jeeps/gpsdatum.h @@ -2,235 +2,234 @@ #define JEEPS_GPSDATUM_H_INCLUDED_ - - typedef struct GPS_SEllipse { - const char* name; - double a; - double invf; - } GPS_OEllipse, *GPS_PEllipse; - - GPS_OEllipse GPS_Ellipse[]= { - { "Airy 1830", 6377563.396, 299.3249646 }, - { "Airy 1830 Modified", 6377340.189, 299.3249646 }, - { "Australian National", 6378160.000, 298.25 }, - { "Bessel 1841 (Namibia)", 6377483.865, 299.1528128 }, - { "Bessel 1841", 6377397.155, 299.1528128 }, - { "Clarke 1866", 6378206.400, 294.9786982 }, - { "Clarke 1880", 6378249.145, 293.465 }, - { "Everest (India 1830)", 6377276.345, 300.8017 }, - { "Everest (Sabah Sarawak)", 6377298.556, 300.8017 }, - { "Everest (India 1956)", 6377301.243, 300.8017 }, - { "Everest (Malaysia 1969)", 6377295.664, 300.8017 }, - { "Everest (Malay & Sing)", 6377304.063, 300.8017 }, - { "Everest (Pakistan)", 6377309.613, 300.8017 }, - { "Modified Fischer 1960", 6378155.000, 298.3 }, - { "Helmert 1906", 6378200.000, 298.3 }, - { "Hough 1960", 6378270.000, 297.0 }, - { "Indonesian 1974", 6378160.000, 298.247 }, - { "International 1924", 6378388.000, 297.0 }, - { "Krassovsky 1940", 6378245.000, 298.3 }, - { "GRS67", 6378160.000, 6356774.516 }, - { "GRS75", 6378140.000, 6356755.288 }, - { "GRS80", 6378137.000, 298.257222101 }, - { "S. American 1969", 6378160.000, 298.25 }, - { "WGS60", 6378165.000, 298.3 }, - { "WGS66", 6378145.000, 298.25 }, - { "WGS72", 6378135.000, 298.26 }, - { "WGS84", 6378137.000, 298.257223563 }, - { "Clarke 1880 (Benoit)", 6378300.789, 293.466 }, - }; - - - - typedef struct GPS_SDatum { - const char* name; - int ellipse; - double dx; - double dy; - double dz; - } GPS_ODatum, *GPS_PDatum; - - GPS_ODatum GPS_Datum[]= { - /* 000 */ { "Adindan", 6, -166, -15, 204 }, - /* 001 */ { "AFG", 18, -43, -163, 45 }, - /* 002 */ { "Ain-El-Abd", 17, -150, -251, -2 }, - /* 003 */ { "Alaska-NAD27", 5, -5, 135, 172 }, - /* 004 */ { "Alaska-Canada", 6, -9, 151, 185 }, - /* 005 */ { "Anna-1-Astro", 2, -491, -22, 435 }, - /* 006 */ { "ARC 1950 Mean", 6, -143, -90, -294 }, - /* 007 */ { "ARC 1960 Mean", 6, -160, -8, -300 }, - /* 008 */ { "Asc Island 58", 17, -207, 107, 52 }, - /* 009 */ { "Astro B4", 17, 114, -116, -333 }, - /* 010 */ { "Astro Beacon E", 17, 145, 75, -272 }, - /* 011 */ { "Astro pos 71/4", 17, -320, 550, -494 }, - /* 012 */ { "Astro stn 52", 17, 124, -234, -25 }, - /* 013 */ { "Australia Geo 1984", 2, -134, -48, 149 }, - /* 014 */ { "Bahamas NAD27", 6, -4, 154, 178 }, - /* 015 */ { "Bellevue IGN", 17, -127, -769, 472 }, - /* 016 */ { "Bermuda 1957", 6, -73, 213, 296 }, - /* 017 */ { "Bukit Rimpah", 4, -384, 664, -48 }, - /* 018 */ { "Camp_Area_Astro", 17, -104, -129, 239 }, - /* 019 */ { "Campo_Inchauspe", 17, -148, 136, 90 }, - /* 020 */ { "Canada_Mean(NAD27)", 5, -10, 158, 187 }, - /* 021 */ { "Canal_Zone_(NAD27)", 5, 0, 125, 201 }, - /* 022 */ { "Canton_Island_1966", 17, 298, -304, -375 }, - /* 023 */ { "Cape", 6, -136, -108, -292 }, - /* 024 */ { "Cape_Canaveral_mean", 5, -2, 150, 181 }, - /* 025 */ { "Carribean NAD27", 5, -7, 152, 178 }, - /* 026 */ { "Carthage", 6, -263, 6, 431 }, - /* 027 */ { "Cent America NAD27", 5 , 0, 125, 194 }, - /* 028 */ { "Chatham 1971", 17, 175, -38, 113 }, - /* 029 */ { "Chua Astro", 17, -134, 229, -29 }, - /* 030 */ { "Corrego Alegre", 17, -206, 172, -6 }, - /* 031 */ { "Cuba NAD27", 5, -9, 152, 178 }, - /* 032 */ { "Cyprus", 17, -104, -101, -140 }, - /* 033 */ { "Djakarta(Batavia)", 4, -377, 681, -50 }, - /* 034 */ { "DOS 1968", 17, 230, -199, -752 }, - /* 035 */ { "Easter lsland 1967", 17, 211, 147, 111 }, - /* 036 */ { "Egypt", 17, -130, -117, -151 }, - /* 037 */ { "European 1950", 17, -87, -96, -120 }, - /* 038 */ { "European 1950 mean", 17, -87, -98, -121 }, - /* 039 */ { "European 1979 mean", 17, -86, -98, -119 }, - /* 040 */ { "Finnish Nautical", 17, -78, -231, -97 }, - /* 041 */ { "Gandajika Base", 17, -133, -321, 50 }, - /* 042 */ { "Geodetic Datum 49", 17, 84, -22, 209 }, - /* 043 */ { "Ghana", 26, 0, 0, 0 }, - /* 044 */ { "Greenland NAD27", 5, 11, 114, 195 }, - /* 045 */ { "Guam 1963", 5, -100, -248, 259 }, - /* 046 */ { "Gunung Segara", 4, -403, 684, 41 }, - /* 047 */ { "Gunung Serindung 1962", 26, 0, 0, 0 }, - /* 048 */ { "GUX1 Astro", 17, 252, -209, -751 }, - /* 049 */ { "Herat North", 17, -333, -222, 114 }, - /* 050 */ { "Hjorsey 1955", 17, -73, 46, 86 }, - /* 051 */ { "Hong Kong 1963", 17, -156, -271, -189 }, - /* 052 */ { "Hu-Tzu-Shan", 17, -634, -549, -201 }, - /* 053 */ { "Indian", 9, 289, 734, 257 }, - /* 054 */ { "Iran", 17, -117, -132, -164 }, - /* 055 */ { "Ireland 1965", 1, 506, -122, 611 }, - /* 056 */ { "ISTS 073 Astro 69", 17, 208, -435, -229 }, - /* 057 */ { "Johnston Island 61", 17, 191, -77, -204 }, - /* 058 */ { "Kandawala", 7, -97, 787, 86 }, - /* 059 */ { "Kerguelen Island", 17, 145, -187, 103 }, - /* 060 */ { "Kertau 48", 11, -11, 851, 5 }, - /* 061 */ { "L.C. 5 Astro", 5, 42, 124, 147 }, - /* 062 */ { "La Reunion", 17, 94, -948, -1262 }, - /* 063 */ { "Liberia 1964", 6, -90, 40, 88 }, - /* 064 */ { "Luzon", 5, -133, -77, -51 }, - /* 065 */ { "Mahe 1971", 6, 41, -220, -134 }, - /* 066 */ { "Marco Astro", 17, -289, -124, 60 }, - /* 067 */ { "Masirah Is. Nahrwan", 6, -247, -148, 369 }, - /* 068 */ { "Massawa", 4, 639, 405, 60 }, - /* 069 */ { "Merchich", 6, 31, 146, 47 }, - /* 070 */ { "Mexico NAD27", 5, -12, 130, 190 }, - /* 071 */ { "Midway Astro 61", 17, 912, -58, 1227 }, - /* 072 */ { "Mindanao", 5, -133, -79, -72 }, - /* 073 */ { "Minna", 6, -92, -93, 122 }, - /* 074 */ { "Montjong Lowe", 26, 0, 0, 0 }, - /* 075 */ { "Nahrwan", 6, -231, -196, 482 }, - /* 076 */ { "Naparima BWI", 17, -2, 374, 172 }, - /* 077 */ { "North America 83", 21, 0, 0, 0 }, - /* 078 */ { "N. America 1927 mean", 5, -8, 160, 176 }, - /* 079 */ { "Observatorio 1966", 17, -425, -169, 81 }, - /* 080 */ { "Old Egyptian", 14, -130, 110, -13 }, - /* 081 */ { "Old Hawaiian_mean", 5, 89, -279, -183 }, - /* 082 */ { "Old Hawaiian Kauai", 5, 45, -290, -172 }, - /* 083 */ { "Old Hawaiian Maui", 5, 65, -290, -190 }, - /* 084 */ { "Old Hawaiian Oahu", 5, 56, -284, -181 }, - /* 085 */ { "Oman", 6, -346, -1, 224 }, - /* 086 */ { "OSGB36", 0, 375, -111, 431 }, - /* 087 */ { "Pico De Las Nieves", 17, -307, -92, 127 }, - /* 088 */ { "Pitcairn Astro 67", 17, 185, 165, 42 }, - /* 089 */ { "S. Am. 1956 mean(P)", 17, -288, 175, -376 }, - /* 090 */ { "S. Chilean 1963 (P)", 17, 16, 196, 93 }, - /* 091 */ { "Puerto Rico", 5, 11, 72, -101 }, - /* 092 */ { "Pulkovo 1942", 18, 28, -130, -95 }, - /* 093 */ { "Qornoq", 17, 164, 138, -189 }, - /* 094 */ { "Quatar National", 17, -128, -283, 22 }, - /* 095 */ { "Rome 1940", 17, -225, -65, 9 }, - /* 096 */ { "S-42(Pulkovo1942)", 18, 28, -121, -77 }, - /* 097 */ { "S.E.Asia_(Indian)", 7, 173, 750, 264 }, - /* 098 */ { "SAD-69/Brazil", 22, -60, -2, -41 }, - /* 099 */ { "Santa Braz", 17, -203, 141, 53 }, - /* 100 */ { "Santo (DOS)", 17, 170, 42, 84 }, - /* 101 */ { "Sapper Hill 43", 17, -355, 16, 74 }, - /* 102 */ { "Schwarzeck", 3, 616, 97, -251 }, - /* 103 */ { "Sicily", 17, -97, -88, -135 }, - /* 104 */ { "Sierra Leone 1960", 26, 0, 0, 0 }, - /* 105 */ { "S. Am. 1969 mean", 22, -57, 1, -41 }, - /* 106 */ { "South Asia", 13, 7, -10, -26 }, - /* 107 */ { "Southeast Base", 17, -499, -249, 314 }, - /* 108 */ { "Southwest Base", 17, -104, 167, -38 }, - /* 109 */ { "Tananarive Obs 25", 17, -189, -242, -91 }, - /* 110 */ { "Thai/Viet (Indian)", 7, 214, 836, 303 }, - /* 111 */ { "Timbalai 1948", 7, -689, 691, -45 }, - /* 112 */ { "Tokyo mean", 4, -128, 481, 664 }, - /* 113 */ { "Tristan Astro 1968", 17, -632, 438, -609 }, - /* 114 */ { "United Arab Emirates", 6, -249, -156, 381 }, - /* 115 */ { "Viti Levu 1916", 6, 51, 391, -36 }, - /* 116 */ { "Wake Eniwetok 60", 15, 101, 52, -39 }, - /* 117 */ { "WGS 72", 25, 0, 0, 5 }, - /* 118 */ { "WGS 84", 26, 0, 0, 0 }, - /* 119 */ { "Yacare", 17, -155, 171, 37 }, - /* 120 */ { "Zanderij", 17, -265, 120, -358 }, - /* 121 */ { "Sweden", 4, 424.3, -80.5, 613.1 }, - /* 122 */ { "GDA 94", 21, 0, 0, 0 }, - /* 123 */ { "CH-1903", 4, 674, 15, 405 }, - /* 124 */ { "Palestine 1923", 27, -235, -85, 264 }, - /* 125 */ { "ITM (Israeli New)", 21, -48, 55, -52 }, - { nullptr, 0, 0, 0, 0 } - }; - - - typedef struct GPS_SDatum_Alias { - const char* alias; - const int datum; - } GPS_ODatum_Alias, *GPS_PDatum_Alias; - - GPS_ODatum_Alias GPS_DatumAlias[] = { - { "Australian GDA94", 122 }, - { "Australian Geocentric 1994 (GDA94)", 122}, /* Observed in Ozi */ - { "GDA94", 122 }, - { "GDA-94", 122 }, - { "CH1903", 123 }, - { "CH 1903", 123 }, - { "European 1950 (Spain and Portugal)", 38 }, - { "Geodetic Datum 1949", 42 }, - { "NAD27 Alaska", 3 }, - { "NAD27 Bahamas", 14 }, - { "NAD27 Canada", 4 }, - { "NAD27 Canal Zone", 21 }, - { "NAD27 Caribbean", 25 }, - { "NAD27 Central", 27 }, - { "NAD27 CONUS", 78 }, - { "NAD27 Cuba", 31 }, - { "NAD27 Greenland", 44 }, - { "NAD27 Mexico", 70 }, - { "NAD83", 77 }, - { "NAD 83", 77 }, - { "NAD-83", 77 }, - { "OSGB 36", 86 }, - { "OSGB-36", 86 }, - { "Wake-Eniwetok 1960", 116 }, - { "WGS72", 117 }, - { "WGS-72", 117 }, - { "WGS84", 118 }, - { "WGS-84", 118 }, - { "Israeli", 124 }, - { "D_Israel_new", 125 }, - { nullptr, -1 } - }; - - - /* UK Ordnance Survey Nation Grid Map Codes */ - static const char* UKNG[]= { - "SV","SW","SX","SY","SZ","TV","TW","SQ","SR","SS","ST","SU","TQ","TR", - "SL","SM","SN","SO","SP","TL","TM","SF","SG","SH","SJ","SK","TF","TG", - "SA","SB","SC","SD","SE","TA","TB","NV","NW","NX","NY","NZ","OV","OW", - "NQ","NR","NS","NT","NU","OQ","OR","NL","NM","NN","NO","NP","OL","OM", - "NF","NG","NH","NJ","NK","OF","OG","NA","NB","NC","ND","NE","OA","OB", - "HV","HW","HX","HY","HZ","JV","JW","HQ","HR","HS","HT","HU","JQ","JR", - "HL","HM","HN","HO","HP","JL","JM","" - }; +struct GPS_Ellipse { + const char* name; + double a; + double invf; +}; + +const GPS_Ellipse GPS_Ellipses[]= { + { "Airy 1830", 6377563.396, 299.3249646 }, + { "Airy 1830 Modified", 6377340.189, 299.3249646 }, + { "Australian National", 6378160.000, 298.25 }, + { "Bessel 1841 (Namibia)", 6377483.865, 299.1528128 }, + { "Bessel 1841", 6377397.155, 299.1528128 }, + { "Clarke 1866", 6378206.400, 294.9786982 }, + { "Clarke 1880", 6378249.145, 293.465 }, + { "Everest (India 1830)", 6377276.345, 300.8017 }, + { "Everest (Sabah Sarawak)", 6377298.556, 300.8017 }, + { "Everest (India 1956)", 6377301.243, 300.8017 }, + { "Everest (Malaysia 1969)", 6377295.664, 300.8017 }, + { "Everest (Malay & Sing)", 6377304.063, 300.8017 }, + { "Everest (Pakistan)", 6377309.613, 300.8017 }, + { "Modified Fischer 1960", 6378155.000, 298.3 }, + { "Helmert 1906", 6378200.000, 298.3 }, + { "Hough 1960", 6378270.000, 297.0 }, + { "Indonesian 1974", 6378160.000, 298.247 }, + { "International 1924", 6378388.000, 297.0 }, + { "Krassovsky 1940", 6378245.000, 298.3 }, + { "GRS67", 6378160.000, 6356774.516 }, + { "GRS75", 6378140.000, 6356755.288 }, + { "GRS80", 6378137.000, 298.257222101 }, + { "S. American 1969", 6378160.000, 298.25 }, + { "WGS60", 6378165.000, 298.3 }, + { "WGS66", 6378145.000, 298.25 }, + { "WGS72", 6378135.000, 298.26 }, + { "WGS84", 6378137.000, 298.257223563 }, + { "Clarke 1880 (Benoit)", 6378300.789, 293.466 }, +}; + + + +struct GPS_Datum { + const char* name; + int ellipse; + double dx; + double dy; + double dz; +}; + +const GPS_Datum GPS_Datums[]= { + /* 000 */ { "Adindan", 6, -166, -15, 204 }, + /* 001 */ { "AFG", 18, -43, -163, 45 }, + /* 002 */ { "Ain-El-Abd", 17, -150, -251, -2 }, + /* 003 */ { "Alaska-NAD27", 5, -5, 135, 172 }, + /* 004 */ { "Alaska-Canada", 6, -9, 151, 185 }, + /* 005 */ { "Anna-1-Astro", 2, -491, -22, 435 }, + /* 006 */ { "ARC 1950 Mean", 6, -143, -90, -294 }, + /* 007 */ { "ARC 1960 Mean", 6, -160, -8, -300 }, + /* 008 */ { "Asc Island 58", 17, -207, 107, 52 }, + /* 009 */ { "Astro B4", 17, 114, -116, -333 }, + /* 010 */ { "Astro Beacon E", 17, 145, 75, -272 }, + /* 011 */ { "Astro pos 71/4", 17, -320, 550, -494 }, + /* 012 */ { "Astro stn 52", 17, 124, -234, -25 }, + /* 013 */ { "Australia Geo 1984", 2, -134, -48, 149 }, + /* 014 */ { "Bahamas NAD27", 6, -4, 154, 178 }, + /* 015 */ { "Bellevue IGN", 17, -127, -769, 472 }, + /* 016 */ { "Bermuda 1957", 6, -73, 213, 296 }, + /* 017 */ { "Bukit Rimpah", 4, -384, 664, -48 }, + /* 018 */ { "Camp_Area_Astro", 17, -104, -129, 239 }, + /* 019 */ { "Campo_Inchauspe", 17, -148, 136, 90 }, + /* 020 */ { "Canada_Mean(NAD27)", 5, -10, 158, 187 }, + /* 021 */ { "Canal_Zone_(NAD27)", 5, 0, 125, 201 }, + /* 022 */ { "Canton_Island_1966", 17, 298, -304, -375 }, + /* 023 */ { "Cape", 6, -136, -108, -292 }, + /* 024 */ { "Cape_Canaveral_mean", 5, -2, 150, 181 }, + /* 025 */ { "Carribean NAD27", 5, -7, 152, 178 }, + /* 026 */ { "Carthage", 6, -263, 6, 431 }, + /* 027 */ { "Cent America NAD27", 5, 0, 125, 194 }, + /* 028 */ { "Chatham 1971", 17, 175, -38, 113 }, + /* 029 */ { "Chua Astro", 17, -134, 229, -29 }, + /* 030 */ { "Corrego Alegre", 17, -206, 172, -6 }, + /* 031 */ { "Cuba NAD27", 5, -9, 152, 178 }, + /* 032 */ { "Cyprus", 17, -104, -101, -140 }, + /* 033 */ { "Djakarta(Batavia)", 4, -377, 681, -50 }, + /* 034 */ { "DOS 1968", 17, 230, -199, -752 }, + /* 035 */ { "Easter lsland 1967", 17, 211, 147, 111 }, + /* 036 */ { "Egypt", 17, -130, -117, -151 }, + /* 037 */ { "European 1950", 17, -87, -96, -120 }, + /* 038 */ { "European 1950 mean", 17, -87, -98, -121 }, + /* 039 */ { "European 1979 mean", 17, -86, -98, -119 }, + /* 040 */ { "Finnish Nautical", 17, -78, -231, -97 }, + /* 041 */ { "Gandajika Base", 17, -133, -321, 50 }, + /* 042 */ { "Geodetic Datum 49", 17, 84, -22, 209 }, + /* 043 */ { "Ghana", 26, 0, 0, 0 }, + /* 044 */ { "Greenland NAD27", 5, 11, 114, 195 }, + /* 045 */ { "Guam 1963", 5, -100, -248, 259 }, + /* 046 */ { "Gunung Segara", 4, -403, 684, 41 }, + /* 047 */ { "Gunung Serindung 1962", 26, 0, 0, 0 }, + /* 048 */ { "GUX1 Astro", 17, 252, -209, -751 }, + /* 049 */ { "Herat North", 17, -333, -222, 114 }, + /* 050 */ { "Hjorsey 1955", 17, -73, 46, 86 }, + /* 051 */ { "Hong Kong 1963", 17, -156, -271, -189 }, + /* 052 */ { "Hu-Tzu-Shan", 17, -634, -549, -201 }, + /* 053 */ { "Indian", 9, 289, 734, 257 }, + /* 054 */ { "Iran", 17, -117, -132, -164 }, + /* 055 */ { "Ireland 1965", 1, 506, -122, 611 }, + /* 056 */ { "ISTS 073 Astro 69", 17, 208, -435, -229 }, + /* 057 */ { "Johnston Island 61", 17, 191, -77, -204 }, + /* 058 */ { "Kandawala", 7, -97, 787, 86 }, + /* 059 */ { "Kerguelen Island", 17, 145, -187, 103 }, + /* 060 */ { "Kertau 48", 11, -11, 851, 5 }, + /* 061 */ { "L.C. 5 Astro", 5, 42, 124, 147 }, + /* 062 */ { "La Reunion", 17, 94, -948, -1262 }, + /* 063 */ { "Liberia 1964", 6, -90, 40, 88 }, + /* 064 */ { "Luzon", 5, -133, -77, -51 }, + /* 065 */ { "Mahe 1971", 6, 41, -220, -134 }, + /* 066 */ { "Marco Astro", 17, -289, -124, 60 }, + /* 067 */ { "Masirah Is. Nahrwan", 6, -247, -148, 369 }, + /* 068 */ { "Massawa", 4, 639, 405, 60 }, + /* 069 */ { "Merchich", 6, 31, 146, 47 }, + /* 070 */ { "Mexico NAD27", 5, -12, 130, 190 }, + /* 071 */ { "Midway Astro 61", 17, 912, -58, 1227 }, + /* 072 */ { "Mindanao", 5, -133, -79, -72 }, + /* 073 */ { "Minna", 6, -92, -93, 122 }, + /* 074 */ { "Montjong Lowe", 26, 0, 0, 0 }, + /* 075 */ { "Nahrwan", 6, -231, -196, 482 }, + /* 076 */ { "Naparima BWI", 17, -2, 374, 172 }, + /* 077 */ { "North America 83", 21, 0, 0, 0 }, + /* 078 */ { "N. America 1927 mean", 5, -8, 160, 176 }, + /* 079 */ { "Observatorio 1966", 17, -425, -169, 81 }, + /* 080 */ { "Old Egyptian", 14, -130, 110, -13 }, + /* 081 */ { "Old Hawaiian_mean", 5, 89, -279, -183 }, + /* 082 */ { "Old Hawaiian Kauai", 5, 45, -290, -172 }, + /* 083 */ { "Old Hawaiian Maui", 5, 65, -290, -190 }, + /* 084 */ { "Old Hawaiian Oahu", 5, 56, -284, -181 }, + /* 085 */ { "Oman", 6, -346, -1, 224 }, + /* 086 */ { "OSGB36", 0, 375, -111, 431 }, + /* 087 */ { "Pico De Las Nieves", 17, -307, -92, 127 }, + /* 088 */ { "Pitcairn Astro 67", 17, 185, 165, 42 }, + /* 089 */ { "S. Am. 1956 mean(P)", 17, -288, 175, -376 }, + /* 090 */ { "S. Chilean 1963 (P)", 17, 16, 196, 93 }, + /* 091 */ { "Puerto Rico", 5, 11, 72, -101 }, + /* 092 */ { "Pulkovo 1942", 18, 28, -130, -95 }, + /* 093 */ { "Qornoq", 17, 164, 138, -189 }, + /* 094 */ { "Quatar National", 17, -128, -283, 22 }, + /* 095 */ { "Rome 1940", 17, -225, -65, 9 }, + /* 096 */ { "S-42(Pulkovo1942)", 18, 28, -121, -77 }, + /* 097 */ { "S.E.Asia_(Indian)", 7, 173, 750, 264 }, + /* 098 */ { "SAD-69/Brazil", 22, -60, -2, -41 }, + /* 099 */ { "Santa Braz", 17, -203, 141, 53 }, + /* 100 */ { "Santo (DOS)", 17, 170, 42, 84 }, + /* 101 */ { "Sapper Hill 43", 17, -355, 16, 74 }, + /* 102 */ { "Schwarzeck", 3, 616, 97, -251 }, + /* 103 */ { "Sicily", 17, -97, -88, -135 }, + /* 104 */ { "Sierra Leone 1960", 26, 0, 0, 0 }, + /* 105 */ { "S. Am. 1969 mean", 22, -57, 1, -41 }, + /* 106 */ { "South Asia", 13, 7, -10, -26 }, + /* 107 */ { "Southeast Base", 17, -499, -249, 314 }, + /* 108 */ { "Southwest Base", 17, -104, 167, -38 }, + /* 109 */ { "Tananarive Obs 25", 17, -189, -242, -91 }, + /* 110 */ { "Thai/Viet (Indian)", 7, 214, 836, 303 }, + /* 111 */ { "Timbalai 1948", 7, -689, 691, -45 }, + /* 112 */ { "Tokyo mean", 4, -128, 481, 664 }, + /* 113 */ { "Tristan Astro 1968", 17, -632, 438, -609 }, + /* 114 */ { "United Arab Emirates", 6, -249, -156, 381 }, + /* 115 */ { "Viti Levu 1916", 6, 51, 391, -36 }, + /* 116 */ { "Wake Eniwetok 60", 15, 101, 52, -39 }, + /* 117 */ { "WGS 72", 25, 0, 0, 5 }, + /* 118 */ { "WGS 84", 26, 0, 0, 0 }, + /* 119 */ { "Yacare", 17, -155, 171, 37 }, + /* 120 */ { "Zanderij", 17, -265, 120, -358 }, + /* 121 */ { "Sweden", 4, 424.3, -80.5, 613.1 }, + /* 122 */ { "GDA 94", 21, 0, 0, 0 }, + /* 123 */ { "CH-1903", 4, 674, 15, 405 }, + /* 124 */ { "Palestine 1923", 27, -235, -85, 264 }, + /* 125 */ { "ITM (Israeli New)", 21, -48, 55, -52 }, + { nullptr, 0, 0, 0, 0 } +}; + + +struct GPS_Datum_Alias { + const char* alias; + int datum; +}; + +const GPS_Datum_Alias GPS_DatumAliases[] = { + { "Australian GDA94", 122 }, + { "Australian Geocentric 1994 (GDA94)", 122}, /* Observed in Ozi */ + { "GDA94", 122 }, + { "GDA-94", 122 }, + { "CH1903", 123 }, + { "CH 1903", 123 }, + { "European 1950 (Spain and Portugal)", 38 }, + { "Geodetic Datum 1949", 42 }, + { "NAD27 Alaska", 3 }, + { "NAD27 Bahamas", 14 }, + { "NAD27 Canada", 4 }, + { "NAD27 Canal Zone", 21 }, + { "NAD27 Caribbean", 25 }, + { "NAD27 Central", 27 }, + { "NAD27 CONUS", 78 }, + { "NAD27 Cuba", 31 }, + { "NAD27 Greenland", 44 }, + { "NAD27 Mexico", 70 }, + { "NAD83", 77 }, + { "NAD 83", 77 }, + { "NAD-83", 77 }, + { "OSGB 36", 86 }, + { "OSGB-36", 86 }, + { "Wake-Eniwetok 1960", 116 }, + { "WGS72", 117 }, + { "WGS-72", 117 }, + { "WGS84", 118 }, + { "WGS-84", 118 }, + { "Israeli", 124 }, + { "D_Israel_new", 125 }, + { nullptr, -1 } +}; + + +/* UK Ordnance Survey Nation Grid Map Codes */ +static const char* const UKNG[]= { + "SV","SW","SX","SY","SZ","TV","TW","SQ","SR","SS","ST","SU","TQ","TR", + "SL","SM","SN","SO","SP","TL","TM","SF","SG","SH","SJ","SK","TF","TG", + "SA","SB","SC","SD","SE","TA","TB","NV","NW","NX","NY","NZ","OV","OW", + "NQ","NR","NS","NT","NU","OQ","OR","NL","NM","NN","NO","NP","OL","OM", + "NF","NG","NH","NJ","NK","OF","OG","NA","NB","NC","ND","NE","OA","OB", + "HV","HW","HX","HY","HZ","JV","JW","HQ","HR","HS","HT","HU","JQ","JR", + "HL","HM","HN","HO","HP","JL","JM","" +}; diff --git a/jeeps/gpsmath.cc b/jeeps/gpsmath.cc index 56a24581a..8da383fa5 100644 --- a/jeeps/gpsmath.cc +++ b/jeeps/gpsmath.cc @@ -21,11 +21,19 @@ ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ** Boston, MA 02110-1301, USA. ********************************************************************/ -#include "jeeps/gps.h" -#include "jeeps/gpsdatum.h" -#include -#include -#include +#include "jeeps/gpsmath.h" + +#include // for assert +#include // for sin, tan, cos, pow, log, sqrt, asin, atan, exp, fabs, round +#include // for int32_t +#include // for abs +#include // for strcmp, strcpy +#include // for time_t + +#include // for QString + +#include "defs.h" // for case_ignore_strcmp, fatal, CSTR +#include "jeeps/gpsdatum.h" // for GPS_ODatum, GPS_OEllipse, GPS_Datums, GPS_Ellipses, UKNG, GPS_SDatum_Alias, GPS_SDatum, GPS_DatumAliases, GPS_PDatum, GPS_PDatum_Alias static int32_t GPS_Math_LatLon_To_UTM_Param(double lat, double lon, int32_t* zone, @@ -705,8 +713,9 @@ int32_t GPS_Math_WGS84_To_Swiss_EN(double lat, double lon, double* E, return 0; } - a = GPS_Ellipse[4].a; - b = a - (a / GPS_Ellipse[4].invf); + assert(strcmp(GPS_Ellipses[4].name, "Bessel 1841") == 0); + a = GPS_Ellipses[4].a; + b = a - (a / GPS_Ellipses[4].invf); GPS_Math_WGS84_To_Known_Datum_M(lat, lon, 0, &phi, &lambda, &alt, 123); GPS_Math_Swiss_LatLon_To_EN(phi, lambda, E, N, phi0, lambda0, E0, N0, a, b); @@ -735,8 +744,9 @@ void GPS_Math_Swiss_EN_To_WGS84(double E, double N, double* lat, double* lon) const double N0 = 200000.0; double phi, lambda, alt, a, b; - a = GPS_Ellipse[4].a; - b = a - (a / GPS_Ellipse[4].invf); + assert(strcmp(GPS_Ellipses[4].name, "Bessel 1841") == 0); + a = GPS_Ellipses[4].a; + b = a - (a / GPS_Ellipses[4].invf); GPS_Math_Swiss_EN_To_LatLon(E, N, &phi, &lambda, phi0, lambda0, E0, N0, a, b); GPS_Math_Known_Datum_To_WGS84_M(phi, lambda, 0, lat, lon, &alt, 123); @@ -1099,10 +1109,10 @@ int32_t GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, if (datum < 0) { fatal("Unable to find Palestine 1923 in internal tables"); } - int32_t ellipse = GPS_Datum[datum].ellipse; + int32_t ellipse = GPS_Datums[datum].ellipse; - a = GPS_Ellipse[ellipse].a; - b = a - (a / GPS_Ellipse[ellipse].invf); + a = GPS_Ellipses[ellipse].a; + b = a - (a / GPS_Ellipses[ellipse].invf); GPS_Math_WGS84_To_Known_Datum_M(lat, lon, 0, &phi, &lambda, &alt, datum); GPS_Math_Cassini_LatLon_To_EN(phi, lambda, E, N, @@ -1135,10 +1145,10 @@ void GPS_Math_ICS_EN_To_WGS84(double E, double N, double* lat, double* lon) if (datum < 0) { fatal("Unable to find Palestine 1923 in internal tables"); } - int32_t ellipse = GPS_Datum[datum].ellipse; + int32_t ellipse = GPS_Datums[datum].ellipse; - a = GPS_Ellipse[ellipse].a; - b = a - (a / GPS_Ellipse[ellipse].invf); + a = GPS_Ellipses[ellipse].a; + b = a - (a / GPS_Ellipses[ellipse].invf); GPS_Math_Cassini_EN_To_LatLon(E, N, &phi, &lambda, phi0, lambda0, E0, N0, a, b); @@ -1519,7 +1529,7 @@ void GPS_Math_Molodensky(double Sphi, double Slam, double SH, double Sa, ** @param [w] Dphi [double *] dest latitude (deg) ** @param [w] Dlam [double *] dest longitude (deg) ** @param [w] DH [double *] dest height (metres) -** @param [r] n [int32] datum number from GPS_Datum structure +** @param [r] n [int32] datum number from GPS_Datums structure ** ** @return [void] ************************************************************************/ @@ -1539,12 +1549,12 @@ void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, Da = 6378137.0; Dif = 298.257223563; - idx = GPS_Datum[n].ellipse; - Sa = GPS_Ellipse[idx].a; - Sif = GPS_Ellipse[idx].invf; - x = GPS_Datum[n].dx; - y = GPS_Datum[n].dy; - z = GPS_Datum[n].dz; + idx = GPS_Datums[n].ellipse; + Sa = GPS_Ellipses[idx].a; + Sif = GPS_Ellipses[idx].invf; + x = GPS_Datums[n].dx; + y = GPS_Datums[n].dy; + z = GPS_Datums[n].dz; GPS_Math_Molodensky(Sphi,Slam,SH,Sa,Sif,Dphi,Dlam,DH,Da,Dif,x,y,z); @@ -1563,7 +1573,7 @@ void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, ** @param [w] Dphi [double *] dest latitude (deg) ** @param [w] Dlam [double *] dest longitude (deg) ** @param [w] DH [double *] dest height (metres) -** @param [r] n [int32] datum number from GPS_Datum structure +** @param [r] n [int32] datum number from GPS_Datums structure ** ** @return [void] ************************************************************************/ @@ -1583,12 +1593,12 @@ void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, Sa = 6378137.0; Sif = 298.257223563; - idx = GPS_Datum[n].ellipse; - Da = GPS_Ellipse[idx].a; - Dif = GPS_Ellipse[idx].invf; - x = -GPS_Datum[n].dx; - y = -GPS_Datum[n].dy; - z = -GPS_Datum[n].dz; + idx = GPS_Datums[n].ellipse; + Da = GPS_Ellipses[idx].a; + Dif = GPS_Ellipses[idx].invf; + x = -GPS_Datums[n].dx; + y = -GPS_Datums[n].dy; + z = -GPS_Datums[n].dz; GPS_Math_Molodensky(Sphi,Slam,SH,Sa,Sif,Dphi,Dlam,DH,Da,Dif,x,y,z); @@ -1607,7 +1617,7 @@ void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, ** @param [w] Dphi [double *] dest latitude (deg) ** @param [w] Dlam [double *] dest longitude (deg) ** @param [w] DH [double *] dest height (metres) -** @param [r] n [int32] datum number from GPS_Datum structure +** @param [r] n [int32] datum number from GPS_Datums structure ** ** @return [void] ************************************************************************/ @@ -1633,14 +1643,14 @@ void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, Dif = 298.257223563; Db = Da - (Da / Dif); - idx = GPS_Datum[n].ellipse; - Sa = GPS_Ellipse[idx].a; - Sif = GPS_Ellipse[idx].invf; + idx = GPS_Datums[n].ellipse; + Sa = GPS_Ellipses[idx].a; + Sif = GPS_Ellipses[idx].invf; Sb = Sa - (Sa / Sif); - x = GPS_Datum[n].dx; - y = GPS_Datum[n].dy; - z = GPS_Datum[n].dz; + x = GPS_Datums[n].dx; + y = GPS_Datums[n].dy; + z = GPS_Datums[n].dz; GPS_Math_LatLonH_To_XYZ(Sphi,Slam,SH,&sx,&sy,&sz,Sa,Sb); sx += x; @@ -1664,7 +1674,7 @@ void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, ** @param [w] Dphi [double *] dest latitude (deg) ** @param [w] Dlam [double *] dest longitude (deg) ** @param [w] DH [double *] dest height (metres) -** @param [r] n [int32] datum number from GPS_Datum structure +** @param [r] n [int32] datum number from GPS_Datums structure ** ** @return [void] ************************************************************************/ @@ -1690,14 +1700,14 @@ void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, Sif = 298.257223563; Sb = Sa - (Sa / Sif); - idx = GPS_Datum[n].ellipse; - Da = GPS_Ellipse[idx].a; - Dif = GPS_Ellipse[idx].invf; + idx = GPS_Datums[n].ellipse; + Da = GPS_Ellipses[idx].a; + Dif = GPS_Ellipses[idx].invf; Db = Da - (Da / Dif); - x = -GPS_Datum[n].dx; - y = -GPS_Datum[n].dy; - z = -GPS_Datum[n].dz; + x = -GPS_Datums[n].dx; + y = -GPS_Datums[n].dy; + z = -GPS_Datums[n].dz; GPS_Math_LatLonH_To_XYZ(Sphi,Slam,SH,&dx,&dy,&dz,Sa,Sb); dx += x; @@ -1721,8 +1731,8 @@ void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, ** @param [w] Dphi [double *] dest latitude (deg) ** @param [w] Dlam [double *] dest longitude (deg) ** @param [w] DH [double *] dest height (metres) -** @param [r] n1 [int32] source datum number from GPS_Datum structure -** @param [r] n2 [int32] dest datum number from GPS_Datum structure +** @param [r] n1 [int32] source datum number from GPS_Datums structure +** @param [r] n2 [int32] dest datum number from GPS_Datums structure ** ** @return [void] ************************************************************************/ @@ -1748,19 +1758,19 @@ void GPS_Math_Known_Datum_To_Known_Datum_M(double Sphi, double Slam, double SH, int32_t idx2; - idx1 = GPS_Datum[n1].ellipse; - Sa = GPS_Ellipse[idx1].a; - Sif = GPS_Ellipse[idx1].invf; - x1 = GPS_Datum[n1].dx; - y1 = GPS_Datum[n1].dy; - z1 = GPS_Datum[n1].dz; + idx1 = GPS_Datums[n1].ellipse; + Sa = GPS_Ellipses[idx1].a; + Sif = GPS_Ellipses[idx1].invf; + x1 = GPS_Datums[n1].dx; + y1 = GPS_Datums[n1].dy; + z1 = GPS_Datums[n1].dz; - idx2 = GPS_Datum[n2].ellipse; - Da = GPS_Ellipse[idx2].a; - Dif = GPS_Ellipse[idx2].invf; - x2 = GPS_Datum[n2].dx; - y2 = GPS_Datum[n2].dy; - z2 = GPS_Datum[n2].dz; + idx2 = GPS_Datums[n2].ellipse; + Da = GPS_Ellipses[idx2].a; + Dif = GPS_Ellipses[idx2].invf; + x2 = GPS_Datums[n2].dx; + y2 = GPS_Datums[n2].dy; + z2 = GPS_Datums[n2].dz; x = -(x2-x1); y = -(y2-y1); @@ -1783,8 +1793,8 @@ void GPS_Math_Known_Datum_To_Known_Datum_M(double Sphi, double Slam, double SH, ** @param [w] Dphi [double *] dest latitude (deg) ** @param [w] Dlam [double *] dest longitude (deg) ** @param [w] DH [double *] dest height (metres) -** @param [r] n1 [int32] source datum number from GPS_Datum structure -** @param [r] n2 [int32] dest datum number from GPS_Datum structure +** @param [r] n1 [int32] source datum number from GPS_Datums structure +** @param [r] n2 [int32] dest datum number from GPS_Datums structure ** ** @return [void] ************************************************************************/ @@ -1812,23 +1822,23 @@ void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, double dy; double dz; - idx1 = GPS_Datum[n1].ellipse; - Sa = GPS_Ellipse[idx1].a; - Sif = GPS_Ellipse[idx1].invf; + idx1 = GPS_Datums[n1].ellipse; + Sa = GPS_Ellipses[idx1].a; + Sif = GPS_Ellipses[idx1].invf; Sb = Sa - (Sa / Sif); - x1 = GPS_Datum[n1].dx; - y1 = GPS_Datum[n1].dy; - z1 = GPS_Datum[n1].dz; + x1 = GPS_Datums[n1].dx; + y1 = GPS_Datums[n1].dy; + z1 = GPS_Datums[n1].dz; - idx2 = GPS_Datum[n2].ellipse; - Da = GPS_Ellipse[idx2].a; - Dif = GPS_Ellipse[idx2].invf; + idx2 = GPS_Datums[n2].ellipse; + Da = GPS_Ellipses[idx2].a; + Dif = GPS_Ellipses[idx2].invf; Db = Da - (Da / Dif); - x2 = GPS_Datum[n2].dx; - y2 = GPS_Datum[n2].dy; - z2 = GPS_Datum[n2].dz; + x2 = GPS_Datums[n2].dx; + y2 = GPS_Datums[n2].dy; + z2 = GPS_Datums[n2].dz; GPS_Math_LatLonH_To_XYZ(Sphi,Slam,SH,&dx,&dy,&dz,Sa,Sb); dx += -(x2-x1); @@ -2116,8 +2126,9 @@ int32_t GPS_Math_NAD83_To_UTM_EN(double lat, double lon, double* E, phi0 = 0.0; - a = GPS_Ellipse[21].a; - b = a - (a/GPS_Ellipse[21].invf); + assert(strcmp(GPS_Ellipses[21].name, "GRS80") == 0); + a = GPS_Ellipses[21].a; + b = a - (a / GPS_Ellipses[21].invf); GPS_Math_LatLon_To_EN(E,N,lat,lon,N0,E0,phi0,lambda0,F0,a,b); @@ -2243,7 +2254,7 @@ int32_t GPS_Math_UTM_EN_To_WGS84(double* lat, double* lon, double E, return 0; } - GPS_Math_UTM_EN_to_LatLon(GPS_Datum[118].ellipse, N, E, lat, lon, lambda0, E0, N0); + GPS_Math_UTM_EN_to_LatLon(GPS_Datums[118].ellipse, N, E, lat, lon, lambda0, E0, N0); return 1; } @@ -2258,7 +2269,7 @@ int32_t GPS_Math_UTM_EN_To_WGS84(double* lat, double* lon, double E, ** @param [w] N [double *] northing (metres) ** @param [w] zone [int32 *] zone number ** @param [w] zc [char *] zone character -** @param [r] n [int32] datum number from GPS_Datum structure +** @param [r] n [int32] datum number from GPS_Datums structure ** ** @return [int32] success ************************************************************************/ @@ -2281,9 +2292,9 @@ int32_t GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, phi0 = 0.0; - idx = GPS_Datum[n].ellipse; - a = GPS_Ellipse[idx].a; - b = a - (a/GPS_Ellipse[idx].invf); + idx = GPS_Datums[n].ellipse; + a = GPS_Ellipses[idx].a; + b = a - (a / GPS_Ellipses[idx].invf); GPS_Math_LatLon_To_EN(E,N,lat,lon,N0,E0,phi0,lambda0,F0,a,b); @@ -2300,7 +2311,7 @@ int32_t GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, ** @param [w] N [double] northing (metres) ** @param [w] zone [int32] zone number ** @param [w] zc [char] zone character -** @param [r] n [int32] datum number from GPS_Datum structure +** @param [r] n [int32] datum number from GPS_Datums structure ** ** @return [int32] success ************************************************************************/ @@ -2316,7 +2327,7 @@ int32_t GPS_Math_UTM_EN_To_Known_Datum(double* lat, double* lon, double E, return 0; } - GPS_Math_UTM_EN_to_LatLon(GPS_Datum[n].ellipse, N, E, lat, lon, lambda0, E0, N0); + GPS_Math_UTM_EN_to_LatLon(GPS_Datums[n].ellipse, N, E, lat, lon, lambda0, E0, N0); return 1; } @@ -2514,8 +2525,8 @@ void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, double mu, phi1Rad; double x, y; - a = GPS_Ellipse[ReferenceEllipsoid].a; - b = 1 / GPS_Ellipse[ReferenceEllipsoid].invf; + a = GPS_Ellipses[ReferenceEllipsoid].a; + b = 1 / GPS_Ellipses[ReferenceEllipsoid].invf; eccSquared = b * (2.0 - b); e1 = (1-sqrt(1-eccSquared))/(1+sqrt(1-eccSquared)); @@ -2549,18 +2560,18 @@ void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, int32_t GPS_Lookup_Datum_Index(const char* n) { - GPS_PDatum dp; - GPS_PDatum_Alias al; + const GPS_Datum* dp; + const GPS_Datum_Alias* al; - for (al = GPS_DatumAlias; al->alias; al++) { + for (al = GPS_DatumAliases; al->alias; al++) { if (case_ignore_strcmp(al->alias, n) == 0) { return al->datum; } } - for (dp = GPS_Datum; dp->name; dp++) { + for (dp = GPS_Datums; dp->name; dp++) { if (0 == case_ignore_strcmp(dp->name, n)) { - return dp - GPS_Datum; + return dp - GPS_Datums; } } @@ -2575,7 +2586,7 @@ int32_t GPS_Lookup_Datum_Index(const QString& n) const char* GPS_Math_Get_Datum_Name(const int datum_index) { - return GPS_Datum[datum_index].name; + return GPS_Datums[datum_index].name; } diff --git a/jeeps/gpsmath.h b/jeeps/gpsmath.h index 39dd394b1..19451987d 100644 --- a/jeeps/gpsmath.h +++ b/jeeps/gpsmath.h @@ -1,94 +1,96 @@ #ifndef JEEPS_GPSMATH_H_INCLUDED_ #define JEEPS_GPSMATH_H_INCLUDED_ -#include "jeeps/gpsport.h" +#include // for int32_t +#include // for time_t -#define GPS_PI 3.141592653589 -#define GPS_FLTMIN 1.75494351E-38 -#define GPS_FLTMAX 3.402823466E+38 +#include // for QString - double GPS_Math_Deg_To_Rad(double v); - double GPS_Math_Rad_To_Deg(double v); +constexpr double GPS_PI = 3.141592653589; - double GPS_Math_Metres_To_Feet(double v); - double GPS_Math_Feet_To_Metres(double v); + +double GPS_Math_Deg_To_Rad(double v); +double GPS_Math_Rad_To_Deg(double v); + +double GPS_Math_Metres_To_Feet(double v); +double GPS_Math_Feet_To_Metres(double v); int32_t GPS_Math_Deg_To_Semi(double v); - double GPS_Math_Semi_To_Deg(int32_t v); +double GPS_Math_Semi_To_Deg(int32_t v); - time_t GPS_Math_Utime_To_Gtime(time_t v); - time_t GPS_Math_Gtime_To_Utime(time_t v); +time_t GPS_Math_Utime_To_Gtime(time_t v); +time_t GPS_Math_Gtime_To_Utime(time_t v); - void GPS_Math_Deg_To_DegMin(double v, int32_t* d, double* m); - void GPS_Math_DegMin_To_Deg(int32_t d, double m, double* deg); - void GPS_Math_Deg_To_DegMinSec(double v, int32_t* d, int32_t* m, double* s); - void GPS_Math_DegMinSec_To_Deg(int32_t d, int32_t m, double s, double* deg); +void GPS_Math_Deg_To_DegMin(double v, int32_t* d, double* m); +void GPS_Math_DegMin_To_Deg(int32_t d, double m, double* deg); +void GPS_Math_Deg_To_DegMinSec(double v, int32_t* d, int32_t* m, double* s); +void GPS_Math_DegMinSec_To_Deg(int32_t d, int32_t m, double s, double* deg); - void GPS_Math_Airy1830LatLonToNGEN(double phi, double lambda, double* E, - double* N); - void GPS_Math_Airy1830M_LatLonToINGEN(double phi, double lambda, double* E, - double* N); +void GPS_Math_Airy1830LatLonToNGEN(double phi, double lambda, double* E, + double* N); +void GPS_Math_Airy1830M_LatLonToINGEN(double phi, double lambda, double* E, + double* N); int32_t GPS_Math_EN_To_UKOSNG_Map(double E, double N, double* mE, double* mN, char* map); int32_t GPS_Math_UKOSNG_Map_To_EN(const char* map, double mapE, double mapN, double* E, double* N); - void GPS_Math_LatLonH_To_XYZ(double phi, double lambda, double H, - double* x, double* y, double* z, - double a, double b); - void GPS_Math_XYZ_To_LatLonH(double* phi, double* lambda, double* H, - double x, double y, double z, - double a, double b); - - void GPS_Math_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double N0, double E0, - double phi0, double lambda0, - double F0, double a, double b); - void GPS_Math_LatLon_To_EN(double* E, double* N, double phi, - double lambda, double N0, double E0, - double phi0, double lambda0, - double F0, double a, double b); - - void GPS_Math_NGENToAiry1830LatLon(double E, double N, double* phi, +void GPS_Math_LatLonH_To_XYZ(double phi, double lambda, double H, + double* x, double* y, double* z, + double a, double b); +void GPS_Math_XYZ_To_LatLonH(double* phi, double* lambda, double* H, + double x, double y, double z, + double a, double b); + +void GPS_Math_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double N0, double E0, + double phi0, double lambda0, + double F0, double a, double b); +void GPS_Math_LatLon_To_EN(double* E, double* N, double phi, + double lambda, double N0, double E0, + double phi0, double lambda0, + double F0, double a, double b); + +void GPS_Math_NGENToAiry1830LatLon(double E, double N, double* phi, + double* lambda); +void GPS_Math_INGENToAiry1830MLatLon(double E, double N, double* phi, double* lambda); - void GPS_Math_INGENToAiry1830MLatLon(double E, double N, double* phi, - double* lambda); - - - void GPS_Math_Airy1830LatLonH_To_XYZ(double phi, double lambda, double H, - double* x, double* y, double* z); - void GPS_Math_WGS84LatLonH_To_XYZ(double phi, double lambda, double H, - double* x, double* y, double* z); - void GPS_Math_XYZ_To_Airy1830LatLonH(double* phi, double* lambda, double* H, - double x, double y, double z); - void GPS_Math_XYZ_To_WGS84LatLonH(double* phi, double* lambda, double* H, - double x, double y, double z); - - void GPS_Math_Molodensky(double Sphi, double Slam, double SH, double Sa, - double Sif, double* Dphi, double* Dlam, - double* DH, double Da, double Dif, double dx, - double dy, double dz); - void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, - double* Dphi, double* Dlam, double* DH, - int32_t n); - void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, - double* Dphi, double* Dlam, double* DH, - int32_t n); - void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, - double* Dphi, double* Dlam, double* DH, - int32_t n); - void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, - double* Dphi, double* Dlam, double* DH, - int32_t n); - - void GPS_Math_Known_Datum_To_Known_Datum_M(double Sphi, double Slam, double SH, - double* Dphi, double* Dlam, - double* DH, int32_t n1, int32_t n2); - void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, - double* Dphi, double* Dlam, - double* DH, int32_t n1, int32_t n2); + + +void GPS_Math_Airy1830LatLonH_To_XYZ(double phi, double lambda, double H, + double* x, double* y, double* z); +void GPS_Math_WGS84LatLonH_To_XYZ(double phi, double lambda, double H, + double* x, double* y, double* z); +void GPS_Math_XYZ_To_Airy1830LatLonH(double* phi, double* lambda, double* H, + double x, double y, double z); +void GPS_Math_XYZ_To_WGS84LatLonH(double* phi, double* lambda, double* H, + double x, double y, double z); + +void GPS_Math_Molodensky(double Sphi, double Slam, double SH, double Sa, + double Sif, double* Dphi, double* Dlam, + double* DH, double Da, double Dif, double dx, + double dy, double dz); +void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, + double* Dphi, double* Dlam, double* DH, + int32_t n); +void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, + double* Dphi, double* Dlam, double* DH, + int32_t n); +void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, + double* Dphi, double* Dlam, double* DH, + int32_t n); +void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, + double* Dphi, double* Dlam, double* DH, + int32_t n); + +void GPS_Math_Known_Datum_To_Known_Datum_M(double Sphi, double Slam, double SH, + double* Dphi, double* Dlam, + double* DH, int32_t n1, int32_t n2); +void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, + double* Dphi, double* Dlam, + double* DH, int32_t n1, int32_t n2); int32_t GPS_Math_WGS84_To_UKOSMap_M(double lat, double lon, double* mE, double* mN, char* map); @@ -115,34 +117,34 @@ int32_t GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, int32_t GPS_Math_UTM_EN_To_Known_Datum(double* lat, double* lon, double E, double N, int32_t zone, char zc, int n); - void GPS_Math_Swiss_LatLon_To_EN(double phi, double lambda, double* E, - double* N,double phi0,double lambda0, +void GPS_Math_Swiss_LatLon_To_EN(double phi, double lambda, double* E, + double* N,double phi0,double lambda0, + double E0, double N0, double a, double b); +void GPS_Math_Swiss_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double lambda0, + double E0, double N0, double a, double b); + +void GPS_Math_Cassini_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi0, double M0, double E0, double N0, double a, double b); - void GPS_Math_Swiss_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double lambda0, +void GPS_Math_Cassini_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double M0, double E0, double N0, double a, double b); - void GPS_Math_Cassini_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi0, double M0, - double E0, double N0, double a, double b); - void GPS_Math_Cassini_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double M0, - double E0, double N0, double a, double b); - int32_t GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, double* N); - void GPS_Math_ICS_EN_To_WGS84(double E, double N, double* lat, double* lon); +void GPS_Math_ICS_EN_To_WGS84(double E, double N, double* lat, double* lon); int32_t GPS_Math_WGS84_To_Swiss_EN(double phi, double lambda, double* E, double* N); - void GPS_Math_Swiss_EN_To_WGS84(double E, double N, double* lat, double* lon); +void GPS_Math_Swiss_EN_To_WGS84(double E, double N, double* lat, double* lon); - void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, - double UTMNorthing, double UTMEasting, - double* Lat, double* Lon, - double lambda0, double E0, double N0); +void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, + double UTMNorthing, double UTMEasting, + double* Lat, double* Lon, + double lambda0, double E0, double N0); int32_t GPS_Lookup_Datum_Index(const char* n); int32_t GPS_Lookup_Datum_Index(const QString& n); - const char* GPS_Math_Get_Datum_Name(int datum_index); +const char* GPS_Math_Get_Datum_Name(int datum_index); #endif // JEEPS_GPSMATH_H_INCLUDED_ diff --git a/jeeps/gpsmem.h b/jeeps/gpsmem.h index 01038d9fa..2d9fe6588 100644 --- a/jeeps/gpsmem.h +++ b/jeeps/gpsmem.h @@ -1,6 +1,8 @@ #ifndef JEEPS_GPSMEM_H_INCLUDED_ #define JEEPS_GPSMEM_H_INCLUDED_ +constexpr double GPS_FLTMIN = 1.75494351E-38; +constexpr double GPS_FLTMAX = 3.402823466E+38; #include "jeeps/gps.h" GPS_PPvt_Data GPS_Pvt_New(); diff --git a/jeeps/gpsproj.cc b/jeeps/gpsproj.cc index 8f138e33b..9e6c0602e 100644 --- a/jeeps/gpsproj.cc +++ b/jeeps/gpsproj.cc @@ -21,9 +21,11 @@ ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ** Boston, MA 02110-1301, USA. ********************************************************************/ -#include "jeeps/gps.h" -#include -#include +#include "jeeps/gpsproj.h" + +#include // for sin, pow, cos, fabs, log, tan, asin, atan, atan2, sqrt, exp, acos, sinh + +#include "jeeps/gpsmath.h" // for GPS_Math_Deg_To_Rad, GPS_PI, GPS_Math_Rad_To_Deg, GPS_Math_EN_To_LatLon, GPS_Math_LatLon_To_EN, GPS_Math_Cassini_EN_To_LatLon, GPS_Math_Cassini_LatLon_To_EN, GPS_Math_Swiss_EN_To_LatLon, GPS_Math_Swiss_LatLon_To_EN /* @func GPS_Math_Albers_LatLon_To_EN ********************************** diff --git a/jeeps/gpsproj.h b/jeeps/gpsproj.h index cbdca53df..dd14711fd 100644 --- a/jeeps/gpsproj.h +++ b/jeeps/gpsproj.h @@ -2,147 +2,145 @@ #define JEEPS_GPSPROJ_H_INCLUDED_ -#include "jeeps/gps.h" +void GPS_Math_Albers_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi1, double phi2, + double phi0, double M0, double E0, + double N0, double a, double b); +void GPS_Math_Albers_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi1, double phi2, + double phi0, double M0, double E0, + double N0, double a, double b); + + +void GPS_Math_LambertCC_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi1, double phi2, + double phi0, double M0, double E0, + double N0, double a, double b); +void GPS_Math_LambertCC_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi1, double phi2, + double phi0, double M0, double E0, + double N0, double a, double b); + +void GPS_Math_Miller_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double M0, double E0, + double N0, double a, double b); +void GPS_Math_Miller_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double M0, double E0, + double N0, double a, double b); + +void GPS_Math_Bonne_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi0, double M0, double E0, + double N0, double a, double b); +void GPS_Math_Bonne_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double M0, + double E0, double N0, double a, double b); + +void GPS_Math_Cassini_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi0, double M0, + double E0, double N0, double a, double b); +void GPS_Math_Cassini_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double M0, + double E0, double N0, double a, double b); - void GPS_Math_Albers_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi1, double phi2, - double phi0, double M0, double E0, +void GPS_Math_Cylea_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi0, double M0, + double E0, double N0, double a, double b); +void GPS_Math_Cylea_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double M0, + double E0, double N0, double a, double b); + +void GPS_Math_EckertIV_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double M0, double E0, double N0, + double a, double b); +void GPS_Math_EckertIV_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double M0, double E0, double N0, double a, double b); - void GPS_Math_Albers_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi1, double phi2, - double phi0, double M0, double E0, + +void GPS_Math_EckertVI_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double M0, double E0, double N0, + double a, double b); +void GPS_Math_EckertVI_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double M0, double E0, double N0, double a, double b); +void GPS_Math_Cyled_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi0, double M0, double E0, + double N0, double a, double b); +void GPS_Math_Cyled_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double M0, + double E0, double N0, double a, double b); - void GPS_Math_LambertCC_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi1, double phi2, - double phi0, double M0, double E0, +void GPS_Math_VderGrinten_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double M0, double E0, double N0, double a, double b); - void GPS_Math_LambertCC_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi1, double phi2, - double phi0, double M0, double E0, +void GPS_Math_VderGrinten_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double M0, double E0, double N0, double a, double b); - void GPS_Math_Miller_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double M0, double E0, - double N0, double a, double b); - void GPS_Math_Miller_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double M0, double E0, - double N0, double a, double b); - - void GPS_Math_Bonne_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi0, double M0, double E0, - double N0, double a, double b); - void GPS_Math_Bonne_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double M0, +void GPS_Math_PolarSt_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi1, double lambda1, + double E0, double N0, double a, double b); +void GPS_Math_PolarSt_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi1, double lambda1, double E0, double N0, double a, double b); - void GPS_Math_Cassini_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi0, double M0, - double E0, double N0, double a, double b); - void GPS_Math_Cassini_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double M0, - double E0, double N0, double a, double b); - - void GPS_Math_Cylea_LatLon_To_EN(double phi, double lambda, double* E, +void GPS_Math_Mollweide_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double M0, double E0, + double N0, double a, double b); +void GPS_Math_Mollweide_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double M0, double E0, + double N0, double a, double b); + +void GPS_Math_Orthog_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi0, double lambda0, + double E0, double N0, double a, double b); +void GPS_Math_Orthog_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double lambda0, + double E0, double N0, double a, double b); + +void GPS_Math_Polycon_LatLon_To_EN(double phi, double lambda, double* E, double* N, double phi0, double M0, double E0, double N0, double a, double b); - void GPS_Math_Cylea_EN_To_LatLon(double E, double N, double* phi, +void GPS_Math_Polycon_EN_To_LatLon(double E, double N, double* phi, double* lambda, double phi0, double M0, double E0, double N0, double a, double b); - void GPS_Math_EckertIV_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double M0, double E0, double N0, - double a, double b); - void GPS_Math_EckertIV_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double M0, double E0, - double N0, double a, double b); - - void GPS_Math_EckertVI_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double M0, double E0, double N0, - double a, double b); - void GPS_Math_EckertVI_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double M0, double E0, - double N0, double a, double b); - - void GPS_Math_Cyled_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi0, double M0, double E0, - double N0, double a, double b); - void GPS_Math_Cyled_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double M0, - double E0, double N0, double a, double b); +void GPS_Math_Sinusoid_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double M0, double E0, + double N0, double a, double b); +void GPS_Math_Sinusoid_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double M0, double E0, + double N0, double a, double b); - void GPS_Math_VderGrinten_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double M0, double E0, - double N0, double a, double b); - void GPS_Math_VderGrinten_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double M0, double E0, - double N0, double a, double b); - - void GPS_Math_PolarSt_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi1, double lambda1, - double E0, double N0, double a, double b); - void GPS_Math_PolarSt_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi1, double lambda1, - double E0, double N0, double a, double b); - - void GPS_Math_Mollweide_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double M0, double E0, - double N0, double a, double b); - void GPS_Math_Mollweide_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double M0, double E0, - double N0, double a, double b); +void GPS_Math_TCylEA_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi0, double M0, double E0, + double N0, double a, double b); +void GPS_Math_TCylEA_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double M0, + double E0, double N0, double a, double b); - void GPS_Math_Orthog_LatLon_To_EN(double phi, double lambda, double* E, +void GPS_Math_Mercator_LatLon_To_EN(double phi, double lambda, double* E, double* N, double phi0, double lambda0, double E0, double N0, double a, double b); - void GPS_Math_Orthog_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double lambda0, - double E0, double N0, double a, double b); - - void GPS_Math_Polycon_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi0, double M0, - double E0, double N0, double a, double b); - void GPS_Math_Polycon_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double M0, - double E0, double N0, double a, double b); - - void GPS_Math_Sinusoid_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double M0, double E0, - double N0, double a, double b); - void GPS_Math_Sinusoid_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double M0, double E0, - double N0, double a, double b); - - void GPS_Math_TCylEA_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi0, double M0, double E0, - double N0, double a, double b); - void GPS_Math_TCylEA_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double M0, - double E0, double N0, double a, double b); - - void GPS_Math_Mercator_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi0, double lambda0, - double E0, double N0, double a, double b); - void GPS_Math_Mercator_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, - double lambda0, double E0, double N0, - double a, double b); - - void GPS_Math_TMerc_LatLon_To_EN(double phi, double lambda, double* E, - double* N, double phi0, double lambda0, - double E0, double N0, double F0, - double a, double b); - void GPS_Math_TMerc_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double lambda0, - double E0, double N0, double F0, - double a, double b); - - void GPS_Math_Swiss_LatLon_To_EN(double phi, double lambda, double* E, - double* N,double phi0,double lambda0, - double E0, double N0, double a, double b); - void GPS_Math_Swiss_EN_To_LatLon(double E, double N, double* phi, - double* lambda, double phi0, double lambda0, - double E0, double N0, double a, double b); +void GPS_Math_Mercator_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, + double lambda0, double E0, double N0, + double a, double b); + +void GPS_Math_TMerc_LatLon_To_EN(double phi, double lambda, double* E, + double* N, double phi0, double lambda0, + double E0, double N0, double F0, + double a, double b); +void GPS_Math_TMerc_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double lambda0, + double E0, double N0, double F0, + double a, double b); + +void GPS_Math_Swiss_LatLon_To_EN(double phi, double lambda, double* E, + double* N,double phi0,double lambda0, + double E0, double N0, double a, double b); +void GPS_Math_Swiss_EN_To_LatLon(double E, double N, double* phi, + double* lambda, double phi0, double lambda0, + double E0, double N0, double a, double b); #endif // JEEPS_GPSPROJ_H_INCLUDED_ From ad23c5767a149e71381503810677ba75df95c471 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:29:55 -0700 Subject: [PATCH 040/132] astyle jeeps included files (#1219) --- jeeps/gps.h | 26 +-- jeeps/gpsapp.h | 114 ++++++------ jeeps/gpscom.h | 4 +- jeeps/gpsdevice.h | 44 ++--- jeeps/gpsfmt.h | 10 +- jeeps/gpsmem.h | 32 ++-- jeeps/gpsprot.h | 462 +++++++++++++++++++++++----------------------- jeeps/gpsread.h | 4 +- jeeps/gpssend.h | 4 +- jeeps/gpsutil.h | 50 ++--- 10 files changed, 375 insertions(+), 375 deletions(-) diff --git a/jeeps/gps.h b/jeeps/gps.h index 7dd742c2a..f883911f3 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -31,7 +31,7 @@ extern char gps_categories[16][17]; struct GPS_Packet { US type{0}; uint32_t n{0}; - UC data[MAX_GPS_PACKET_SIZE]{}; + UC data[MAX_GPS_PACKET_SIZE] {}; }; @@ -154,16 +154,16 @@ typedef struct GPS_SWay { * Forerunner/Edge Lap data. */ typedef struct GPS_SLap { - uint32_t index; /* unique index in device or -1 */ + uint32_t index; /* unique index in device or -1 */ time_t start_time; - uint32_t total_time; /* Hundredths of a second */ + uint32_t total_time; /* Hundredths of a second */ float total_distance; /* In meters */ double begin_lat; double begin_lon; double end_lat; double end_lon; - int16_t calories; - uint32_t track_index; /* ref to track or -1 */ + int16_t calories; + uint32_t track_index; /* ref to track or -1 */ float max_speed; /* In meters per second */ unsigned char avg_heart_rate; /* In beats-per-minute, 0 if invalid */ unsigned char max_heart_rate; /* In beats-per-minute, 0 if invalid */ @@ -179,17 +179,17 @@ typedef struct GPS_SLap { typedef struct GPS_SCourse { - uint32_t index; /* Unique among courses on device */ + uint32_t index; /* Unique among courses on device */ char course_name[16]; /* Null-terminated unique course name */ - uint32_t track_index; /* Index of the associated track + uint32_t track_index; /* Index of the associated track * Must be 0xFFFFFFFF if there is none*/ } GPS_OCourse, *GPS_PCourse; typedef struct GPS_SCourse_Lap { - uint32_t course_index; /* Index of associated course */ - uint32_t lap_index; /* This lap's index in the course */ - uint32_t total_time; /* In hundredths of a second */ + uint32_t course_index; /* Index of associated course */ + uint32_t lap_index; /* This lap's index in the course */ + uint32_t total_time; /* In hundredths of a second */ float total_dist; /* [m] */ double begin_lat; /* Starting position of the lap */ double begin_lon; /* Invalid if lat,lon are 0x7FFFFFFF.*/ @@ -225,9 +225,9 @@ typedef struct GPS_SCourse_Point { } GPS_OCourse_Point, *GPS_PCourse_Point; typedef struct GPS_SCourse_Limits { - int32_t max_courses; - int32_t max_course_laps; - int32_t max_course_pnt; + int32_t max_courses; + int32_t max_course_laps; + int32_t max_course_pnt; int32_t max_course_trk_pnt; } GPS_OCourse_Limits, *GPS_PCourse_Limits; diff --git a/jeeps/gpsapp.h b/jeeps/gpsapp.h index 00f2736bb..52d4ee52f 100644 --- a/jeeps/gpsapp.h +++ b/jeeps/gpsapp.h @@ -22,17 +22,17 @@ int32_t GPS_A301_Send(const char* port, GPS_PTrack* trk, int32_t n, int protoid, gpsdevh* fd); int32_t GPS_D300_Get(GPS_PTrack* trk, int32_t entries, gpsdevh* h); - void GPS_D300b_Get(GPS_PTrack* trk, UC* data); - void GPS_D301b_Get(GPS_PTrack* trk, UC* data); - void GPS_D302b_Get(GPS_PTrack* trk, UC* data); - void GPS_D303b_Get(GPS_PTrack* trk, UC* data); /*D304*/ - void GPS_D310_Get(GPS_PTrack* trk, UC* s); - void GPS_D311_Get(GPS_PTrack* trk, UC* s); - void GPS_D300_Send(UC* data, GPS_PTrack trk, int32_t* len); - void GPS_D301_Send(UC* data, GPS_PTrack trk, int32_t* len, int type); - void GPS_D303_Send(UC* data, GPS_PTrack trk, int32_t* len, int protoid); - void GPS_D310_Send(UC* data, GPS_PTrack trk, int32_t* len); - void GPS_D311_Send(UC* data, GPS_PTrack trk, int32_t* len); +void GPS_D300b_Get(GPS_PTrack* trk, UC* data); +void GPS_D301b_Get(GPS_PTrack* trk, UC* data); +void GPS_D302b_Get(GPS_PTrack* trk, UC* data); +void GPS_D303b_Get(GPS_PTrack* trk, UC* data); /*D304*/ +void GPS_D310_Get(GPS_PTrack* trk, UC* s); +void GPS_D311_Get(GPS_PTrack* trk, UC* s); +void GPS_D300_Send(UC* data, GPS_PTrack trk, int32_t* len); +void GPS_D301_Send(UC* data, GPS_PTrack trk, int32_t* len, int type); +void GPS_D303_Send(UC* data, GPS_PTrack trk, int32_t* len, int protoid); +void GPS_D310_Send(UC* data, GPS_PTrack trk, int32_t* len); +void GPS_D311_Send(UC* data, GPS_PTrack trk, int32_t* len); int32_t GPS_A400_Get(const char* port, GPS_PWay** way); int32_t GPS_A400_Send(const char* port, GPS_PWay* way, int32_t n); @@ -40,76 +40,76 @@ int32_t GPS_A400_Send(const char* port, GPS_PWay* way, int32_t n); int32_t GPS_A500_Get(const char* port, GPS_PAlmanac** alm); int32_t GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32_t n); - time_t GPS_A600_Get(const char* port); - time_t GPS_D600_Get(const GPS_Packet& packet); +time_t GPS_A600_Get(const char* port); +time_t GPS_D600_Get(const GPS_Packet& packet); int32_t GPS_A600_Send(const char* port, time_t Time); - void GPS_D600_Send(GPS_Packet& packet, time_t Time); +void GPS_D600_Send(GPS_Packet& packet, time_t Time); int32_t GPS_A700_Get(const char* port, double* lat, double* lon); int32_t GPS_A700_Send(const char* port, double lat, double lon); - void GPS_D700_Get(const GPS_Packet& packet, double* lat, double* lon); - void GPS_D700_Send(GPS_Packet& packet, double lat, double lon); +void GPS_D700_Get(const GPS_Packet& packet, double* lat, double* lon); +void GPS_D700_Send(GPS_Packet& packet, double lat, double lon); int32_t GPS_A800_On(const char* port, gpsdevh** fd); int32_t GPS_A800_Off(const char* port, gpsdevh** fd); int32_t GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet); - void GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt); +void GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt); int32_t GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb); - void GPS_D1011b_Get(GPS_PLap* Lap,UC* data); /*D906 D1001 D1015*/ +void GPS_D1011b_Get(GPS_PLap* Lap,UC* data); /*D906 D1001 D1015*/ int32_t GPS_A1006_Get(const char* port, GPS_PCourse** crs, pcb_fn cb); int32_t GPS_A1006_Send(const char* port, GPS_PCourse* crs, int32_t n_crs, gpsdevh* fd); - void GPS_D1006_Get(GPS_PCourse* crs, UC* p); - void GPS_D1006_Send(UC* data, GPS_PCourse crs, int32_t* len); +void GPS_D1006_Get(GPS_PCourse* crs, UC* p); +void GPS_D1006_Send(UC* data, GPS_PCourse crs, int32_t* len); int32_t GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb); int32_t GPS_A1007_Send(const char* port, GPS_PCourse_Lap* clp, int32_t n_clp, gpsdevh* fd); - void GPS_D1007_Get(GPS_PCourse_Lap* clp, UC* p); - void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32_t* len); +void GPS_D1007_Get(GPS_PCourse_Lap* clp, UC* p); +void GPS_D1007_Send(UC* data, GPS_PCourse_Lap clp, int32_t* len); int32_t GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb); int32_t GPS_A1008_Send(const char* port, GPS_PCourse_Point* cpt, int32_t n_cpt, gpsdevh* fd); - void GPS_D1012_Get(GPS_PCourse_Point* cpt, UC* p); - void GPS_D1012_Send(UC* data, GPS_PCourse_Point cpt, int32_t* len); +void GPS_D1012_Get(GPS_PCourse_Point* cpt, UC* p); +void GPS_D1012_Send(UC* data, GPS_PCourse_Point cpt, int32_t* len); int32_t GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits); - void GPS_D1013_Get(GPS_PCourse_Limits limits, UC* p); - - /* Unhandled documented protocols, as of: - Garmin Device Interface Specification, May 19, 2006, Drawing Number: 001-00063-00 Rev. C - A650 FlightBook Transfer Protocol - A1000 Run Transfer Protocol - Capability A1000: D1009 - D1000 D1010 - A1002 Workout Transfer Protocol - Capability A1002: D1008 - D1002 - Capability A1003: D1003 - A1004 Fitness User Profile Transfer Protocol - Capability A1004: D1004 - A1005 Workout Limits Transfer Protocol - Capability A1005: D1005 - */ - /* Unimplemented and Undocumented, as listed from the following device/sw: - GF305 3.70 - - Capability A601: D601 - Capability A801: D801 - - Capability A902: - Capability A903: - Capability A907: D907 D908 D909 D910 - Capability A918: D918 - Capability A1013: D1014 - */ - - const char* Get_Pkt_Type(US p, US d0, const char** xinfo); - - void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32_t* n); +void GPS_D1013_Get(GPS_PCourse_Limits limits, UC* p); + +/* Unhandled documented protocols, as of: + Garmin Device Interface Specification, May 19, 2006, Drawing Number: 001-00063-00 Rev. C +A650 FlightBook Transfer Protocol +A1000 Run Transfer Protocol + Capability A1000: D1009 + D1000 D1010 +A1002 Workout Transfer Protocol + Capability A1002: D1008 + D1002 + Capability A1003: D1003 +A1004 Fitness User Profile Transfer Protocol + Capability A1004: D1004 +A1005 Workout Limits Transfer Protocol + Capability A1005: D1005 +*/ +/* Unimplemented and Undocumented, as listed from the following device/sw: + GF305 3.70 + +Capability A601: D601 +Capability A801: D801 + +Capability A902: +Capability A903: +Capability A907: D907 D908 D909 D910 +Capability A918: D918 +Capability A1013: D1014 +*/ + +const char* Get_Pkt_Type(US p, US d0, const char** xinfo); + +void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32_t* n); int32_t GPS_Set_Baud_Rate(const char* port, int br); #endif // JEEPS_GPSAPP_H_INCLUDED_ diff --git a/jeeps/gpscom.h b/jeeps/gpscom.h index 88f7f6c69..bb34cb81f 100644 --- a/jeeps/gpscom.h +++ b/jeeps/gpscom.h @@ -7,7 +7,7 @@ int32_t GPS_Command_Off(const char* port); - time_t GPS_Command_Get_Time(const char* port); +time_t GPS_Command_Get_Time(const char* port); int32_t GPS_Command_Send_Time(const char* port, time_t Time); int32_t GPS_Command_Get_Position(const char* port, double* lat, double* lon); @@ -38,7 +38,7 @@ int32_t GPS_Command_Send_Course(const char* port, GPS_PCourse* crs, GPS_PCourse_ GPS_PTrack* trk, GPS_PCourse_Point* cpt, int32_t n_crs, int32_t n_clp, int32_t n_trk, int32_t n_cpt); int32_t GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32_t n_trk, - GPS_PWay* wpt, int32_t n_wpt, int eraset); + GPS_PWay* wpt, int32_t n_wpt, int eraset); int32_t GPS_Command_Get_Workout(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); int32_t GPS_Command_Get_Fitness_User_Profile(const char* port, void** lap, int (*cb)(int, GPS_SWay**)); diff --git a/jeeps/gpsdevice.h b/jeeps/gpsdevice.h index 444e869a6..757acb14d 100644 --- a/jeeps/gpsdevice.h +++ b/jeeps/gpsdevice.h @@ -22,7 +22,7 @@ #ifndef JEEPS_GPSDEVICE_H_INCLUDED_ #define JEEPS_GPSDEVICE_H_INCLUDED_ - typedef struct gpsdevh gpsdevh; +typedef struct gpsdevh gpsdevh; #include "jeeps/gps.h" @@ -36,28 +36,28 @@ int32_t GPS_Device_Wait(gpsdevh* fd); int32_t GPS_Device_Flush(gpsdevh* fd); int32_t GPS_Device_Read(int32_t ignored, void* ibuf, int size); int32_t GPS_Device_Write(int32_t ignored, const void* obuf, int size); - void GPS_Device_Error(char* hdr, ...); +void GPS_Device_Error(char* hdr, ...); int32_t GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet); - bool GPS_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); +bool GPS_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); int32_t GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet); - bool GPS_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); - - using gps_device_op = int32_t (*)(gpsdevh*); - using gps_device_op5 = int32_t (*)(const char*, gpsdevh** fd); - using gps_device_op10 = bool (*)(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); - using gps_device_op12 = int32_t (*)(gpsdevh* fd, const GPS_Packet& packet); - using gps_device_op13 = int32_t (*)(gpsdevh* fd, GPS_Packet* packet); - - typedef struct { - gps_device_op5 Device_On; - gps_device_op Device_Off; - gps_device_op Device_Chars_Ready; - gps_device_op Device_Wait; - gps_device_op Device_Flush; - gps_device_op10 Send_Ack; - gps_device_op10 Get_Ack; - gps_device_op13 Read_Packet; - gps_device_op12 Write_Packet; - } gps_device_ops; +bool GPS_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); + +using gps_device_op = int32_t (*)(gpsdevh*); +using gps_device_op5 = int32_t (*)(const char*, gpsdevh** fd); +using gps_device_op10 = bool (*)(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); +using gps_device_op12 = int32_t (*)(gpsdevh* fd, const GPS_Packet& packet); +using gps_device_op13 = int32_t (*)(gpsdevh* fd, GPS_Packet* packet); + +typedef struct { + gps_device_op5 Device_On; + gps_device_op Device_Off; + gps_device_op Device_Chars_Ready; + gps_device_op Device_Wait; + gps_device_op Device_Flush; + gps_device_op10 Send_Ack; + gps_device_op10 Get_Ack; + gps_device_op13 Read_Packet; + gps_device_op12 Write_Packet; +} gps_device_ops; #endif /* JEEPS_GPSDEVICE_H_INCLUDED_ */ diff --git a/jeeps/gpsfmt.h b/jeeps/gpsfmt.h index 9471eb3f4..8b0d3a8ff 100644 --- a/jeeps/gpsfmt.h +++ b/jeeps/gpsfmt.h @@ -6,11 +6,11 @@ #include #include - void GPS_Fmt_Print_Time(time_t Time, FILE* outf); - void GPS_Fmt_Print_Position(double lat, double lon, FILE* outf); - void GPS_Fmt_Print_Pvt(GPS_PPvt_Data pvt, FILE* outf); - void GPS_Fmt_Print_Almanac(GPS_PAlmanac* alm, int32_t n, FILE* outf); - void GPS_Fmt_Print_Track(GPS_PTrack* trk, int32_t n, FILE* outf); +void GPS_Fmt_Print_Time(time_t Time, FILE* outf); +void GPS_Fmt_Print_Position(double lat, double lon, FILE* outf); +void GPS_Fmt_Print_Pvt(GPS_PPvt_Data pvt, FILE* outf); +void GPS_Fmt_Print_Almanac(GPS_PAlmanac* alm, int32_t n, FILE* outf); +void GPS_Fmt_Print_Track(GPS_PTrack* trk, int32_t n, FILE* outf); int32_t GPS_Fmt_Print_Waypoint(GPS_PWay* way, int32_t n, FILE* outf); int32_t GPS_Fmt_Print_Proximity(GPS_PWay* way, int32_t n, FILE* outf); int32_t GPS_Fmt_Print_Route(GPS_PWay* way, int32_t n, FILE* outf); diff --git a/jeeps/gpsmem.h b/jeeps/gpsmem.h index 2d9fe6588..1e249483b 100644 --- a/jeeps/gpsmem.h +++ b/jeeps/gpsmem.h @@ -5,21 +5,21 @@ constexpr double GPS_FLTMIN = 1.75494351E-38; constexpr double GPS_FLTMAX = 3.402823466E+38; #include "jeeps/gps.h" - GPS_PPvt_Data GPS_Pvt_New(); - void GPS_Pvt_Del(GPS_PPvt_Data* thys); - GPS_PAlmanac GPS_Almanac_New(); - void GPS_Almanac_Del(GPS_PAlmanac* thys); - GPS_PTrack GPS_Track_New(); - void GPS_Track_Del(GPS_PTrack* thys); - GPS_PWay GPS_Way_New(); - void GPS_Way_Del(GPS_PWay* thys); - GPS_PLap GPS_Lap_New(); - void GPS_Lap_Del(GPS_PLap* thys); - GPS_PCourse GPS_Course_New(); - void GPS_Course_Del(GPS_PCourse* thys); - GPS_PCourse_Lap GPS_Course_Lap_New(); - void GPS_Course_Lap_Del(GPS_PCourse_Lap* thys); - GPS_PCourse_Point GPS_Course_Point_New(); - void GPS_Course_Point_Del(GPS_PCourse_Point* thys); +GPS_PPvt_Data GPS_Pvt_New(); +void GPS_Pvt_Del(GPS_PPvt_Data* thys); +GPS_PAlmanac GPS_Almanac_New(); +void GPS_Almanac_Del(GPS_PAlmanac* thys); +GPS_PTrack GPS_Track_New(); +void GPS_Track_Del(GPS_PTrack* thys); +GPS_PWay GPS_Way_New(); +void GPS_Way_Del(GPS_PWay* thys); +GPS_PLap GPS_Lap_New(); +void GPS_Lap_Del(GPS_PLap* thys); +GPS_PCourse GPS_Course_New(); +void GPS_Course_Del(GPS_PCourse* thys); +GPS_PCourse_Lap GPS_Course_Lap_New(); +void GPS_Course_Lap_Del(GPS_PCourse_Lap* thys); +GPS_PCourse_Point GPS_Course_Point_New(); +void GPS_Course_Point_Del(GPS_PCourse_Point* thys); #endif // JEEPS_GPSMEM_H_INCLUDED_ diff --git a/jeeps/gpsprot.h b/jeeps/gpsprot.h index 12d45b55d..2a296a6c6 100644 --- a/jeeps/gpsprot.h +++ b/jeeps/gpsprot.h @@ -7,191 +7,191 @@ #include "jeeps/gps.h" - /* - * Link protocols - */ - - struct LINKDATA { - US Pid_Protocol_Array; - US Pid_Product_Rqst; - US Pid_Product_Data; - US Pid_Ext_Product_Data; - - US Pid_Ack_Byte; - US Pid_Command_Data; - US Pid_Xfer_Cmplt; - US Pid_Date_Time_Data; - US Pid_Position_Data; - US Pid_Prx_Wpt_Data; - US Pid_Nak_Byte; - US Pid_Records; - US Pid_Rte_Hdr; - US Pid_Rte_Wpt_Data; - US Pid_Almanac_Data; - US Pid_Trk_Data; - US Pid_Wpt_Data; - US Pid_Pvt_Data; - US Pid_Rte_Link_Data; - US Pid_Trk_Hdr; - - US Pid_FlightBook_Record; - US Pid_Lap; - US Pid_Wpt_Cat; - US Pid_Run; - US Pid_Workout; - US Pid_Workout_Occurrence; - US Pid_Fitness_User_Profile; - US Pid_Workout_Limits; - US Pid_Course; - US Pid_Course_Lap; - US Pid_Course_Point; - US Pid_Course_Trk_Hdr; - US Pid_Course_Trk_Data; - US Pid_Course_Limits; - US Pid_Trk2_Hdr; /*Undocumented*/ - }; - - - - - - /* - * Command types - */ +/* + * Link protocols + */ + +struct LINKDATA { + US Pid_Protocol_Array; + US Pid_Product_Rqst; + US Pid_Product_Data; + US Pid_Ext_Product_Data; + + US Pid_Ack_Byte; + US Pid_Command_Data; + US Pid_Xfer_Cmplt; + US Pid_Date_Time_Data; + US Pid_Position_Data; + US Pid_Prx_Wpt_Data; + US Pid_Nak_Byte; + US Pid_Records; + US Pid_Rte_Hdr; + US Pid_Rte_Wpt_Data; + US Pid_Almanac_Data; + US Pid_Trk_Data; + US Pid_Wpt_Data; + US Pid_Pvt_Data; + US Pid_Rte_Link_Data; + US Pid_Trk_Hdr; + + US Pid_FlightBook_Record; + US Pid_Lap; + US Pid_Wpt_Cat; + US Pid_Run; + US Pid_Workout; + US Pid_Workout_Occurrence; + US Pid_Fitness_User_Profile; + US Pid_Workout_Limits; + US Pid_Course; + US Pid_Course_Lap; + US Pid_Course_Point; + US Pid_Course_Trk_Hdr; + US Pid_Course_Trk_Data; + US Pid_Course_Limits; + US Pid_Trk2_Hdr; /*Undocumented*/ +}; + + + + + +/* + * Command types + */ #define pA010 10 #define pA011 11 - COMMON int32_t gps_device_command; - - - struct COMMANDDATA { - US Cmnd_Abort_Transfer; - US Cmnd_Transfer_Alm; - US Cmnd_Transfer_Posn; - US Cmnd_Transfer_Prx; - US Cmnd_Transfer_Rte; - US Cmnd_Transfer_Time; - US Cmnd_Transfer_Trk; - US Cmnd_Transfer_Wpt; - US Cmnd_Turn_Off_Pwr; - US Cmnd_Start_Pvt_Data; - US Cmnd_Stop_Pvt_Data; - US Cmnd_FlightBook_Transfer; - US Cmnd_Transfer_Laps; - US Cmnd_Transfer_Wpt_Cats; - US Cmnd_Transfer_Runs; - US Cmnd_Transfer_Workouts; - US Cmnd_Transfer_Workout_Occurrences; - US Cmnd_Transfer_Fitness_User_Profile; - US Cmnd_Transfer_Workout_Limits; - US Cmnd_Transfer_Courses; - US Cmnd_Transfer_Course_Laps; - US Cmnd_Transfer_Course_Points; - US Cmnd_Transfer_Course_Tracks; - US Cmnd_Transfer_Course_Limits; - }; - - - - - /* - * Waypoint Transfer Protocol - */ +COMMON int32_t gps_device_command; + + +struct COMMANDDATA { + US Cmnd_Abort_Transfer; + US Cmnd_Transfer_Alm; + US Cmnd_Transfer_Posn; + US Cmnd_Transfer_Prx; + US Cmnd_Transfer_Rte; + US Cmnd_Transfer_Time; + US Cmnd_Transfer_Trk; + US Cmnd_Transfer_Wpt; + US Cmnd_Turn_Off_Pwr; + US Cmnd_Start_Pvt_Data; + US Cmnd_Stop_Pvt_Data; + US Cmnd_FlightBook_Transfer; + US Cmnd_Transfer_Laps; + US Cmnd_Transfer_Wpt_Cats; + US Cmnd_Transfer_Runs; + US Cmnd_Transfer_Workouts; + US Cmnd_Transfer_Workout_Occurrences; + US Cmnd_Transfer_Fitness_User_Profile; + US Cmnd_Transfer_Workout_Limits; + US Cmnd_Transfer_Courses; + US Cmnd_Transfer_Course_Laps; + US Cmnd_Transfer_Course_Points; + US Cmnd_Transfer_Course_Tracks; + US Cmnd_Transfer_Course_Limits; +}; + + + + +/* + * Waypoint Transfer Protocol + */ #define pA100 100 - COMMON int32_t gps_waypt_transfer; +COMMON int32_t gps_waypt_transfer; - /* - * Waypoint category transfer protocol - */ +/* + * Waypoint category transfer protocol + */ #define pA101 101 - COMMON int32_t gps_category_transfer; +COMMON int32_t gps_category_transfer; - /* - * Route Transfer Protocol - */ +/* + * Route Transfer Protocol + */ #define pA200 200 #define pA201 201 - COMMON int32_t gps_route_transfer; +COMMON int32_t gps_route_transfer; - /* - * Track Log Transfer Protocol - */ +/* + * Track Log Transfer Protocol + */ #define pA300 300 #define pA301 301 #define pA302 302 #define pA304 304 - COMMON int32_t gps_trk_transfer; +COMMON int32_t gps_trk_transfer; - /* - * Proximity Waypoint Transfer Protocol - */ +/* + * Proximity Waypoint Transfer Protocol + */ #define pA400 400 - COMMON int32_t gps_prx_waypt_transfer; +COMMON int32_t gps_prx_waypt_transfer; - /* - * Almanac Transfer Protocol - */ +/* + * Almanac Transfer Protocol + */ #define pA500 500 - COMMON int32_t gps_almanac_transfer; +COMMON int32_t gps_almanac_transfer; - /* - * Date Time Transfer - */ +/* + * Date Time Transfer + */ #define pA600 600 - COMMON int32_t gps_date_time_transfer; +COMMON int32_t gps_date_time_transfer; - /* - * FlightBook Transfer Protocol - */ +/* + * FlightBook Transfer Protocol + */ #define pA650 650 - /*Not implemented */ +/*Not implemented */ - /* - * Position - */ +/* + * Position + */ #define pA700 700 - COMMON int32_t gps_position_transfer; +COMMON int32_t gps_position_transfer; - /* - * Pvt - */ +/* + * Pvt + */ #define pA800 800 - COMMON int32_t gps_pvt_transfer; +COMMON int32_t gps_pvt_transfer; - /* - * Lap Data Transfer - */ +/* + * Lap Data Transfer + */ #define pA906 906 - COMMON int32_t gps_lap_transfer; +COMMON int32_t gps_lap_transfer; - /* - * Various fitness related - */ +/* + * Various fitness related + */ #define pA1000 1000 - COMMON int32_t gps_run_transfer; +COMMON int32_t gps_run_transfer; #define pA1002 1002 - COMMON int32_t gps_workout_transfer; +COMMON int32_t gps_workout_transfer; #define pA1004 1004 - COMMON int32_t gps_user_profile_transfer; +COMMON int32_t gps_user_profile_transfer; #define pA1005 1005 - COMMON int32_t gps_workout_limits_transfer; +COMMON int32_t gps_workout_limits_transfer; #define pA1006 1006 - COMMON int32_t gps_course_transfer; +COMMON int32_t gps_course_transfer; #define pA1007 1007 - COMMON int32_t gps_course_lap_transfer; +COMMON int32_t gps_course_lap_transfer; #define pA1008 1008 - COMMON int32_t gps_course_point_transfer; +COMMON int32_t gps_course_point_transfer; #define pA1009 1009 - COMMON int32_t gps_course_limits_transfer; +COMMON int32_t gps_course_limits_transfer; #define pA1012 1012 - COMMON int32_t gps_course_trk_transfer; +COMMON int32_t gps_course_trk_transfer; - /* - * Waypoint D Type - */ +/* + * Waypoint D Type + */ #define pD100 100 #define pD101 101 #define pD102 102 @@ -209,167 +209,167 @@ #define pD154 154 #define pD155 155 - COMMON int32_t gps_rte_type; - COMMON int32_t gps_waypt_type; +COMMON int32_t gps_rte_type; +COMMON int32_t gps_waypt_type; - /* - * Waypoint category types - */ +/* + * Waypoint category types + */ #define pD120 120 - COMMON int32_t gps_category_type; +COMMON int32_t gps_category_type; - /* - * Rte Header Type - */ +/* + * Rte Header Type + */ #define pD200 200 #define pD201 201 #define pD202 202 - COMMON int32_t gps_rte_hdr_type; +COMMON int32_t gps_rte_hdr_type; - /* - * Rte Link Type - */ +/* + * Rte Link Type + */ #define pD210 210 - COMMON int32_t gps_rte_link_type; +COMMON int32_t gps_rte_link_type; - /* - * Trk Point Type - */ +/* + * Trk Point Type + */ #define pD300 300 #define pD301 301 #define pD302 302 #define pD303 303 #define pD304 304 - COMMON int32_t gps_trk_type; - COMMON int32_t gps_run_crs_trk_type; +COMMON int32_t gps_trk_type; +COMMON int32_t gps_run_crs_trk_type; - /* - * Trk Header Type - */ +/* + * Trk Header Type + */ #define pD310 310 #define pD311 311 #define pD312 312 - COMMON int32_t gps_trk_hdr_type; - COMMON int32_t gps_run_crs_trk_hdr_type; +COMMON int32_t gps_trk_hdr_type; +COMMON int32_t gps_run_crs_trk_hdr_type; - /* - * Prx Wpt Type - */ +/* + * Prx Wpt Type + */ #define pD400 400 #define pD403 403 #define pD450 450 - COMMON int32_t gps_prx_waypt_type; +COMMON int32_t gps_prx_waypt_type; - /* - * Almanac Type - */ +/* + * Almanac Type + */ #define pD500 500 #define pD501 501 #define pD550 550 #define pD551 551 - COMMON int32_t gps_almanac_type; +COMMON int32_t gps_almanac_type; - /* - * Date Time Type - */ +/* + * Date Time Type + */ #define pD600 600 - COMMON int32_t gps_date_time_type; +COMMON int32_t gps_date_time_type; - /* - * Position Type - */ +/* + * Position Type + */ #define pD700 700 - COMMON int32_t gps_position_type; +COMMON int32_t gps_position_type; - /* - * Pvt Data Type - */ +/* + * Pvt Data Type + */ #define pD800 800 - COMMON int32_t gps_pvt_type; +COMMON int32_t gps_pvt_type; - /* - * Lap Data Type - */ +/* + * Lap Data Type + */ #define pD906 906 #define pD1001 1001 #define pD1011 1011 #define pD1015 1015 - COMMON int32_t gps_lap_type; +COMMON int32_t gps_lap_type; - /* - * Various fitness related - */ +/* + * Various fitness related + */ #define pD1000 1000 #define pD1009 1009 #define pD1010 1010 - COMMON int32_t gps_run_type; +COMMON int32_t gps_run_type; #define pD1002 1002 #define pD1008 1008 - COMMON int32_t gps_workout_type; +COMMON int32_t gps_workout_type; #define pD1003 1003 - COMMON int32_t gps_workout_occurrence_type; +COMMON int32_t gps_workout_occurrence_type; #define pD1004 1004 - COMMON int32_t gps_user_profile_type; +COMMON int32_t gps_user_profile_type; #define pD1005 1005 - COMMON int32_t gps_workout_limits_type; +COMMON int32_t gps_workout_limits_type; #define pD1006 1006 - COMMON int32_t gps_course_type; +COMMON int32_t gps_course_type; #define pD1007 1007 - COMMON int32_t gps_course_lap_type; +COMMON int32_t gps_course_lap_type; #define pD1012 1012 - COMMON int32_t gps_course_point_type; +COMMON int32_t gps_course_point_type; #define pD1013 1013 - COMMON int32_t gps_course_limits_type; +COMMON int32_t gps_course_limits_type; - /* - * Link protocol type - */ +/* + * Link protocol type + */ #define pL000 0 #define pL001 1 #define pL002 2 - COMMON int32_t gps_link_type; - - - - struct GPS_MODEL_PROTOCOL { - US id; - int32_t link; - int32_t command; - int32_t wayptt; - int32_t wayptd; - int32_t rtea; - int32_t rted0; - int32_t rted1; - int32_t trka; - int32_t trkd; - int32_t prxa; - int32_t prxd; - int32_t alma; - int32_t almd; - }; - - US GPS_Protocol_Version_Change(US id, US version); - COMMON int32_t GPS_Protocol_Table_Set(US id); - void GPS_Protocol_Error(US tag, US data); - void GPS_Unknown_Protocol_Print(); +COMMON int32_t gps_link_type; + + + +struct GPS_MODEL_PROTOCOL { + US id; + int32_t link; + int32_t command; + int32_t wayptt; + int32_t wayptd; + int32_t rtea; + int32_t rted0; + int32_t rted1; + int32_t trka; + int32_t trkd; + int32_t prxa; + int32_t prxd; + int32_t alma; + int32_t almd; +}; + +US GPS_Protocol_Version_Change(US id, US version); +COMMON int32_t GPS_Protocol_Table_Set(US id); +void GPS_Protocol_Error(US tag, US data); +void GPS_Unknown_Protocol_Print(); #endif // JEEPS_GPSPROT_H_INCLUDED_ diff --git a/jeeps/gpsread.h b/jeeps/gpsread.h index c5937234c..e28287293 100644 --- a/jeeps/gpsread.h +++ b/jeeps/gpsread.h @@ -4,8 +4,8 @@ #include "jeeps/gps.h" - time_t GPS_Time_Now(); +time_t GPS_Time_Now(); int32_t GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet); - bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_Packet *tra, GPS_Packet *rec); +bool GPS_Serial_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); #endif // JEEPS_GPSREAD_H_INCLUDED_ diff --git a/jeeps/gpssend.h b/jeeps/gpssend.h index a4954a9e4..9c5827124 100644 --- a/jeeps/gpssend.h +++ b/jeeps/gpssend.h @@ -7,9 +7,9 @@ #define GPS_ARB_LEN 1024 int32_t GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet); - bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); +bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec); - void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32_t n); +void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32_t n); #endif // JEEPS_GPSSEND_H_INCLUDED_ diff --git a/jeeps/gpsutil.h b/jeeps/gpsutil.h index 87f47e23d..0e50f703a 100644 --- a/jeeps/gpsutil.h +++ b/jeeps/gpsutil.h @@ -6,35 +6,35 @@ int32_t GPS_Util_Little(); - US GPS_Util_Get_Short(const UC* s); - void GPS_Util_Put_Short(UC* s, US v); +US GPS_Util_Get_Short(const UC* s); +void GPS_Util_Put_Short(UC* s, US v); int32_t GPS_Util_Get_Int(const UC* s); - void GPS_Util_Put_Int(UC* s, int32_t v); - double GPS_Util_Get_Double(const UC* s); - void GPS_Util_Put_Double(UC* s, double v); - float GPS_Util_Get_Float(const UC* s); - void GPS_Util_Put_Float(UC* s, float v); - void GPS_Util_Canon(int32_t state); +void GPS_Util_Put_Int(UC* s, int32_t v); +double GPS_Util_Get_Double(const UC* s); +void GPS_Util_Put_Double(UC* s, double v); +float GPS_Util_Get_Float(const UC* s); +void GPS_Util_Put_Float(UC* s, float v); +void GPS_Util_Canon(int32_t state); int32_t GPS_Util_Block(int32_t fd, int32_t state); - void GPS_Util_Put_Uint(UC* s, uint32_t v); +void GPS_Util_Put_Uint(UC* s, uint32_t v); uint32_t GPS_Util_Get_Uint(const UC* s); - void GPS_Warning(const char* s); - [[gnu::format(printf, 1, 2)]] void GPS_Error(const char* fmt, ...); - [[gnu::format(printf, 1, 2)]] void GPS_Serial_Error(const char* fmt, ...); - [[noreturn]] void GPS_Fatal(const char* s); - void GPS_Enable_Error(); - void GPS_Enable_Warning(); - void GPS_Disable_Error(); - void GPS_Disable_Warning(); - [[gnu::format(printf, 1, 2)]] void GPS_User(const char* fmt, ...); - void GPS_Disable_User(); - void GPS_Enable_User(); - void GPS_Diagnose(int32_t c); - [[gnu::format(printf, 1, 2)]] void GPS_Diag(const char* fmt, ...); - - void GPS_Enable_Diagnose(); - void GPS_Disable_Diagnose(); +void GPS_Warning(const char* s); +[[gnu::format(printf, 1, 2)]] void GPS_Error(const char* fmt, ...); +[[gnu::format(printf, 1, 2)]] void GPS_Serial_Error(const char* fmt, ...); +[[noreturn]] void GPS_Fatal(const char* s); +void GPS_Enable_Error(); +void GPS_Enable_Warning(); +void GPS_Disable_Error(); +void GPS_Disable_Warning(); +[[gnu::format(printf, 1, 2)]] void GPS_User(const char* fmt, ...); +void GPS_Disable_User(); +void GPS_Enable_User(); +void GPS_Diagnose(int32_t c); +[[gnu::format(printf, 1, 2)]] void GPS_Diag(const char* fmt, ...); + +void GPS_Enable_Diagnose(); +void GPS_Disable_Diagnose(); #endif // JEEPS_GPSUTIL_H_INCLUDED_ From 9abb5be03d5bb7176e5b13d005d45e36645e09ec Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:00:59 -0700 Subject: [PATCH 041/132] convert garmin to Format class (#1222) * convert garmin to format class. * add new file garmin.h * make some member fns static. * init member var --- CMakeLists.txt | 1 + garmin.cc | 273 ++++++++++++++++--------------------------------- garmin.h | 206 +++++++++++++++++++++++++++++++++++++ vecs.cc | 4 +- 4 files changed, 295 insertions(+), 189 deletions(-) create mode 100644 garmin.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c664f0ed8..995f6b724 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,6 +201,7 @@ set(HEADERS filter_vecs.h format.h formspec.h + garmin.h garmin_fit.h garmin_fs.h garmin_gpi.h diff --git a/garmin.cc b/garmin.cc index cfe7674a0..ce6fa3207 100644 --- a/garmin.cc +++ b/garmin.cc @@ -19,6 +19,8 @@ */ +#include "garmin.h" + #include // for assert #include // for INT_MAX #include // for atan2, floor, sqrt @@ -32,7 +34,6 @@ #include // for QRegularExpression #include // for QString #include // for QTextCodec -#include // for QVector #include // for CaseInsensitive #include // for qPrintable, foreach @@ -44,7 +45,6 @@ #include "grtcirc.h" // for DEG #include "jeeps/gpsapp.h" // for GPS_Set_Baud_Rate, GPS_Init, GPS_Pre... #include "jeeps/gpscom.h" // for GPS_Command_Get_Lap, GPS_Command_Get... -#include "jeeps/gpsdevice.h" // for gpsdevh #include "jeeps/gpsmem.h" // for GPS_Track_Del, GPS_Way_Del, GPS_Pvt_Del #include "jeeps/gpsport.h" // for int32 #include "jeeps/gpsprot.h" // for gps_waypt_type, gps_category_type @@ -56,109 +56,34 @@ #define MYNAME "GARMIN" -static const char* portname; -static MakeShort* mkshort_handle; -static GPS_PWay* tx_waylist; -static GPS_PWay* tx_routelist; -static GPS_PWay* cur_tx_routelist_entry; -static GPS_PTrack* tx_tracklist; -static GPS_PTrack* cur_tx_tracklist_entry; -static int my_track_count = 0; -static char* getposn = nullptr; -static char* poweroff = nullptr; -static char* eraset = nullptr; -static char* resettime = nullptr; -static char* snlen = nullptr; -static char* snwhiteopt = nullptr; -static char* deficon = nullptr; -static char* category = nullptr; -static char* categorybitsopt = nullptr; -static char* baudopt = nullptr; -static char* opt_codec = nullptr; -static int baud = 0; -static int categorybits; -static bool receiver_must_upper = true; -static QTextCodec* codec{nullptr}; #define MILITANT_VALID_WAYPT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" -/* Technically, even this is a little loose as spaces aren't allowed */ -static const char* valid_waypt_chars = MILITANT_VALID_WAYPT_CHARS " "; -static QRegularExpression invalid_char_re; - -static -QVector garmin_args = { - { - "snlen", &snlen, "Length of generated shortnames", nullptr, - ARGTYPE_INT, "1", nullptr, nullptr - }, - { - "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { "deficon", &deficon, "Default icon name", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, - { - "get_posn", &getposn, "Return current position as a waypoint", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "power_off", &poweroff, "Command unit to power itself down", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "erase_t", &eraset, "Erase existing courses when writing new ones", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "resettime", &resettime, "Sync GPS time to computer time", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "category", &category, "Category number to use for written waypoints", - nullptr, ARGTYPE_INT, "1", "16", nullptr - }, - { - "bitscategory", &categorybitsopt, "Bitmap of categories", - nullptr, ARGTYPE_INT, "1", "65535", nullptr - }, - { - "baud", &baudopt, "Speed in bits per second of serial port (baud=9600)", - nullptr, ARGTYPE_INT, ARG_NOMINMAX, nullptr - }, - { - "codec", &opt_codec, "override codec to use for device", - nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, - -}; - -static const char* d103_symbol_from_icon_number(unsigned int n); -static int d103_icon_number_from_symbol(const QString& s); -static void garmin_fs_garmin_after_read(GPS_PWay way, Waypoint* wpt, int protoid); -static void garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, int protoid); - -static QByteArray str_from_unicode(const QString& qstr) + +QByteArray GarminFormat::str_from_unicode(const QString& qstr) { return codec->fromUnicode(qstr); } -static QString str_to_unicode(const QByteArray& cstr) +QString GarminFormat::str_to_unicode(const QByteArray& cstr) { return codec->toUnicode(cstr); } -static void -write_char_string(char* dest, const char* source, size_t destsize) +void +GarminFormat::write_char_string(char* dest, const char* source, size_t destsize) { // we zero fill and always terminate within the dest buffer. strncpy(dest, source, destsize - 1); dest[destsize-1] = 0; } -static void -rw_init(const QString& fname) +void +GarminFormat::rw_init(const QString& fname) { receiver_must_upper = true; const char* receiver_charset = "US-ASCII"; + /* Technically, even this is a little loose as spaces aren't allowed */ + const char* valid_waypt_chars = MILITANT_VALID_WAYPT_CHARS " "; if (!mkshort_handle) { mkshort_handle = new MakeShort; @@ -385,14 +310,14 @@ rw_init(const QString& fname) assert(invalid_char_re.isValid()); } -static void -rd_init(const QString& fname) +void +GarminFormat::rd_init(const QString& fname) { rw_init(fname); } -static void -rw_deinit() +void +GarminFormat::rw_deinit() { if (gps_baud_rate != DEFAULT_BAUD) { if (0 == GPS_Set_Baud_Rate(portname, DEFAULT_BAUD)) { @@ -407,8 +332,8 @@ rw_deinit() portname = nullptr; } -static int -waypt_read_cb(int total_ct, GPS_PWay* /*unused*/) +int +GarminFormat::waypt_read_cb(int total_ct, GPS_PWay* /*unused*/) { if (global_opts.verbose_status) { static int i; @@ -418,8 +343,8 @@ waypt_read_cb(int total_ct, GPS_PWay* /*unused*/) return 0; } -static void -waypt_read() +void +GarminFormat::waypt_read() { int n; GPS_PWay* way = nullptr; @@ -485,14 +410,14 @@ waypt_read() } } -static int lap_read_nop_cb(int /*unused*/, GPS_SWay** /*unused*/) +int GarminFormat::lap_read_nop_cb(int /*unused*/, GPS_SWay** /*unused*/) { return 0; } // returns 1 if the waypoint's start_time can be found // in the laps array, 0 otherwise -static unsigned int checkWayPointIsAtSplit(Waypoint* wpt, GPS_PLap* laps, int nlaps) +unsigned int GarminFormat::checkWayPointIsAtSplit(Waypoint* wpt, GPS_PLap* laps, int nlaps) { int result = 0; @@ -518,9 +443,8 @@ static unsigned int checkWayPointIsAtSplit(Waypoint* wpt, GPS_PLap* laps, int nl return result; } -static void -track_read() +GarminFormat::track_read() { GPS_PTrack* array; route_head* trk_head = nullptr; @@ -602,9 +526,8 @@ track_read() xfree(array); } -static void -route_read() +GarminFormat::route_read() { GPS_PWay* array; /* TODO: Fixes warning but is it right? @@ -661,8 +584,8 @@ route_read() * code, we convert the PVT (position/velocity/time) data from the receiver * to the data type we use throughout. Yes, we do lose some data that way. */ -static void -pvt2wpt(GPS_PPvt_Data pvt, Waypoint* wpt) +void +GarminFormat::pvt2wpt(GPS_PPvt_Data pvt, Waypoint* wpt) { wpt->altitude = pvt->alt; wpt->latitude = pvt->lat; @@ -721,17 +644,15 @@ pvt2wpt(GPS_PPvt_Data pvt, Waypoint* wpt) } } -static gpsdevh* pvt_fd; - -static void -pvt_init(const QString& fname) +void +GarminFormat::rd_position_init(const QString& fname) { rw_init(fname); GPS_Command_Pvt_On(qPrintable(fname), &pvt_fd); } -static Waypoint* -pvt_read(posn_status* posn_status) +Waypoint* +GarminFormat::rd_position(posn_status* posn_status) { auto* wpt = new Waypoint; GPS_PPvt_Data pvt = GPS_Pvt_New(); @@ -763,8 +684,8 @@ pvt_read(posn_status* posn_status) return nullptr; } -static void -data_read() +void +GarminFormat::read() { if (poweroff) { return; @@ -785,8 +706,8 @@ data_read() } } -static GPS_PWay -sane_GPS_Way_New() +GPS_PWay +GarminFormat::sane_GPS_Way_New() { GPS_PWay way = GPS_Way_New(); if (!way) { @@ -811,8 +732,8 @@ sane_GPS_Way_New() return way; } -static int -waypt_write_cb(GPS_PWay* /*unused*/) +int +GarminFormat::waypt_write_cb(GPS_PWay* /*unused*/) { int n = waypt_count(); @@ -828,8 +749,8 @@ waypt_write_cb(GPS_PWay* /*unused*/) * If we're using smart names, try to put the cache info in the * description. */ -static const char* -get_gc_info(const Waypoint* wpt) +const char* +GarminFormat::get_gc_info(const Waypoint* wpt) { if (global_opts.smart_names) { if (wpt->gc_data->type == Geocache::type_t::gt_virtual) { @@ -857,8 +778,8 @@ get_gc_info(const Waypoint* wpt) return ""; } -static int -waypoint_prepare() +int +GarminFormat::waypoint_prepare() { int i; int n = waypt_count(); @@ -890,10 +811,10 @@ waypoint_prepare() * cleaning */ QByteArray ident = mkshort_handle->mkshort( - global_opts.synthesize_shortnames ? - str_from_unicode(src) : - str_from_unicode(wpt->shortname), - false); + global_opts.synthesize_shortnames ? + str_from_unicode(src) : + str_from_unicode(wpt->shortname), + false); /* Should not be a strcpy as 'ident' isn't really a C string, * but rather a garmin "fixed length" buffer that's padded * to the end with spaces. So this is NOT (strlen+1). @@ -969,8 +890,8 @@ waypoint_prepare() return n; } -static void -waypoint_write() +void +GarminFormat::waypoint_write() { int n = waypoint_prepare(); @@ -988,8 +909,8 @@ waypoint_write() xfree(tx_waylist); } -static void -route_hdr_pr(const route_head* rte) +void +GarminFormat::route_hdr_pr(const route_head* rte) { (*cur_tx_routelist_entry)->rte_num = rte->rte_num; (*cur_tx_routelist_entry)->isrte = 1; @@ -1000,8 +921,8 @@ route_hdr_pr(const route_head* rte) } } -static void -route_waypt_pr(const Waypoint* wpt) +void +GarminFormat::route_waypt_pr(const Waypoint* wpt) { GPS_PWay rte = *cur_tx_routelist_entry; @@ -1053,8 +974,8 @@ route_waypt_pr(const Waypoint* wpt) cur_tx_routelist_entry++; } -static void -route_write() +void +GarminFormat::route_write() { int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */ @@ -1065,12 +986,18 @@ route_write() tx_routelist[i] = sane_GPS_Way_New(); } - route_disp_all(route_hdr_pr, nullptr, route_waypt_pr); + auto route_hdr_pr_lambda = [this](const route_head* rte)->void { + route_hdr_pr(rte); + }; + auto route_waypt_pr_lambda = [this](const Waypoint* waypointp)->void { + route_waypt_pr(waypointp); + }; + route_disp_all(route_hdr_pr_lambda, nullptr, route_waypt_pr_lambda); GPS_Command_Send_Route(portname, tx_routelist, n); } -static void -track_hdr_pr(const route_head* trk_head) +void +GarminFormat::track_hdr_pr(const route_head* trk_head) { (*cur_tx_tracklist_entry)->ishdr = true; if (!trk_head->rte_name.isEmpty()) { @@ -1084,8 +1011,8 @@ track_hdr_pr(const route_head* trk_head) my_track_count++; } -static void -track_waypt_pr(const Waypoint* wpt) +void +GarminFormat::track_waypt_pr(const Waypoint* wpt) { (*cur_tx_tracklist_entry)->lat = wpt->latitude; (*cur_tx_tracklist_entry)->lon = wpt->longitude; @@ -1100,10 +1027,10 @@ track_waypt_pr(const Waypoint* wpt) cur_tx_tracklist_entry++; } -static int -track_prepare() +int +GarminFormat::track_prepare() { - int32_t n = track_waypt_count() + track_count(); + int32_t n = track_waypt_count() + track_count(); tx_tracklist = (GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack)); cur_tx_tracklist_entry = tx_tracklist; @@ -1111,15 +1038,21 @@ track_prepare() tx_tracklist[i] = GPS_Track_New(); } my_track_count = 0; - track_disp_all(track_hdr_pr, nullptr, track_waypt_pr); + auto track_hdr_pr_lambda = [this](const route_head* rte)->void { + track_hdr_pr(rte); + }; + auto track_waypt_pr_lambda = [this](const Waypoint* waypointp)->void { + track_waypt_pr(waypointp); + }; + track_disp_all(track_hdr_pr_lambda, nullptr, track_waypt_pr_lambda); GPS_Prepare_Track_For_Device(&tx_tracklist, &n); return n; } -static void -track_write() +void +GarminFormat::track_write() { int n = track_prepare(); GPS_Command_Send_Track(portname, tx_tracklist, n, (eraset)? 1 : 0); @@ -1130,8 +1063,8 @@ track_write() xfree(tx_tracklist); } -static void -course_write() +void +GarminFormat::course_write() { int i; @@ -1152,8 +1085,8 @@ course_write() xfree(tx_tracklist); } -static void -data_write() +void +GarminFormat::write() { if (poweroff) { return; @@ -1180,42 +1113,8 @@ data_write() } } - -ff_vecs_t garmin_vecs = { - ff_type_serial, - FF_CAP_RW_ALL, - rd_init, - rw_init, - rw_deinit, - rw_deinit, - data_read, - data_write, - nullptr, - &garmin_args, - { pvt_init, pvt_read, rw_deinit, nullptr, nullptr, nullptr } -}; - -static const char* d103_icons[16] = { - "dot", - "house", - "gas", - "car", - "fish", - "boat", - "anchor", - "wreck", - "exit", - "skull", - "flag", - "camp", - "circle_x", - "deer", - "1st_aid", - "back-track" -}; - -static const char* -d103_symbol_from_icon_number(unsigned int n) +const char* +GarminFormat::d103_symbol_from_icon_number(unsigned int n) { if (n <= 15) { return d103_icons[n]; @@ -1224,8 +1123,8 @@ d103_symbol_from_icon_number(unsigned int n) } } -static int -d103_icon_number_from_symbol(const QString& s) +int +GarminFormat::d103_icon_number_from_symbol(const QString& s) { if (s.isNull()) { return 0; @@ -1239,8 +1138,8 @@ d103_icon_number_from_symbol(const QString& s) return 0; } -static void -garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid) +void +GarminFormat::garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid) { auto* gmsd = new garmin_fs_t(protoid); wpt->fs.FsChainAdd(gmsd); @@ -1273,8 +1172,8 @@ garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid garmin_fs_t::set_addr(gmsd, str_to_unicode(QByteArray(way->addr, qstrnlen(way->addr, sizeof(way->addr))))); } -static void -garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, const int protoid) +void +GarminFormat::garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, const int protoid) { const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); diff --git a/garmin.h b/garmin.h new file mode 100644 index 000000000..0139a861d --- /dev/null +++ b/garmin.h @@ -0,0 +1,206 @@ +/* + Jeeps wrapper for Garmin serial protocol. + + Copyright (C) 2002, 2003, 2004, 2005, 2006 Robert Lipe, robertlipe+source@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ +#ifndef GARMIN_H_INCLUDED_ +#define GARMIN_H_INCLUDED_ + +#include // for size_t + +#include // for QByteArray +#include // for QRegularExpression +#include // for QString +#include // for QTextCodec +#include // for QVector + +#include "defs.h" +#include "format.h" // for Format +#include "jeeps/gpsdevice.h" // for gpsdevh +#include "jeeps/gpssend.h" // for GPS_PWay, GPS_SWay, GPS_PTrack, GPS_PPvt_Data, GPS_SLap +#include "mkshort.h" // for MakeShort + + +class GarminFormat : public Format +{ +public: + QVector* get_args() override + { + return &garmin_args; + } + + ff_type get_type() const override + { + return ff_type_serial; + } + + QVector get_cap() const override + { + return FF_CAP_RW_ALL; + } + + void rd_init(const QString& fname) override; + void read() override; + void rd_deinit() override + { + rw_deinit(); + } + void wr_init(const QString& fname) override + { + rw_init(fname); + } + void write() override; + void wr_deinit() override + { + rw_deinit(); + } + void rd_position_init(const QString& fname) override; + Waypoint* rd_position(posn_status* status) override; + void rd_position_deinit() override + { + rw_deinit(); + } + +private: + /* Member Functions */ + + QByteArray str_from_unicode(const QString& qstr); + QString str_to_unicode(const QByteArray& cstr); + static void write_char_string(char* dest, const char* source, size_t destsize); + void rw_init(const QString& fname); + void rw_deinit(); + static int waypt_read_cb(int total_ct, GPS_SWay** /* unused */); + void waypt_read(); + static int lap_read_nop_cb(int /* unused */, GPS_SWay** /* unused */); + static unsigned int checkWayPointIsAtSplit(Waypoint* wpt, GPS_SLap** laps, int nlaps); + void track_read(); + void route_read(); + static void pvt2wpt(GPS_PPvt_Data pvt, Waypoint* wpt); + static GPS_SWay* sane_GPS_Way_New(); + static int waypt_write_cb(GPS_SWay** /* unused */); + static const char* get_gc_info(const Waypoint* wpt); + int waypoint_prepare(); + void waypoint_write(); + void route_hdr_pr(const route_head* rte); + void route_waypt_pr(const Waypoint* wpt); + void route_write(); + void track_hdr_pr(const route_head* trk_head); + void track_waypt_pr(const Waypoint* wpt); + int track_prepare(); + void track_write(); + void course_write(); + static const char* d103_symbol_from_icon_number(unsigned int n); + static int d103_icon_number_from_symbol(const QString& s); + void garmin_fs_garmin_after_read(GPS_PWay way, Waypoint* wpt, int protoid); + void garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, int protoid); + + /* Data Members */ + + const char* portname{}; + MakeShort* mkshort_handle{}; + GPS_PWay* tx_waylist{}; + GPS_PWay* tx_routelist{}; + GPS_PWay* cur_tx_routelist_entry{}; + GPS_PTrack* tx_tracklist{}; + GPS_PTrack* cur_tx_tracklist_entry{}; + int my_track_count = 0; + char* getposn = nullptr; + char* poweroff = nullptr; + char* eraset = nullptr; + char* resettime = nullptr; + char* snlen = nullptr; + char* snwhiteopt = nullptr; + char* deficon = nullptr; + char* category = nullptr; + char* categorybitsopt = nullptr; + char* baudopt = nullptr; + char* opt_codec = nullptr; + int baud = 0; + int categorybits{}; + bool receiver_must_upper = true; + QTextCodec* codec{nullptr}; + + QRegularExpression invalid_char_re; + + QVector garmin_args = { + { + "snlen", &snlen, "Length of generated shortnames", nullptr, + ARGTYPE_INT, "1", nullptr, nullptr + }, + { + "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { "deficon", &deficon, "Default icon name", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, + { + "get_posn", &getposn, "Return current position as a waypoint", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "power_off", &poweroff, "Command unit to power itself down", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "erase_t", &eraset, "Erase existing courses when writing new ones", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "resettime", &resettime, "Sync GPS time to computer time", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "category", &category, "Category number to use for written waypoints", + nullptr, ARGTYPE_INT, "1", "16", nullptr + }, + { + "bitscategory", &categorybitsopt, "Bitmap of categories", + nullptr, ARGTYPE_INT, "1", "65535", nullptr + }, + { + "baud", &baudopt, "Speed in bits per second of serial port (baud=9600)", + nullptr, ARGTYPE_INT, ARG_NOMINMAX, nullptr + }, + { + "codec", &opt_codec, "override codec to use for device", + nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + + }; + + gpsdevh* pvt_fd{}; + + static constexpr const char* d103_icons[16] = { + "dot", + "house", + "gas", + "car", + "fish", + "boat", + "anchor", + "wreck", + "exit", + "skull", + "flag", + "camp", + "circle_x", + "deer", + "1st_aid", + "back-track" + }; +}; +#endif // GARMIN_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index c4c7a7a99..f35289088 100644 --- a/vecs.cc +++ b/vecs.cc @@ -43,6 +43,7 @@ #include "dg-100.h" // for Dg100FileFormat, Dg100SerialFormat, Dg200FileFormat, Dg200SerialFormat #include "exif.h" // for ExifFormat #include "format.h" // for Format +#include "garmin.h" // for GarminFormat #include "garmin_fit.h" // for GarminFitFormat #include "garmin_gpi.h" // for GarminGPIFormat #include "gbversion.h" // for WEB_DOC_DIR @@ -75,7 +76,6 @@ extern ff_vecs_t geo_vecs; -extern ff_vecs_t garmin_vecs; extern ff_vecs_t ozi_vecs; #if MAXIMAL_ENABLED extern ff_vecs_t tpg_vecs; @@ -115,7 +115,7 @@ struct Vecs::Impl { * of this class is constructed. */ GpxFormat gpx_fmt; - LegacyFormat garmin_fmt {garmin_vecs}; + GarminFormat garmin_fmt; GdbFormat gdb_fmt; NmeaFormat nmea_fmt; LegacyFormat ozi_fmt {ozi_vecs}; From 1d74ab7a69e21d39db4730c2b248ade1ead3f1d3 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:30:05 -0700 Subject: [PATCH 042/132] fix leak in jeeps serial comm on posix. (#1223) see #1221 --- jeeps/gpsserial.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/jeeps/gpsserial.cc b/jeeps/gpsserial.cc index 164054bc3..6e20b5574 100644 --- a/jeeps/gpsserial.cc +++ b/jeeps/gpsserial.cc @@ -604,6 +604,7 @@ int32_t GPS_Serial_Off(gpsdevh* dh) gps_errno = HARDWARE_ERROR; return 0; } + xfree(dh); return 1; } From 840e884874a68af21d9042061ccaa548d435bf04 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 06:59:38 -0700 Subject: [PATCH 043/132] convert tpo formats to Format class (#1225) * convert tpo to Format class. * capture comments --- CMakeLists.txt | 1 + tpo.cc | 123 +++++++--------------------- tpo.h | 213 +++++++++++++++++++++++++++++++++++++++++++++++++ vecs.cc | 7 +- 4 files changed, 247 insertions(+), 97 deletions(-) create mode 100644 tpo.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 995f6b724..9e4a6ee5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,7 @@ set(HEADERS skytraq.h subrip.h text.h + tpo.h unicsv.h units.h vcf.h diff --git a/tpo.cc b/tpo.cc index dd5a7ab7b..d15b1a512 100644 --- a/tpo.cc +++ b/tpo.cc @@ -69,9 +69,11 @@ 3.x "recreation" */ -#include // for abs +#include "tpo.h" + #include // for uint8_t #include // for printf, SEEK_CUR, SEEK_SET +#include // for abs #include // for strlen, strncmp #include // for vector @@ -79,41 +81,24 @@ #include // for QScopedArrayPointer #include // for QString #include // for qMakeStringPrivate, QStringLiteral -#include // for QVector #include // for qPrintable, Q_UNUSED -#include "defs.h" -#include "gbfile.h" // for gbfread, gbfgetc, gbfgetint32, gbfreadbuf, gbfseek, gbfgetdbl, gbfgetint16, gbfclose, gbfgetnativecstr, gbfgetuint16, gbfopen_le, gbfile +#include "defs.h" // for Waypoint, fatal, route_head, le_read32, waypt_add, track_add_wpt, track_add_head, xfree, xmalloc, doing_rtes, doing_wpts, gb_color, route_add_head, route_add_wpt, unknown_alt, doing_trks +#include "gbfile.h" // for gbfread, gbfgetc, gbfgetint32, gbfreadbuf, gbfseek, gbfgetdbl, gbfgetint16, gbfclose, gbfgetnativecstr, gbfgetuint16, gbfopen_le #include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_WGS84_M #define MYNAME "TPO" -static char* dumpheader = nullptr; - -static -QVector tpo2_args = { -}; - -static -QVector tpo3_args = { -}; - - -static gbfile* tpo_file_in; -static double track_length; /*******************************************************************************/ /* READ */ /*******************************************************************************/ -/* Define a global here that we can query from multiple places */ -static float tpo_version = 0.0; - /* tpo_check_version_string() Check the first bytes of the file for a version 3.0 header. */ -static void -tpo_check_version_string() +void +TpoFormatBase::tpo_check_version_string() { unsigned char string_size; @@ -142,11 +127,11 @@ tpo_check_version_string() } } -static void /* tpo_dump_header_bytes(int header_size) Write the first header_size bytes of the file to standard output as a C array definition. */ -tpo_dump_header_bytes(int header_size) +void +TpoFormatBase::tpo_dump_header_bytes(int header_size) { QByteArray buffer = gbfreadbuf(header_size, tpo_file_in); @@ -172,8 +157,8 @@ tpo_dump_header_bytes(int header_size) Keep reading bytes from the file until the section name is encountered, then go seek_bytes forwards (+) or backwards (-) to the start of the section data. */ -static void -tpo_read_until_section(const char* section_name, int seek_bytes) +void +TpoFormatBase::tpo_read_until_section(const char* section_name, int seek_bytes) { char byte; unsigned int match_index = 0; @@ -220,7 +205,7 @@ tpo_read_until_section(const char* section_name, int seek_bytes) // that is the only type of data available in the version 2.x TPO // files. // -static void tpo_read_2_x() +void TpoFormatBase::tpo_read_2_x() { char buff[16]; @@ -335,7 +320,7 @@ static void tpo_read_2_x() // // For version 3.x files. // -static int tpo_read_int() +int TpoFormatBase::tpo_read_int() { constexpr int debug = 0; @@ -381,7 +366,7 @@ static int tpo_read_int() // // For version 3.x/4.x files. // -static int tpo_find_block(unsigned int block_desired) +int TpoFormatBase::tpo_find_block(unsigned int block_desired) { unsigned int block_type; constexpr int debug = 0; @@ -419,7 +404,7 @@ static int tpo_find_block(unsigned int block_desired) // // For version 3.x files. // -static Waypoint* tpo_convert_ll(int lat, int lon) +Waypoint* TpoFormatBase::tpo_convert_ll(int lat, int lon) { auto* waypoint_temp = new Waypoint; @@ -453,19 +438,9 @@ static Waypoint* tpo_convert_ll(int lat, int lon) return (waypoint_temp); } -#define TRACKNAMELENGTH 255 -class StyleInfo -{ -public: - QString name; - uint8_t color[3] {0, 0, 0}; // keep R/G/B values separate because line_color needs BGR - uint8_t wide{0}; - uint8_t dash{0}; -}; - // Track decoder for version 3.x/4.x files. // This block contains tracks (called "freehand routes" in Topo). -static void tpo_process_tracks() +void TpoFormatBase::tpo_process_tracks() { constexpr int debug = 0; // 0-4 for increasingly verbose output in this subroutine) @@ -611,7 +586,7 @@ static void tpo_process_tracks() track_style -= 1; // STARTS AT 1, whereas style arrays start at 0 // Can be 8/16/32-bit value - never used? length in meters? - track_length = tpo_read_int(); + double track_length = tpo_read_int(); //UNKNOWN DATA LENGTH unsigned int name_length = tpo_read_int(); @@ -1039,17 +1014,9 @@ static void tpo_process_tracks() } // end of tpo_process_tracks -// Global index to waypoints, needed for routes, filled in by -// tpo_process_waypoints. -// -// For version 3.x files. -// -static Waypoint** tpo_wp_index; -static unsigned int tpo_index_ptr; - // Waypoint decoder for version 3.x files. // -static void tpo_process_waypoints() +void TpoFormatBase::tpo_process_waypoints() { //printf("Processing Waypoints...\n"); @@ -1157,7 +1124,7 @@ static void tpo_process_waypoints() // Map Notes decoder for version 3.x files. // -static void tpo_process_map_notes() +void TpoFormatBase::tpo_process_map_notes() { //printf("Processing Map Notes...\n"); @@ -1255,7 +1222,7 @@ static void tpo_process_map_notes() // Symbols decoder for version 3.x files. // -static void tpo_process_symbols() +void TpoFormatBase::tpo_process_symbols() { //printf("Processing Symbols...\n"); @@ -1298,7 +1265,7 @@ static void tpo_process_symbols() // Text Labels decoder for version 3.x files. // -static void tpo_process_text_labels() +void TpoFormatBase::tpo_process_text_labels() { //printf("Processing Text Labels...\n"); @@ -1362,7 +1329,7 @@ static void tpo_process_text_labels() // with pointers to waypoint objects by tpo_process_waypoints() // function above. // -static void tpo_process_routes() +void TpoFormatBase::tpo_process_routes() { //printf("Processing Routes...\n"); @@ -1446,7 +1413,7 @@ static void tpo_process_routes() #ifdef DEAD_CODE_IS_REBORN // Compass decoder for version 3.x files. // -static void tpo_process_compass() +void TpoFormatBase::tpo_process_compass() { // Not implemented yet @@ -1461,7 +1428,7 @@ static void tpo_process_compass() // (called "freehand routes" or just "routes" in Topo), "waypoints", // and "gps-routes". We intend to read all three types. // -static void tpo_read_3_x() +void TpoFormatBase::tpo_read_3_x() { if (doing_trks) { @@ -1517,8 +1484,8 @@ static void tpo_read_3_x() -static void -tpo_rd_init(const QString& fname) +void +TpoFormatBase::tpo_rd_init(const QString& fname) { // prepare for an attempt to deallocate memory that may or may not get allocated @@ -1547,8 +1514,8 @@ tpo_rd_init(const QString& fname) } } -static void -tpo_rd_deinit() +void +TpoFormatBase::tpo_rd_deinit() { // Free the waypoint index, we don't need it anymore. for (unsigned int i = 0; i < tpo_index_ptr; i++) { @@ -1565,8 +1532,8 @@ tpo_rd_deinit() gbfclose(tpo_file_in); } -static void -tpo_read() +void +TpoFormatBase::tpo_read() { if (tpo_version == 2.0) { @@ -1579,33 +1546,3 @@ tpo_read() fatal(MYNAME ": gpsbabel can only read TPO versions through 3.x.x\n"); } } - -/* TPO 2.x format can read tracks only */ -ff_vecs_t tpo2_vecs = { - ff_type_file, /* ff_type_internal */ - { ff_cap_none, ff_cap_read, ff_cap_none }, - tpo_rd_init, - nullptr, - tpo_rd_deinit, - nullptr, - tpo_read, - nullptr, - nullptr, - &tpo2_args, - NULL_POS_OPS -}; - -/* TPO 3.x format can read waypoints/tracks/routes */ -ff_vecs_t tpo3_vecs = { - ff_type_file, /* ff_type_internal */ - { ff_cap_read, ff_cap_read, ff_cap_read }, - tpo_rd_init, - nullptr, - tpo_rd_deinit, - nullptr, - tpo_read, - nullptr, - nullptr, - &tpo3_args, - NULL_POS_OPS -}; diff --git a/tpo.h b/tpo.h new file mode 100644 index 000000000..43a0c7e40 --- /dev/null +++ b/tpo.h @@ -0,0 +1,213 @@ +/* + National Geographic Topo! TPO file support. + 2.x support contributed to gpsbabel by Steve Chamberlin. + 3.x support contributed to gpsbabel by Curt Mills. + 4.x files read properly when treated as 3.x (final release was 4.5) + track parsing bugs fixed by Steve Eckert in 2012 and 2020 + + Topo! version 2.x: Tracks are implemented. + Topo! version 3.x/4.x: Reading of Tracks/Waypoints/Routes is + implemented. Also extracts Map Notes/ + Symbols/Text Labels as Waypoints. + + Copyright (C) 2005 Steve Chamberlin, slc at alum.mit.edu + Portions Copyright (C) 2006 Curtis E. Mills, archer at eskimo dot com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ + +/* + TPO format notes: + ----------------- + Most of the ASCII strings embedded in the text will have a + byte-count prepended to the string. Unknown yet whether other + fields have this same byte-count, but so far it doesn't look like + it. + + New format (3.x and later) files begin with a string byte-count + byte and then a string starting with "TOPO! Ver. 3.", like "TOPO! + Ver. 3.3.4". Can contain routes/tracks/waypoints, embedded + images, Map Notes, Symbols, Text Labels, Compass symbols, and + several others. + + Older (pre-3.0) format does not have the above string. Contains + only tracks. Waypoints are saved in a separate .TPG file. + + Track parsing has been problematic and may still not be right! + See further notes and clues in tpo_process_tracks() + (can #define Tracks2012 to revert to pre-2020 code in tpo_process_tracks) + + May contain these strings: + Frmt: String: + ----- -------------------------------- + 2.x "CTopoAzimuth" + 2.x "CTopoBookmark" + 2.x "CTopoGpsRoute". Saved in .tpg files (see tpg.c) + 2.x "CTopoRoute". The actual tracks we parse here. + 2.x "CTopoSymbol" + 2.x/3.x "CTopoText" + 2.x "CTopoWaypoint". Saved in .tpg files (see tpg.c) + 3.x "Notes" + 3.x "PNG." Embedded PNG image containing 2 rows of 40 + symbols each. Starts with signature: 89 50 4e 47 0d + 0a 1a 0a, ends with signature 49 45 4e 44 ae 42 60 82. + 3.x "shapes" + 3.x "arrows" + 3.x "recreation" +*/ +#ifndef TPO_H_INCLUDED_ +#define TPO_H_INCLUDED_ + +#include // for QString +#include // for QVector +#include // for uint8_t +#include "defs.h" // for ff_cap, arglist_t, ff_cap_none, ff_cap_read, Waypoint, ff_type, ff_type_file +#include "format.h" // for Format +#include "gbfile.h" // for gbfile + + +class TpoFormatBase +{ +protected: + /* Constants */ + + static constexpr int TRACKNAMELENGTH = 255; + + /* Types */ + + class StyleInfo + { + public: + QString name; + uint8_t color[3] {0, 0, 0}; // keep R/G/B values separate because line_color needs BGR + uint8_t wide{0}; + uint8_t dash{0}; + }; + + /* Member Functions */ + + void tpo_check_version_string(); + void tpo_dump_header_bytes(int header_size); + void tpo_read_until_section(const char* section_name, int seek_bytes); + void tpo_read_2_x(); + int tpo_read_int(); + int tpo_find_block(unsigned int block_desired); + static Waypoint* tpo_convert_ll(int lat, int lon); + void tpo_process_tracks(); + void tpo_process_waypoints(); + void tpo_process_map_notes(); + void tpo_process_symbols(); + void tpo_process_text_labels(); + void tpo_process_routes(); + void tpo_read_3_x(); + void tpo_rd_init(const QString& fname); + void tpo_rd_deinit(); + void tpo_read(); + + /* Data Members */ + + char* dumpheader = nullptr; + gbfile* tpo_file_in{}; + + // Define a global here that we can query from multiple places. + float tpo_version = 0.0; + + // Global index to waypoints, needed for routes, filled in by + // tpo_process_waypoints. + // + // For version 3.x files. + Waypoint** tpo_wp_index{}; + unsigned int tpo_index_ptr{}; +}; + +class Tpo2Format : public Format, private TpoFormatBase +{ +public: + QVector* get_args() override + { + return &tpo2_args; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + /* TPO 2.x format can read tracks only */ + /* waypoints, tracks, routes */ + return { ff_cap_none, ff_cap_read, ff_cap_none }; + } + + void rd_init(const QString& fname) override + { + tpo_rd_init(fname); + } + void read() override + { + tpo_read(); + } + void rd_deinit() override + { + tpo_rd_deinit(); + } + +private: + /* Data Members */ + + QVector tpo2_args = {}; +}; + +class Tpo3Format : public Format, private TpoFormatBase +{ +public: + QVector* get_args() override + { + return &tpo3_args; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + /* TPO 3.x format can read waypoints/tracks/routes */ + /* waypoints, tracks, routes */ + return { ff_cap_read, ff_cap_read, ff_cap_read }; + } + + void rd_init(const QString& fname) override + { + tpo_rd_init(fname); + } + void read() override + { + tpo_read(); + } + void rd_deinit() override + { + tpo_rd_deinit(); + } + +private: + /* Data Members */ + + QVector tpo3_args = {}; +}; +#endif // TPO_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index f35289088..41b5c6943 100644 --- a/vecs.cc +++ b/vecs.cc @@ -69,6 +69,7 @@ #include "src/core/logging.h" // for Warning, FatalMsg #include "subrip.h" // for SubripFormat #include "text.h" // for TextFormat +#include "tpo.h" // for Tpo2Format, Tpo3Format #include "unicsv.h" // for UnicsvFormat #include "vcf.h" // for VcfFormat #include "xcsv.h" // for XcsvStyle, XcsvFormat @@ -79,8 +80,6 @@ extern ff_vecs_t geo_vecs; extern ff_vecs_t ozi_vecs; #if MAXIMAL_ENABLED extern ff_vecs_t tpg_vecs; -extern ff_vecs_t tpo2_vecs; -extern ff_vecs_t tpo3_vecs; extern ff_vecs_t gpl_vecs; extern ff_vecs_t mtk_vecs; extern ff_vecs_t mtk_fvecs; @@ -123,8 +122,8 @@ struct Vecs::Impl { #if MAXIMAL_ENABLED LowranceusrFormat lowranceusr_fmt; LegacyFormat tpg_fmt {tpg_vecs}; - LegacyFormat tpo2_fmt {tpo2_vecs}; - LegacyFormat tpo3_fmt {tpo3_vecs}; + Tpo2Format tpo2_fmt; + Tpo3Format tpo3_fmt; #if SHAPELIB_ENABLED ShapeFormat shape_fmt; #endif From dd611769a58452ec1042ca97e175cf205855f341 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:08:26 -0700 Subject: [PATCH 044/132] convert v900 to dynamic Format class. (#1227) --- CMakeLists.txt | 1 + v900.cc | 112 ++++++++-------------------------------- v900.h | 135 +++++++++++++++++++++++++++++++++++++++++++++++++ vecs.cc | 6 +-- 4 files changed, 161 insertions(+), 93 deletions(-) create mode 100644 v900.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e4a6ee5e..17c70b6ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,6 +240,7 @@ set(HEADERS tpo.h unicsv.h units.h + v900.h vcf.h vecs.h xcsv.h diff --git a/v900.cc b/v900.cc index 632195221..4b8fb942e 100644 --- a/v900.cc +++ b/v900.cc @@ -71,77 +71,25 @@ for a little more info, see structures: one_line_advanced_mode, one_line_basic_mode, one_line_common_start. ******************************************************************************/ -#include "defs.h" -#include -#include -#include // strtod +#include "v900.h" -/* the start of each record (line) is common to both advanced and basic mode. - it will be parsed by a single common code. hence, it will be easier and clearer - to have a common structure for it. - */ -struct one_line_common_start { - char index[6]; /* record number */ - char comma1; /* ',' */ - char tag; /* tag type. T=trackpoint. TODO: more options??? */ - char comma2; /* ',' */ - char date[6]; /* YYMMDD. YY=09 is 2009. */ - char comma3; /* ',' */ - char time[6]; /* HHMMSS */ - char comma4; /* ',' */ - char latitude_num[9]; /* example: "31.768380" */ - char latitude_NS; /* 'N' or 'S' */ - char comma5; /* ',' */ - char longitude_num[10]; /* example: "035.209656" */ - char longitude_EW; /* 'E' or 'W' */ - char comma6; /* ',' */ - char height[5]; /* Altitude in meters. - * (not corrected to WGS84 ??) */ - char comma7; /* ',' */ - char speed[4]; /* speed in km/h. no decimal point. */ - char comma8; /* ',' */ - char heading[3]; /* heading in degrees */ - char comma9; /* ',' */ -}; - -/* this structure holds one record (line) in advanced logging mode. - advanced mode lines looks like this ('*' means NULL): -1717**,T,090204,062634,31.765528N,035.207730E,772**,0***,0**,2D,SPS ,2.1**,1.9**,1.0**,********* -*/ -struct one_line_advanced_mode { - one_line_common_start common; - char fixmode[2]; /* "2D" or "3D" */ - char comma10; /* ',' */ - char valid[4]; /* "SPS " or "DGPS" */ - char comma11; /* ',' */ - char pdop[5]; - char comma12; /* ',' */ - char hdop[5]; - char comma13; /* ',' */ - char vdop[5]; - char comma14; /* ',' */ - char vox[9]; /* voicetag recorded */ - char cr; /* '\r' */ - char lf; /* '\n' */ -}; - -/* this structure holds one record (line) in basic logging mode. - basic mode lines looks like this ('*' means NULL): -1*****,T,090404,063401,31.765931N,035.206969E,821**,0***,0**,********* -*/ -struct one_line_basic_mode { - one_line_common_start common; - char vox[9]; /* voicetag recorded */ - char cr; /* '\r' */ - char lf; /* '\n' */ -}; +#include // for assert +#include // for va_end, va_start +#include // for fclose, fgets, fread, vfprintf, stderr, va_list +#include // for strtod +#include // for strncmp, strcat, strcpy, strstr +#include // for QByteArray +#include // for QDate +#include // for QTime +#include // for qPrintable, UTC + +#include "defs.h" -static FILE* fin = nullptr; /* copied from dg-100.cpp */ -[[gnu::format(printf, 1, 2)]] static void -v900_log(const char* fmt, ...) +void +V900Format::v900_log(const char* fmt, ...) { va_list ap; @@ -154,8 +102,8 @@ v900_log(const char* fmt, ...) va_end(ap); } -static void -v900_rd_init(const QString& fname) +void +V900Format::rd_init(const QString& fname) { v900_log("%s(%s)\n",__func__,qPrintable(fname)); /* note: file is opened in binary mode, since lines end with \r\n, and in windows text mode @@ -168,8 +116,8 @@ v900_rd_init(const QString& fname) } } -static void -v900_rd_deinit() +void +V900Format::rd_deinit() { v900_log("%s\n",__func__); if (fin) { @@ -178,8 +126,8 @@ v900_rd_deinit() } /* copied from dg-100.c - slight (incompatible) modification to how the date parameter is used */ -static QDateTime -bintime2utc(int date, int time) { +QDateTime +V900Format::bintime2utc(int date, int time) { int secs = time % 100; time /= 100; int mins = time % 100; @@ -198,8 +146,8 @@ bintime2utc(int date, int time) { return QDateTime(dt, tm, Qt::UTC); } -static void -v900_read() +void +V900Format::read() { /* use line buffer large enough to hold either basic or advanced mode lines. */ union { @@ -361,19 +309,3 @@ v900_read() } } } - -/* Could be US-ASCII, since we only read "0-9,A-Z\n\r" */ - -ff_vecs_t v900_vecs = { - ff_type_file, - {ff_cap_read, ff_cap_read, ff_cap_none}, /* Read only format. May only read trackpoints and waypoints. */ - v900_rd_init, - nullptr, /* wr_init */ - v900_rd_deinit, - nullptr, /* wr_deinit */ - v900_read, - nullptr, /* write */ - nullptr, - nullptr, /* args */ - {nullptr,nullptr,nullptr,nullptr,nullptr,nullptr} -}; diff --git a/v900.h b/v900.h new file mode 100644 index 000000000..5a2b578f7 --- /dev/null +++ b/v900.h @@ -0,0 +1,135 @@ +/* + Support for Columbus/Visiontac V900 csv format + This format pads fields with NULL up to a fixed per field length. + Because of that, and because xcsv does not allows a regex as a field delimiter, + a special c module is required. + + Copyright (C) 2009 Tal Benavidor + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ +#ifndef V900_H_INCLUDED_ +#define V900_H_INCLUDED_ + +#include // for FILE + +#include // for QDateTime +#include // for QString +#include // for QVector + +#include "defs.h" // for ff_cap, ff_cap_read, ff_cap_none, arglist_t, ff_type, ff_type_file +#include "format.h" // for Format + + +class V900Format : public Format +{ +public: + using Format::Format; + + QVector* get_args() override + { + return nullptr; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + /* Read only format. May only read trackpoints and waypoints. */ + return {ff_cap_read, ff_cap_read, ff_cap_none}; + } + + void rd_init(const QString& fname) override; + void read() override; + void rd_deinit() override; + +private: + /* Types */ + + /* the start of each record (line) is common to both advanced and basic mode. + it will be parsed by a single common code. hence, it will be easier and clearer + to have a common structure for it. + */ + struct one_line_common_start { + char index[6]; /* record number */ + char comma1; /* ',' */ + char tag; /* tag type. T=trackpoint. TODO: more options??? */ + char comma2; /* ',' */ + char date[6]; /* YYMMDD. YY=09 is 2009. */ + char comma3; /* ',' */ + char time[6]; /* HHMMSS */ + char comma4; /* ',' */ + char latitude_num[9]; /* example: "31.768380" */ + char latitude_NS; /* 'N' or 'S' */ + char comma5; /* ',' */ + char longitude_num[10]; /* example: "035.209656" */ + char longitude_EW; /* 'E' or 'W' */ + char comma6; /* ',' */ + char height[5]; /* Altitude in meters. + * (not corrected to WGS84 ??) */ + char comma7; /* ',' */ + char speed[4]; /* speed in km/h. no decimal point. */ + char comma8; /* ',' */ + char heading[3]; /* heading in degrees */ + char comma9; /* ',' */ + }; + + /* this structure holds one record (line) in advanced logging mode. + advanced mode lines looks like this ('*' means NULL): + 1717**,T,090204,062634,31.765528N,035.207730E,772**,0***,0**,2D,SPS ,2.1**,1.9**,1.0**,********* + */ + struct one_line_advanced_mode { + one_line_common_start common; + char fixmode[2]; /* "2D" or "3D" */ + char comma10; /* ',' */ + char valid[4]; /* "SPS " or "DGPS" */ + char comma11; /* ',' */ + char pdop[5]; + char comma12; /* ',' */ + char hdop[5]; + char comma13; /* ',' */ + char vdop[5]; + char comma14; /* ',' */ + char vox[9]; /* voicetag recorded */ + char cr; /* '\r' */ + char lf; /* '\n' */ + }; + + /* this structure holds one record (line) in basic logging mode. + basic mode lines looks like this ('*' means NULL): + 1*****,T,090404,063401,31.765931N,035.206969E,821**,0***,0**,********* + */ + struct one_line_basic_mode { + one_line_common_start common; + char vox[9]; /* voicetag recorded */ + char cr; /* '\r' */ + char lf; /* '\n' */ + }; + + /* Member Functions */ + + [[gnu::format(printf, 1, 2)]] static void v900_log(const char* fmt, ...); + static QDateTime bintime2utc(int date, int time); + + /* Data Members */ + + FILE* fin = nullptr; +}; + +#endif // V900_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index 41b5c6943..05c4c7e19 100644 --- a/vecs.cc +++ b/vecs.cc @@ -71,6 +71,7 @@ #include "text.h" // for TextFormat #include "tpo.h" // for Tpo2Format, Tpo3Format #include "unicsv.h" // for UnicsvFormat +#include "v900.h" // for V900Format #include "vcf.h" // for VcfFormat #include "xcsv.h" // for XcsvStyle, XcsvFormat #include "googletakeout.h" // for GoogleTakeoutFormat @@ -92,7 +93,6 @@ extern ff_vecs_t gtm_vecs; extern ff_vecs_t garmin_txt_vecs; #endif // CSVFMTS_ENABLED extern ff_vecs_t ggv_log_vecs; -extern ff_vecs_t v900_vecs; extern ff_vecs_t format_garmin_xt_vecs; #endif // MAXIMAL_ENABLED @@ -152,7 +152,6 @@ struct Vecs::Impl { ExifFormat exif_fmt; HumminbirdFormat humminbird_fmt; HumminbirdHTFormat humminbird_ht_fmt; - LegacyFormat v900_fmt {v900_vecs}; SkytraqFormat skytraq_fmt; SkytraqfileFormat skytraq_ffmt; MinihomerFormat miniHomer_fmt; @@ -423,11 +422,12 @@ struct Vecs::Impl { nullptr, }, { - &v900_fmt, + nullptr, "v900", "Columbus/Visiontac V900 files (.csv)", nullptr, nullptr, + &fmtfactory }, { &skytraq_fmt, From 0656a45d9f502f3db86cea20e50a38d8f91b2aa8 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:47:09 -0700 Subject: [PATCH 045/132] convert gtm to Format class. (#1228) --- CMakeLists.txt | 1 + gtm.cc | 332 ++++++++++--------------------------------------- gtm.h | 287 ++++++++++++++++++++++++++++++++++++++++++ vecs.cc | 4 +- 4 files changed, 358 insertions(+), 266 deletions(-) create mode 100644 gtm.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 17c70b6ed..17b57b335 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,7 @@ set(HEADERS googletakeout.h gpx.h grtcirc.h + gtm.h gtrnctr.h heightgrid.h humminbird.h diff --git a/gtm.cc b/gtm.cc index d4bdca5ef..cb309c506 100644 --- a/gtm.cc +++ b/gtm.cc @@ -24,30 +24,20 @@ * https://www.trackmaker.com/download/GTM211_format.pdf */ +#include "gtm.h" + #include // for SEEK_CUR #include // for strlen, memset #include // for QList #include // for QString -#include // for QVector #include "defs.h" -#include "gbfile.h" // for gbfseek, gbfputc, gbfputint32, gbfputflt +#include "gbfile.h" // for gbfseek, gbfputc, gbfputint32, gbfputflt, gbfputint16, gbfputuint16, gbfgetint32, gbfgetdbl, gbfputdbl, gbfgetint16, gbfwrite, gbfgetflt, gbfile, gbfclose, gbfgetc, gbfopen_le, gbfreadbuf #include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_WGS84_M #include "src/core/datetime.h" // for DateTime -static gbfile* file_in, *file_out; -static int indatum; -static int wp_count; -static int ws_count; -static int tr_count; -static int ts_count; -static int rt_count; -static int im_count; -static const route_head* rte_active; -static int start_new; - #define MYNAME "GTM" #define EPOCH89DIFF 631065600 /* was 631076400 but that seems to include a three-hour bias */ @@ -70,8 +60,8 @@ static int start_new; #if 0 /* not used */ -static short int -fread_bool(gbfile* fd) +short int +GtmFormat::fread_bool(gbfile* fd) { char buf[2]; gbfread(buf, 2, 1, fd); @@ -84,29 +74,29 @@ fread_bool(gbfile* fd) #define fread_single(a) gbfgetflt(a) #define fread_double(a) gbfgetdbl(a) -static QString -fread_string(gbfile* fd) +QString +GtmFormat::fread_string(gbfile* fd) { int len = fread_integer(fd); return gbfreadbuf(len, fd); } -static void -fread_string_discard(gbfile* fd) +void +GtmFormat::fread_string_discard(gbfile* fd) { fread_string(fd); } -static QString -fread_fixedstring(gbfile* fd, int len) +QString +GtmFormat::fread_fixedstring(gbfile* fd, int len) { return gbfreadbuf(len, fd); } /* Write functions, according to specification. */ -static void -fwrite_null(gbfile* fd, int len) +void +GtmFormat::fwrite_null(gbfile* fd, int len) { char buf[1024]; @@ -121,8 +111,8 @@ fwrite_null(gbfile* fd, int len) #define fwrite_single(a,b) gbfputflt((b), a) #define fwrite_double(a,b) gbfputdbl((b), a) -static void -fwrite_string(gbfile* fd, const char* str) +void +GtmFormat::fwrite_string(gbfile* fd, const char* str) { if (str && str[0]) { int len = strlen(str); @@ -132,8 +122,9 @@ fwrite_string(gbfile* fd, const char* str) fwrite_integer(fd, 0); } } -static void -fwrite_string(gbfile* fd, const QString& str) + +void +GtmFormat::fwrite_string(gbfile* fd, const QString& str) { if (str.isEmpty()) { fwrite_integer(fd, 0); @@ -143,8 +134,8 @@ fwrite_string(gbfile* fd, const QString& str) } } -static void -fwrite_fixedstring(gbfile* fd, const char* str, int fieldlen) +void +GtmFormat::fwrite_fixedstring(gbfile* fd, const char* str, int fieldlen) { int len = str ? strlen(str) : 0; @@ -159,159 +150,15 @@ fwrite_fixedstring(gbfile* fd, const char* str, int fieldlen) } } -static void -fwrite_fixedstring(gbfile* fd, const QString& str, int fieldlen) +void +GtmFormat::fwrite_fixedstring(gbfile* fd, const QString& str, int fieldlen) { fwrite_fixedstring(fd, CSTR(str), fieldlen); } /* Auxiliary functions */ -#define MAX_INDATUM_INDEX 263 - -static const int indatum_array[MAX_INDATUM_INDEX] = { - -1, // < 1 - 0, 0, 0, 0, 0, 0, 0, // < 8 : Adindan - 1, // < 9 : Afgooye - 2, // < 10 : Ain el Abd - -1, -1, -1, -1, // < 14 - 6, 6, 6, 6, 6, 6, 6, 6, 6, // < 23 : ARC 1950 - 7, 7, 7, // < 26 : ARC 1960 - 8, // < 27 : Ascension Island 58 - -1, -1, -1, -1, -1, // < 32 - 13, // < 33 : Australian Geo 84 - -1, // < 34 - 15, // < 35 : Bellevue IGN - 16, // < 36 : Bermuda 1957 - -1, -1, // < 38 - 17, // < 39 : Bukit Rimpah - 18, // < 40 : Camp Area Astro - 19, // < 41 : Campo Inchauspe - 22, // < 42 : Canton Islan 1966 - 23, // < 43 : Cape - 24, // < 44 : Cape Canaveral - 26, // < 45 : Carthe - 28, // < 46 : Chatham - 29, // < 47 : Chua Astro - 30, // < 48 : Corrego Alegre - -1, -1, // < 50 - 33, // < 51 : Djakarta (Batavia) - 34, // < 52 : DOS 1968 - 35, // < 53 : Easter Island 1967 - -1, // < 54 - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, // < 69 : European 1950 Mean - 39, // < 70 : European 1979 Mean - -1, // < 71 - 41, // < 72 : Gandajika - 42, // < 73 : Geodetic Datum 49 - -1, // < 74 - 45, // < 75 : Guam 1963 - 46, // < 76 : Gunung Segara - -1, // < 77 - 49, // < 78 : Hearth North - -1, // < 79 - 50, // < 80 : Hjorsey 1955 - 51, // < 81 : Hong Kong 1963 - 52, // < 82 : Hu-Tzu-Shan - 53, 53, 53, 53, 53, 53, 53, // < 89 : Indian - -1, // < 90 - 55, // < 91 : Ireland 1965 - -1, // < 92 - 56, // < 93 : ISTS 073 69 - 57, // < 94 : Johnston Island 61 - 58, // < 95 : Kandawala - 59, // < 96 : Kerguelen Island - 60, // < 97 : Kertau 48 - -1, -1, // < 99 - 61, // < 100 : L.C. 5 Astro - -1, // < 101 - 63, // < 102 : Liberia 1964 - 64, 64, // < 104 : Luzon - -1, // < 105 - 65, // < 106 : Mahe 1971 - -1, // < 107 - 69, // < 108 : Merchich - 71, // < 109 : Midway Astro 61 - 73, 73, // < 111 : Minna - -1, // < 112 - 75, 75, 75, // < 115 : Nahrwan - 76, // < 116 : Naparima BWI - 3, 3, 3, // < 119 : Alaska NAD27 - 14, 14, // < 121 : Bahamas NAD27 - 20, 20, 20, 20, 20, // < 126 : Canada Mean NAD27 - 21, // < 127 : Canal Zone NAD27 - 31, // < 128 : Cuba NAD27 - 44, // < 129 : Greenland NAD27 - -1, -1, // < 131 - 20, // < 132 : Canada Mean NAD27 - -1, -1, -1, // < 135 - 70, // < 136 : Mexico NAD27 - -1, -1, -1, -1, -1, -1, -1, -1, // < 144 - 80, // < 145 : Old Egyptian - 81, // < 146 : Old Hawaiian - 82, // < 147 : Old Hawaiian Kauai - 83, // < 148 : Old Hawaiian Maui - 81, // < 149 : Old Hawaiian Mean - 84, // < 150 : Old Hawaiian Oahu - 85, // < 151 : Oman - 86, 86, 86, 86, 86, // < 156 : OSG Britain - 87, // < 157 : Pico de Las Nieves - 88, // < 158 : Pitcairn Astro 67 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // < 171 - 91, // < 172 : Puerto Rico - 92, // < 173 : Pulkovo 1942 - 94, // < 174 : Quatar National - -1, -1, // < 176 - 95, // < 177 : Rome 1940 - 96, 96, 96, 96, 96, 96, 96, // < 184 : S-42 (Pulkovo 1942) - -1, // < 185 - 100, // < 186 : Santo DOS - 99, // < 187 : Sao Braz - -1, -1, -1, -1, // < 191 - 105, 105, // < 193 : SAD-69/Mean - 98, // < 194 : SAD-69/Brazil - 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, // < 204 : SAD-69/Mean - 106, // < 205 : South Asia - 109, // < 206 : Tananarive 1926 - 111, // < 207 : Timbalai 1948 - 112, 112, 112, 112, // < 211 : Tokyo mean - 113, // < 212 : Tristan Astro 1968 - 115, // < 213 : Viti Levu 1916 - -1, -1, // < 215 - 116, // < 216 : Wake Eniwetok 1960 - 117, // < 217 : WGS 72 - 118, // < 218 : WGS 84 - 119, // < 219 : Yacare - 120, // < 220 : Zanderij - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // < 231 - 98, // < 232 : SAD-69/Brazil - -1, -1, // < 234 - 117, // < 235 : WGS 72 - 0, // < 236 : Adindan - 2, // < 237 : Ain el Abd - 7, // < 238 : ARC 1960 - 8, // < 239 : Ascension Island 58 - -1, -1, // < 241 - 52, // < 242 : Hu-Tzu-Shan - 53, 53, 53, // < 245 : Indian - -1, // < 246 - 57, // < 247 : Johnston Island 61 - 64, // < 248 : Luzon - -1, // < 249 - 75, // < 250 : Nahrwan - 76, // < 251 : Naparima BWI - -1, -1, -1, // < 254 - 82, // < 255 : Old Hawaiian Kauai - 83, // < 256 : Old Hawaiian Maui - 84, // < 257 : Old Hawaiian Oahu - -1, -1, // < 259 - 101, // < 260 : Sapper Hill 43 - 111, // < 261 : Timbalai 1948 - 112, // < 262 : Tokyo mean - 116 // < 263 : Wake Eniwetok 1960 -}; - -static void set_datum(int n) +void GtmFormat::set_datum(int n) { indatum = -1; if (n > 0 && n < MAX_INDATUM_INDEX) { @@ -323,52 +170,7 @@ static void set_datum(int n) } } -static const char* icon_descr[] = { - "", "Airport", "Ball Park", "Bank", "Bar", "Boat Ramp", "Campground", "Car", - "City (Large)", "City (Medium)", "City (Small)", "Dam", "Danger Area", - "Drinking Water", "Fishing Area", "Gas Station", "Glider Area", "Golf Course", - "Heliport", "Hotel", "Animals", "Information", "Man Overboard", "Marina", - "Mine", "Medical Facility", "Parachute Area", "Park", "Parking Area", - "Picnic Area", "Private Field", "Residence", "Restaurant", "Restroom", - "Scenic Area", "School", "Seaplane Base", "Shipwreck", "Shopping Center", - "Short Tower", "Policy Station", "Ski Resort", "Soft Field", "Swimming Area", - "Tall Tower", "Telephone", "Tracback Point", "Ultralight Area", "Waypoint", - "Boat", "Exit", "Flag", "Duck", "Buoy", "Back Track", "Beach", "Bridge", - "Building", "Car Repair", "Cemetery", "Church", "Civil", "Convenience Store", - "Crossing", "Fast Food", "Forest", "Ghost Town", "Levee", "Military", - "Oil Field", "Post Office", "Rv Park", "Scales", "Summit", "Toll Booth", - "Trail Head", "Truck Stop", "Tunnel", "Highway", "Gate", "Fall", "Fence", - "Mata-Burro", "Fitness Center", "Movie Theater", "Live Theater", "Zoo", "Horn", - "Bowling", "Car Rental", "City (Capitol)", "Controlled Area", "Stadium", - "Museum", "Amusement Park", "Skull", "Department Store", "Pharmacy", "Pizza", - "Diver Down Flag 1", "Light", "Pin", "", "Pigsty", "Tree", "Bamboo", - "Banana Plant", "Arrow-Down", "Bifurcation", "Cavern", "River", "Rock", - "Arrow-Up", "Trunk", "Soccer Field", "Sporting Court", "Flag, Green", "Trench", - "Ship-Yellow", "Green Sign", "Swamp", "Lake", "Stop!", - "Fishing Hot Spot Facility", "Speed Reducer", "Stairway", "Cactus", "Ship-Red", - "Letter - S", "Letter - D", "Letter - N", - "Crossing", "Cross", "Flag, Red", "Curve1", "Curve2", "Curve3", "Curve4", - "Letter - W", "Letter - L", "Letter - R", "Radio Beacon", "Road Sign", - "Geocache", "Geocache Found", "Traffic Light", "Bus Station", "Train Station", - "School", "Mile Marker", "Conservation Area", "Waypoint", "Box", "Aerial", - "Auto Repair", "Boat", "Exit Ramp", "Fixed Nav Aid", "Floating Buoy", "Garden", - "Fish Farm", "Lighthouse", "Truck Service", "Resort", "Scuba", "Shooting", - "Sight Seeing", "Sounding", "Winery", "Navaid, Amber", "Navaid, Black", - "Navaid, Blue", "Navaid, Green", "Navaid, Green/Red", "Navaid, Green/White", - "Navaid, Orange", "Navaid, Red", "Navaid, Red/Green", "Navaid, Red/White", - "Navaid, Violet", "Navaid, White", "Navaid, White/Green", "Navaid, White/Red", - "Buoy, White", "Dot, White", "Red Square", "Red Diamond", "Green Square", - "Green Diamond", "Restricted Area", "Navaid (unlit)", "Dot (Small)", "Libraries", "Waypoint", "Waypoint1", - "Waypoint2", "Mark (1)", "Mark (2)", "Mark (3)", "Cross (Red)", "Store", - "Exclamation", "Flag (EUA)", "Flag (CAN)", "Flag (BRA)", "Man", "Animals", - "Deer Tracks", "Tree Stand", "Bridge", "Fence", "Intersection", - "Non Direct Beacon", "VHF Omni Range", "Vor/Tacan", "Vor-Dme", - "1st Approach Fix", "Localizer Outer", "Missed Appr. Pt", "Tacan", - "CheckPoint", nullptr -}; - - -static void convert_datum(double* lat, double* lon) +void GtmFormat::convert_datum(double* lat, double* lon) const { double amt; if (indatum != -1 && indatum != 118) { @@ -379,8 +181,8 @@ static void convert_datum(double* lat, double* lon) /* Callbacks */ -static void -gtm_rd_init(const QString& fname) +void +GtmFormat::rd_init(const QString& fname) { file_in = gbfopen_le(fname, "rb", MYNAME); int version = fread_integer(file_in); @@ -417,21 +219,21 @@ gtm_rd_init(const QString& fname) fread_discard(file_in, 22); } -static void -gtm_rd_deinit() +void +GtmFormat::rd_deinit() { gbfclose(file_in); } -static void count_track_styles(const route_head* rte) +void GtmFormat::count_track_styles(const route_head* rte) { if (!rte->rte_waypt_empty()) { ts_count++; } } -static void -gtm_wr_init(const QString& fname) +void +GtmFormat::wr_init(const QString& fname) { // Count the number of track style entires. // We don't output a track style for any track that doesn't have any @@ -440,7 +242,10 @@ gtm_wr_init(const QString& fname) // in this format as every tracklog entry represents a waypoint, // and a new track is defined by a tracklog entry with the tracklog flag set. ts_count = 0; - track_disp_all(count_track_styles, nullptr, nullptr); + auto count_track_styles_lambda = [this](const route_head* rte)->void { + count_track_styles(rte); + }; + track_disp_all(count_track_styles_lambda, nullptr, nullptr); file_out = gbfopen_le(fname, "wb", MYNAME); /* little endian */ @@ -490,14 +295,14 @@ gtm_wr_init(const QString& fname) fwrite_null(file_out, 22); } -static void -gtm_wr_deinit() +void +GtmFormat::wr_deinit() { gbfclose(file_out); } -static void -gtm_read() +void +GtmFormat::read() { route_head* trk_head = nullptr; route_head* rte_head = nullptr; @@ -625,7 +430,7 @@ gtm_read() } } -static int icon_from_descr(const QString& descr) +int GtmFormat::icon_from_descr(const QString& descr) { for (int i = 0; icon_descr[i]; i++) { if (descr.compare(icon_descr[i]) == 0) { @@ -635,7 +440,7 @@ static int icon_from_descr(const QString& descr) return 48; } -static void write_waypt(const Waypoint* wpt) +void GtmFormat::write_waypt(const Waypoint* wpt) { fwrite_double(file_out, wpt->latitude); fwrite_double(file_out, wpt->longitude); @@ -657,13 +462,13 @@ static void write_waypt(const Waypoint* wpt) fwrite_integer(file_out, 0); } -static void start_rte(const route_head* rte) +void GtmFormat::start_rte(const route_head* rte) { rte_active = rte; start_new = 1; } -static void write_trk_waypt(const Waypoint* wpt) +void GtmFormat::write_trk_waypt(const Waypoint* wpt) { fwrite_double(file_out, wpt->latitude); fwrite_double(file_out, wpt->longitude); @@ -677,7 +482,7 @@ static void write_trk_waypt(const Waypoint* wpt) start_new = 0; } -static void write_trk_style(const route_head* trk) +void GtmFormat::write_trk_style(const route_head* trk) { if (!trk->rte_waypt_empty()) { fwrite_string(file_out, trk->rte_name); @@ -689,7 +494,7 @@ static void write_trk_style(const route_head* trk) } } -static void write_rte_waypt(const Waypoint* wpt) +void GtmFormat::write_rte_waypt(const Waypoint* wpt) { fwrite_double(file_out, wpt->latitude); fwrite_double(file_out, wpt->longitude); @@ -710,32 +515,31 @@ static void write_rte_waypt(const Waypoint* wpt) start_new = 0; } -static void -gtm_write() +void +GtmFormat::write() { - waypt_disp_all(write_waypt); + auto write_waypt_lambda = [this](const Waypoint* waypointp)->void { + write_waypt(waypointp); + }; + waypt_disp_all(write_waypt_lambda); + if (waypt_count()) { gbfwrite(WAYPOINTSTYLES, 1, sizeof(WAYPOINTSTYLES)-1, file_out); } - track_disp_all(start_rte, nullptr, write_trk_waypt); - track_disp_all(write_trk_style, nullptr, nullptr); - route_disp_all(start_rte, nullptr, write_rte_waypt); -} -static -QVector gtm_args = { -}; - -ff_vecs_t gtm_vecs = { - ff_type_file, - FF_CAP_RW_ALL, - gtm_rd_init, - gtm_wr_init, - gtm_rd_deinit, - gtm_wr_deinit, - gtm_read, - gtm_write, - nullptr, - >m_args, - NULL_POS_OPS -}; + auto start_rte_lambda = [this](const route_head* rte)->void { + start_rte(rte); + }; + auto write_trk_style_lambda = [this](const route_head* rte)->void { + write_trk_style(rte); + }; + auto write_trk_waypt_lambda = [this](const Waypoint* waypointp)->void { + write_trk_waypt(waypointp); + }; + auto write_rte_waypt_lambda = [this](const Waypoint* waypointp)->void { + write_rte_waypt(waypointp); + }; + track_disp_all(start_rte_lambda, nullptr, write_trk_waypt_lambda); + track_disp_all(write_trk_style_lambda, nullptr, nullptr); + route_disp_all(start_rte_lambda, nullptr, write_rte_waypt_lambda); +} diff --git a/gtm.h b/gtm.h new file mode 100644 index 000000000..0473e435a --- /dev/null +++ b/gtm.h @@ -0,0 +1,287 @@ +/* + Support for GPS TrackMaker data file. + + Copyright (C) 2005 Gustavo Niemeyer . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/* + * Documentation can be found at + * https://www.trackmaker.com/download/ref_guide_eng.pdf + * https://www.trackmaker.com/download/GTM211_format.pdf + */ +#ifndef GTM_H_INCLUDED_ +#define GTM_H_INCLUDED_ + +#include // for QString +#include // for QVector + +#include "defs.h" +#include "format.h" // for Format +#include "gbfile.h" // for gbfile + + +class GtmFormat : public Format +{ +public: + QVector* get_args() override + { + return nullptr; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + return FF_CAP_RW_ALL; + } + + void rd_init(const QString& fname) override; + void read() override; + void rd_deinit() override; + void wr_init(const QString& fname) override; + void write() override; + void wr_deinit() override; + +private: + /* Constants */ + + static constexpr int MAX_INDATUM_INDEX = 263; + + static constexpr int indatum_array[MAX_INDATUM_INDEX] = { + -1, // < 1 + 0, 0, 0, 0, 0, 0, 0, // < 8 : Adindan + 1, // < 9 : Afgooye + 2, // < 10 : Ain el Abd + -1, -1, -1, -1, // < 14 + 6, 6, 6, 6, 6, 6, 6, 6, 6, // < 23 : ARC 1950 + 7, 7, 7, // < 26 : ARC 1960 + 8, // < 27 : Ascension Island 58 + -1, -1, -1, -1, -1, // < 32 + 13, // < 33 : Australian Geo 84 + -1, // < 34 + 15, // < 35 : Bellevue IGN + 16, // < 36 : Bermuda 1957 + -1, -1, // < 38 + 17, // < 39 : Bukit Rimpah + 18, // < 40 : Camp Area Astro + 19, // < 41 : Campo Inchauspe + 22, // < 42 : Canton Islan 1966 + 23, // < 43 : Cape + 24, // < 44 : Cape Canaveral + 26, // < 45 : Carthe + 28, // < 46 : Chatham + 29, // < 47 : Chua Astro + 30, // < 48 : Corrego Alegre + -1, -1, // < 50 + 33, // < 51 : Djakarta (Batavia) + 34, // < 52 : DOS 1968 + 35, // < 53 : Easter Island 1967 + -1, // < 54 + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, // < 69 : European 1950 Mean + 39, // < 70 : European 1979 Mean + -1, // < 71 + 41, // < 72 : Gandajika + 42, // < 73 : Geodetic Datum 49 + -1, // < 74 + 45, // < 75 : Guam 1963 + 46, // < 76 : Gunung Segara + -1, // < 77 + 49, // < 78 : Hearth North + -1, // < 79 + 50, // < 80 : Hjorsey 1955 + 51, // < 81 : Hong Kong 1963 + 52, // < 82 : Hu-Tzu-Shan + 53, 53, 53, 53, 53, 53, 53, // < 89 : Indian + -1, // < 90 + 55, // < 91 : Ireland 1965 + -1, // < 92 + 56, // < 93 : ISTS 073 69 + 57, // < 94 : Johnston Island 61 + 58, // < 95 : Kandawala + 59, // < 96 : Kerguelen Island + 60, // < 97 : Kertau 48 + -1, -1, // < 99 + 61, // < 100 : L.C. 5 Astro + -1, // < 101 + 63, // < 102 : Liberia 1964 + 64, 64, // < 104 : Luzon + -1, // < 105 + 65, // < 106 : Mahe 1971 + -1, // < 107 + 69, // < 108 : Merchich + 71, // < 109 : Midway Astro 61 + 73, 73, // < 111 : Minna + -1, // < 112 + 75, 75, 75, // < 115 : Nahrwan + 76, // < 116 : Naparima BWI + 3, 3, 3, // < 119 : Alaska NAD27 + 14, 14, // < 121 : Bahamas NAD27 + 20, 20, 20, 20, 20, // < 126 : Canada Mean NAD27 + 21, // < 127 : Canal Zone NAD27 + 31, // < 128 : Cuba NAD27 + 44, // < 129 : Greenland NAD27 + -1, -1, // < 131 + 20, // < 132 : Canada Mean NAD27 + -1, -1, -1, // < 135 + 70, // < 136 : Mexico NAD27 + -1, -1, -1, -1, -1, -1, -1, -1, // < 144 + 80, // < 145 : Old Egyptian + 81, // < 146 : Old Hawaiian + 82, // < 147 : Old Hawaiian Kauai + 83, // < 148 : Old Hawaiian Maui + 81, // < 149 : Old Hawaiian Mean + 84, // < 150 : Old Hawaiian Oahu + 85, // < 151 : Oman + 86, 86, 86, 86, 86, // < 156 : OSG Britain + 87, // < 157 : Pico de Las Nieves + 88, // < 158 : Pitcairn Astro 67 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // < 171 + 91, // < 172 : Puerto Rico + 92, // < 173 : Pulkovo 1942 + 94, // < 174 : Quatar National + -1, -1, // < 176 + 95, // < 177 : Rome 1940 + 96, 96, 96, 96, 96, 96, 96, // < 184 : S-42 (Pulkovo 1942) + -1, // < 185 + 100, // < 186 : Santo DOS + 99, // < 187 : Sao Braz + -1, -1, -1, -1, // < 191 + 105, 105, // < 193 : SAD-69/Mean + 98, // < 194 : SAD-69/Brazil + 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, // < 204 : SAD-69/Mean + 106, // < 205 : South Asia + 109, // < 206 : Tananarive 1926 + 111, // < 207 : Timbalai 1948 + 112, 112, 112, 112, // < 211 : Tokyo mean + 113, // < 212 : Tristan Astro 1968 + 115, // < 213 : Viti Levu 1916 + -1, -1, // < 215 + 116, // < 216 : Wake Eniwetok 1960 + 117, // < 217 : WGS 72 + 118, // < 218 : WGS 84 + 119, // < 219 : Yacare + 120, // < 220 : Zanderij + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // < 231 + 98, // < 232 : SAD-69/Brazil + -1, -1, // < 234 + 117, // < 235 : WGS 72 + 0, // < 236 : Adindan + 2, // < 237 : Ain el Abd + 7, // < 238 : ARC 1960 + 8, // < 239 : Ascension Island 58 + -1, -1, // < 241 + 52, // < 242 : Hu-Tzu-Shan + 53, 53, 53, // < 245 : Indian + -1, // < 246 + 57, // < 247 : Johnston Island 61 + 64, // < 248 : Luzon + -1, // < 249 + 75, // < 250 : Nahrwan + 76, // < 251 : Naparima BWI + -1, -1, -1, // < 254 + 82, // < 255 : Old Hawaiian Kauai + 83, // < 256 : Old Hawaiian Maui + 84, // < 257 : Old Hawaiian Oahu + -1, -1, // < 259 + 101, // < 260 : Sapper Hill 43 + 111, // < 261 : Timbalai 1948 + 112, // < 262 : Tokyo mean + 116 // < 263 : Wake Eniwetok 1960 + }; + + static constexpr const char* icon_descr[] = { + "", "Airport", "Ball Park", "Bank", "Bar", "Boat Ramp", "Campground", "Car", + "City (Large)", "City (Medium)", "City (Small)", "Dam", "Danger Area", + "Drinking Water", "Fishing Area", "Gas Station", "Glider Area", "Golf Course", + "Heliport", "Hotel", "Animals", "Information", "Man Overboard", "Marina", + "Mine", "Medical Facility", "Parachute Area", "Park", "Parking Area", + "Picnic Area", "Private Field", "Residence", "Restaurant", "Restroom", + "Scenic Area", "School", "Seaplane Base", "Shipwreck", "Shopping Center", + "Short Tower", "Policy Station", "Ski Resort", "Soft Field", "Swimming Area", + "Tall Tower", "Telephone", "Tracback Point", "Ultralight Area", "Waypoint", + "Boat", "Exit", "Flag", "Duck", "Buoy", "Back Track", "Beach", "Bridge", + "Building", "Car Repair", "Cemetery", "Church", "Civil", "Convenience Store", + "Crossing", "Fast Food", "Forest", "Ghost Town", "Levee", "Military", + "Oil Field", "Post Office", "Rv Park", "Scales", "Summit", "Toll Booth", + "Trail Head", "Truck Stop", "Tunnel", "Highway", "Gate", "Fall", "Fence", + "Mata-Burro", "Fitness Center", "Movie Theater", "Live Theater", "Zoo", "Horn", + "Bowling", "Car Rental", "City (Capitol)", "Controlled Area", "Stadium", + "Museum", "Amusement Park", "Skull", "Department Store", "Pharmacy", "Pizza", + "Diver Down Flag 1", "Light", "Pin", "", "Pigsty", "Tree", "Bamboo", + "Banana Plant", "Arrow-Down", "Bifurcation", "Cavern", "River", "Rock", + "Arrow-Up", "Trunk", "Soccer Field", "Sporting Court", "Flag, Green", "Trench", + "Ship-Yellow", "Green Sign", "Swamp", "Lake", "Stop!", + "Fishing Hot Spot Facility", "Speed Reducer", "Stairway", "Cactus", "Ship-Red", + "Letter - S", "Letter - D", "Letter - N", + "Crossing", "Cross", "Flag, Red", "Curve1", "Curve2", "Curve3", "Curve4", + "Letter - W", "Letter - L", "Letter - R", "Radio Beacon", "Road Sign", + "Geocache", "Geocache Found", "Traffic Light", "Bus Station", "Train Station", + "School", "Mile Marker", "Conservation Area", "Waypoint", "Box", "Aerial", + "Auto Repair", "Boat", "Exit Ramp", "Fixed Nav Aid", "Floating Buoy", "Garden", + "Fish Farm", "Lighthouse", "Truck Service", "Resort", "Scuba", "Shooting", + "Sight Seeing", "Sounding", "Winery", "Navaid, Amber", "Navaid, Black", + "Navaid, Blue", "Navaid, Green", "Navaid, Green/Red", "Navaid, Green/White", + "Navaid, Orange", "Navaid, Red", "Navaid, Red/Green", "Navaid, Red/White", + "Navaid, Violet", "Navaid, White", "Navaid, White/Green", "Navaid, White/Red", + "Buoy, White", "Dot, White", "Red Square", "Red Diamond", "Green Square", + "Green Diamond", "Restricted Area", "Navaid (unlit)", "Dot (Small)", "Libraries", "Waypoint", "Waypoint1", + "Waypoint2", "Mark (1)", "Mark (2)", "Mark (3)", "Cross (Red)", "Store", + "Exclamation", "Flag (EUA)", "Flag (CAN)", "Flag (BRA)", "Man", "Animals", + "Deer Tracks", "Tree Stand", "Bridge", "Fence", "Intersection", + "Non Direct Beacon", "VHF Omni Range", "Vor/Tacan", "Vor-Dme", + "1st Approach Fix", "Localizer Outer", "Missed Appr. Pt", "Tacan", + "CheckPoint", nullptr + }; + + /* Member Functions */ + + static QString fread_string(gbfile* fd); + static void fread_string_discard(gbfile* fd); + static QString fread_fixedstring(gbfile* fd, int len); + static void fwrite_null(gbfile* fd, int len); + static void fwrite_string(gbfile* fd, const char* str); + static void fwrite_string(gbfile* fd, const QString& str); + static void fwrite_fixedstring(gbfile* fd, const char* str, int fieldlen); + static void fwrite_fixedstring(gbfile* fd, const QString& str, int fieldlen); + void set_datum(int n); + void convert_datum(double* lat, double* lon) const; + void count_track_styles(const route_head* rte); + static int icon_from_descr(const QString& descr); + void write_waypt(const Waypoint* wpt); + void start_rte(const route_head* rte); + void write_trk_waypt(const Waypoint* wpt); + void write_trk_style(const route_head* trk); + void write_rte_waypt(const Waypoint* wpt); + + /* Data Members */ + + gbfile* file_in{}; + gbfile* file_out{}; + int indatum{}; + int wp_count{}; + int ws_count{}; + int tr_count{}; + int ts_count{}; + int rt_count{}; + int im_count{}; + const route_head* rte_active{}; + int start_new{}; +}; +#endif // GTM_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index 05c4c7e19..06bee8ecc 100644 --- a/vecs.cc +++ b/vecs.cc @@ -52,6 +52,7 @@ #include "globalsat_sport.h" // for GlobalsatSportFormat #include "geo.h" // for GeoFormat #include "gpx.h" // for GpxFormat +#include "gtm.h" // for GtmFormat #include "gtrnctr.h" // for GtrnctrFormat #include "html.h" // for HtmlFormat #include "humminbird.h" // for HumminbirdFormat, HumminbirdHTFormat @@ -88,7 +89,6 @@ extern ff_vecs_t mtk_m241_vecs; extern ff_vecs_t mtk_m241_fvecs; #endif // MAXIMAL_ENABLED #if MAXIMAL_ENABLED -extern ff_vecs_t gtm_vecs; #if CSVFMTS_ENABLED extern ff_vecs_t garmin_txt_vecs; #endif // CSVFMTS_ENABLED @@ -137,7 +137,7 @@ struct Vecs::Impl { #endif // MAXIMAL_ENABLED #if MAXIMAL_ENABLED UnicsvFormat unicsv_fmt; - LegacyFormat gtm_fmt {gtm_vecs}; + GtmFormat gtm_fmt; #if CSVFMTS_ENABLED LegacyFormat garmin_txt_fmt {garmin_txt_vecs}; #endif // CSVFMTS_ENABLED From f888ec564e06961b8f2657a34f511c538f8b46ee Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 15:16:01 -0700 Subject: [PATCH 046/132] convert tpg to dynamic Format class. (#1229) --- CMakeLists.txt | 1 + tpg.cc | 75 ++++++++++++++++---------------------------- tpg.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++ vecs.cc | 6 ++-- 4 files changed, 114 insertions(+), 52 deletions(-) create mode 100644 tpg.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 17b57b335..6be14d150 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,6 +238,7 @@ set(HEADERS skytraq.h subrip.h text.h + tpg.h tpo.h unicsv.h units.h diff --git a/tpg.cc b/tpg.cc index 615a08de2..5b21552e3 100644 --- a/tpg.cc +++ b/tpg.cc @@ -22,16 +22,17 @@ */ +#include "tpg.h" + #include // for isalnum #include // for memcmp #include // for QChar #include // for QString -#include // for QVector #include "defs.h" -#include "gbfile.h" // for gbfwrite, gbfgetint16, gbfputint16, gbfclose -#include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index, GPS_Math_Known_Da... +#include "gbfile.h" // for gbfwrite, gbfgetint16, gbfputint16, gbfclose, gbfgetdbl, gbfgetpstr, gbfopen_le, gbfputdbl, gbfgetint32, gbfputc, gbfputpstr, gbfread +#include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_WGS84_To_Known_Datum_M #include "mkshort.h" // for MakeShort @@ -40,21 +41,8 @@ #define MAXTPGSTRINGSIZE 256 #define MAXTPGOUTPUTPINS 65535 -static gbfile* tpg_file_in; -static gbfile* tpg_file_out; -static MakeShort* mkshort_handle; -static char* tpg_datum_opt; -static int tpg_datum_idx; - -static unsigned int waypt_out_count; - -static -QVector tpg_args = { - {"datum", &tpg_datum_opt, "Datum (default=NAD27)", "N. America 1927 mean", ARGTYPE_STRING, ARG_NOMINMAX , nullptr}, -}; - -static int -valid_tpg_header(char* header, int len) +int +TpgFormat::valid_tpg_header(char* header, int len) { unsigned char header_bytes[] = { 0xFF, 0xFF, 0x01, 0x00, 0x0D, 0x00, 0x43, 0x54, 0x6F, 0x70, @@ -68,8 +56,8 @@ valid_tpg_header(char* header, int len) return memcmp(header_bytes, header, len); } -static void -tpg_common_init() +void +TpgFormat::tpg_common_init() { tpg_datum_idx = GPS_Lookup_Datum_Index(tpg_datum_opt); if (tpg_datum_idx < 0) { @@ -77,21 +65,21 @@ tpg_common_init() } } -static void -tpg_rd_init(const QString& fname) +void +TpgFormat::rd_init(const QString& fname) { tpg_common_init(); tpg_file_in = gbfopen_le(fname, "rb", MYNAME); } -static void -tpg_rd_deinit() +void +TpgFormat::rd_deinit() { gbfclose(tpg_file_in); } -static void -tpg_wr_init(const QString& fname) +void +TpgFormat::wr_init(const QString& fname) { tpg_common_init(); tpg_file_out = gbfopen_le(fname, "wb", MYNAME); @@ -99,15 +87,15 @@ tpg_wr_init(const QString& fname) waypt_out_count = 0; } -static void -tpg_wr_deinit() +void +TpgFormat::wr_deinit() { delete mkshort_handle; gbfclose(tpg_file_out); } -static void -tpg_read() +void +TpgFormat::read() { char buff[MAXTPGSTRINGSIZE + 1]; double amt; @@ -169,8 +157,8 @@ tpg_read() } } -static void -tpg_waypt_pr(const Waypoint* wpt) +void +TpgFormat::tpg_waypt_pr(const Waypoint* wpt) { double lon, lat; double amt; @@ -280,8 +268,8 @@ tpg_waypt_pr(const Waypoint* wpt) } } -static void -tpg_write() +void +TpgFormat::write() { unsigned char header_bytes[] = { 0xFF, 0xFF, 0x01, 0x00, 0x0D, 0x00, 0x43, 0x54, 0x6F, 0x70, @@ -307,19 +295,8 @@ tpg_write() /* write the rest of the header */ gbfwrite(header_bytes, 1, 19, tpg_file_out); - waypt_disp_all(tpg_waypt_pr); + auto tpg_waypt_pr_lambda = [this](const Waypoint* waypointp)->void { + tpg_waypt_pr(waypointp); + }; + waypt_disp_all(tpg_waypt_pr_lambda); } - -ff_vecs_t tpg_vecs = { - ff_type_file, - FF_CAP_RW_WPT, - tpg_rd_init, - tpg_wr_init, - tpg_rd_deinit, - tpg_wr_deinit, - tpg_read, - tpg_write, - nullptr, - &tpg_args, - NULL_POS_OPS -}; diff --git a/tpg.h b/tpg.h new file mode 100644 index 000000000..6f4b098d3 --- /dev/null +++ b/tpg.h @@ -0,0 +1,84 @@ +/* + National Geographic Topo! TPG file support (Waypoints/Routes) + Contributed to gpsbabel by Alex Mottram + + For Topo! version 2.x. Routes are currently not implemented. + + Copyright (C) 2002 Alex Mottram, geo_alexm at cox-internet.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ +#ifndef TPG_H_INCLUDED_ +#define TPG_H_INCLUDED_ + +#include // for QString +#include // for QVector + +#include "defs.h" +#include "format.h" // for Format +#include "gbfile.h" // for gbfile +#include "mkshort.h" // for MakeShort + + +class TpgFormat : public Format +{ +public: + using Format::Format; + + QVector* get_args() override + { + return &tpg_args; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + return FF_CAP_RW_WPT; + } + + void rd_init(const QString& fname) override; + void read() override; + void rd_deinit() override; + void wr_init(const QString& fname) override; + void write() override; + void wr_deinit() override; + +private: + /* Member Functions */ + + static int valid_tpg_header(char* header, int len); + void tpg_common_init(); + void tpg_waypt_pr(const Waypoint* wpt); + + /* Data Members */ + + gbfile* tpg_file_in{}; + gbfile* tpg_file_out{}; + MakeShort* mkshort_handle{}; + char* tpg_datum_opt{}; + int tpg_datum_idx{}; + + unsigned int waypt_out_count{}; + + QVector tpg_args = { + {"datum", &tpg_datum_opt, "Datum (default=NAD27)", "N. America 1927 mean", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, + }; +}; +#endif // TPG_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index 06bee8ecc..4807ad949 100644 --- a/vecs.cc +++ b/vecs.cc @@ -70,6 +70,7 @@ #include "src/core/logging.h" // for Warning, FatalMsg #include "subrip.h" // for SubripFormat #include "text.h" // for TextFormat +#include "tpg.h" // for TpgFormat #include "tpo.h" // for Tpo2Format, Tpo3Format #include "unicsv.h" // for UnicsvFormat #include "v900.h" // for V900Format @@ -81,7 +82,6 @@ extern ff_vecs_t geo_vecs; extern ff_vecs_t ozi_vecs; #if MAXIMAL_ENABLED -extern ff_vecs_t tpg_vecs; extern ff_vecs_t gpl_vecs; extern ff_vecs_t mtk_vecs; extern ff_vecs_t mtk_fvecs; @@ -121,7 +121,6 @@ struct Vecs::Impl { KmlFormat kml_fmt; #if MAXIMAL_ENABLED LowranceusrFormat lowranceusr_fmt; - LegacyFormat tpg_fmt {tpg_vecs}; Tpo2Format tpo2_fmt; Tpo3Format tpo3_fmt; #if SHAPELIB_ENABLED @@ -233,11 +232,12 @@ struct Vecs::Impl { nullptr, }, { - &tpg_fmt, + nullptr, "tpg", "National Geographic Topo .tpg (waypoints)", "tpg", nullptr, + &fmtfactory }, { &tpo2_fmt, From bed7b94d89432ac1d6f0957fc5dcd0e8293b4e35 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 16:28:47 -0700 Subject: [PATCH 047/132] convert garmin_xt to Format class (#1230) --- CMakeLists.txt | 1 + garmin_xt.cc | 99 +++++++++++----------------------------------- garmin_xt.h | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ vecs.cc | 4 +- 4 files changed, 130 insertions(+), 79 deletions(-) create mode 100644 garmin_xt.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6be14d150..38f2ff4cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,6 +210,7 @@ set(HEADERS gbfile.h gbser.h gbser_private.h + garmin_xt.h gdb.h geocache.h geojson.h diff --git a/garmin_xt.cc b/garmin_xt.cc index 5e62af4db..a0f4cc48e 100644 --- a/garmin_xt.cc +++ b/garmin_xt.cc @@ -23,15 +23,16 @@ */ +#include "garmin_xt.h" + #include // for uint8_t, uint32_t, uint16_t, int32_t #include // for SEEK_CUR, SEEK_SET #include // for strcmp, strcpy #include // for QString -#include // for QVector -#include "defs.h" // -#include "gbfile.h" // for gbfread, gbfgetuint16, gbfseek, gbfgetc, gbfgetu... +#include "defs.h" +#include "gbfile.h" // for gbfread, gbfgetuint16, gbfseek, gbfgetc, gbfgetuint32, gbfclose, gbfeof, gbfopen #define MYNAME "Garmin_XT" @@ -39,38 +40,6 @@ #define DATABLOCKSIZE 1 #define STRK_BLOCK_SIZE 97 -static int colors[] = { - 0x000000, // Black - 0x00008b, // DarkRed - 0x006400, // DarkGreen - 0x00d7ff, // Gold - 0x8b0000, // DarkBlue - 0x8b008b, // DarkMagenta - 0x8b8b00, // DarkCyan - 0xd3d3d3, // LightGray - 0xa9a9a9, // DarkGray - 0x0000ff, // Red - 0x00ff00, // Green - 0x00ffff, // Yellow - 0xff0000, // Blue - 0xff00ff, // Magenta - 0xffff00, // Cyan - 0xffffff // White -}; - -static gbfile* fin; -static route_head* track; -static char* opt_xt_ftype = nullptr; -static char* opt_trk_header = nullptr; - -static -QVector format_garmin_xt_args = { - {"ftype", &opt_xt_ftype, "Garmin Mobile XT ([ATRK]/STRK)", "ATRK", ARGTYPE_STRING | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr}, - // TODO: SHIFT - can't test behaviour, do not have appropriate files - //{"trk_header_opt", &opt_trk_header, "Track name processing option ([0]-nrm/1-ign/2-sht)", "0", ARGTYPE_INT, ARG_NOMINMAX}, - {"trk_header", &opt_trk_header, "Track name processing option ([0]-nrm/1-ign)", "0", ARGTYPE_INT, ARG_NOMINMAX, nullptr}, -}; - /******************************************************************************* * %%% global callbacks called by gpsbabel main process %%% * *******************************************************************************/ @@ -78,20 +47,20 @@ QVector format_garmin_xt_args = { /******************************************************************************* * %%% Reader callbacks %%% * *******************************************************************************/ -static void -format_garmin_xt_rd_init(const QString& fname) +void +GarminXTFormat::rd_init(const QString& fname) { fin = gbfopen(fname, "rb", MYNAME); } -static void -format_garmin_xt_rd_deinit() +void +GarminXTFormat::rd_deinit() { gbfclose(fin); } -static uint16_t -format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color) +uint16_t +GarminXTFormat::format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color) { int method = 0; uint8_t spam = 0; @@ -156,8 +125,8 @@ format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color) /* * Function to decrypt track block in saved read from saved tracks file */ -static void -format_garmin_xt_decrypt_trk_blk(int Count, uint8_t TrackBlock[]) +void +GarminXTFormat::format_garmin_xt_decrypt_trk_blk(int Count, uint8_t TrackBlock[]) { int j = 12; while (j<(Count-1)) { @@ -174,8 +143,8 @@ format_garmin_xt_decrypt_trk_blk(int Count, uint8_t TrackBlock[]) /* * Function to Decompose track block of STRK_BLOCK_SIZE bytes */ -static void -format_garmin_xt_decomp_trk_blk(uint8_t ii, const uint8_t TrackBlock[], double* Ele, double* Lat, double* Lon, uint32_t* Time) +void +GarminXTFormat::format_garmin_xt_decomp_trk_blk(uint8_t ii, const uint8_t TrackBlock[], double* Ele, double* Lat, double* Lon, uint32_t* Time) { //printf("%d %d %d %d %d %d\n", TrackBlock[0], TrackBlock[1], TrackBlock[2], TrackBlock[3], TrackBlock[4], TrackBlock[5]); uint16_t PrevEleW = TrackBlock[(ii - 1) * 12 + 1 ]; @@ -218,8 +187,8 @@ format_garmin_xt_decomp_trk_blk(uint8_t ii, const uint8_t TrackBlock[], double* /* * Decompose Last Waypoint Elevation */ -static void -format_garmin_xt_decomp_last_ele(uint8_t ii, double* PrevEle, const uint8_t TrackBlock[]) +void +GarminXTFormat::format_garmin_xt_decomp_last_ele(uint8_t ii, double* PrevEle, const uint8_t TrackBlock[]) { uint16_t PrevEleW = TrackBlock[ii - 1]; PrevEleW = PrevEleW << 8; @@ -230,8 +199,8 @@ format_garmin_xt_decomp_last_ele(uint8_t ii, double* PrevEle, const uint8_t Trac /* * Main Function to process Saved tracks file */ -static void -format_garmin_xt_proc_strk() +void +GarminXTFormat::format_garmin_xt_proc_strk() { int Count = 0; // Used to obtain number of read bytes int TracksCompleted = 0; // Number of processed tracks @@ -331,8 +300,8 @@ format_garmin_xt_proc_strk() } } -static void -format_garmin_xt_proc_atrk() +void +GarminXTFormat::format_garmin_xt_proc_atrk() { int method = 0; unsigned char buf[3]; @@ -393,8 +362,8 @@ format_garmin_xt_proc_atrk() } } -static void -format_garmin_xt_read() +void +GarminXTFormat::read() { // Saved Tracks file if (strcmp(opt_xt_ftype, "STRK") == 0) { @@ -403,27 +372,3 @@ format_garmin_xt_read() format_garmin_xt_proc_atrk(); } } - -/**************************************************************************/ - -/* ascii is the expected character set */ -/* not fixed, can be changed through command line parameter */ - -ff_vecs_t format_garmin_xt_vecs = { - ff_type_file, - { - ff_cap_none /* waypoints */, - ff_cap_read /* tracks */, - ff_cap_none /* routes */ - }, - format_garmin_xt_rd_init, - nullptr, - format_garmin_xt_rd_deinit, - nullptr, - format_garmin_xt_read, - nullptr, - nullptr, - &format_garmin_xt_args, - NULL_POS_OPS -}; -/**************************************************************************/ diff --git a/garmin_xt.h b/garmin_xt.h new file mode 100644 index 000000000..39c5b44c2 --- /dev/null +++ b/garmin_xt.h @@ -0,0 +1,105 @@ +/* + + Copyright (C) 2010 Eriks Zelenka, isindir@users.sourceforge.net + Copyright (C) 2009 jekaeff, + GMXT2GPX ( http://www.geocaching.hu/users.geo?id=9508 ; http://sites.google.com/site/jekaeff/eng-1 ) + The original code written in Pascal and does not include specific License, however on the project + webpage it is said to be OpenSource/Libre software + Copyright (C) 2005 Robert Lipe, robertlipe+source@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ +#ifndef GARMIN_XT_H_INCLUDED_ +#define GARMIN_XT_H_INCLUDED_ + +#include // for uint8_t, uint16_t, uint32_t + +#include // for QString +#include // for QVector + +#include "defs.h" +#include "format.h" // for Format +#include "gbfile.h" // for gbfile + + +class GarminXTFormat : public Format +{ +public: + QVector* get_args() override + { + return &format_garmin_xt_args; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + return {ff_cap_none, ff_cap_read, ff_cap_none}; + } + + void rd_init(const QString& fname) override; + void read() override; + void rd_deinit() override; + +private: + /* Constants */ + + static constexpr int colors[] = { + 0x000000, // Black + 0x00008b, // DarkRed + 0x006400, // DarkGreen + 0x00d7ff, // Gold + 0x8b0000, // DarkBlue + 0x8b008b, // DarkMagenta + 0x8b8b00, // DarkCyan + 0xd3d3d3, // LightGray + 0xa9a9a9, // DarkGray + 0x0000ff, // Red + 0x00ff00, // Green + 0x00ffff, // Yellow + 0xff0000, // Blue + 0xff00ff, // Magenta + 0xffff00, // Cyan + 0xffffff // White + }; + + /* Member Functions */ + + uint16_t format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color); + static void format_garmin_xt_decrypt_trk_blk(int Count, uint8_t* TrackBlock); + static void format_garmin_xt_decomp_trk_blk(uint8_t ii, const uint8_t* TrackBlock, double* Ele, double* Lat, double* Lon, uint32_t* Time); + static void format_garmin_xt_decomp_last_ele(uint8_t ii, double* PrevEle, const uint8_t* TrackBlock); + void format_garmin_xt_proc_strk(); + void format_garmin_xt_proc_atrk(); + + /* Data Members */ + + gbfile* fin{}; + route_head* track{}; + char* opt_xt_ftype = nullptr; + char* opt_trk_header = nullptr; + + QVector format_garmin_xt_args = { + {"ftype", &opt_xt_ftype, "Garmin Mobile XT ([ATRK]/STRK)", "ATRK", ARGTYPE_STRING | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr}, + // TODO: SHIFT - can't test behaviour, do not have appropriate files + //{"trk_header_opt", &opt_trk_header, "Track name processing option ([0]-nrm/1-ign/2-sht)", "0", ARGTYPE_INT, ARG_NOMINMAX}, + {"trk_header", &opt_trk_header, "Track name processing option ([0]-nrm/1-ign)", "0", ARGTYPE_INT, ARG_NOMINMAX, nullptr}, + }; +}; +#endif // GARMIN_XT_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index 4807ad949..a963531f8 100644 --- a/vecs.cc +++ b/vecs.cc @@ -46,6 +46,7 @@ #include "garmin.h" // for GarminFormat #include "garmin_fit.h" // for GarminFitFormat #include "garmin_gpi.h" // for GarminGPIFormat +#include "garmin_xt.h" // for GarminXTFormat #include "gbversion.h" // for WEB_DOC_DIR #include "gdb.h" // for GdbFormat #include "geojson.h" // for GeoJsonFormat @@ -93,7 +94,6 @@ extern ff_vecs_t mtk_m241_fvecs; extern ff_vecs_t garmin_txt_vecs; #endif // CSVFMTS_ENABLED extern ff_vecs_t ggv_log_vecs; -extern ff_vecs_t format_garmin_xt_vecs; #endif // MAXIMAL_ENABLED #define MYNAME "vecs" @@ -155,7 +155,7 @@ struct Vecs::Impl { SkytraqfileFormat skytraq_ffmt; MinihomerFormat miniHomer_fmt; SubripFormat subrip_fmt; - LegacyFormat format_garmin_xt_fmt {format_garmin_xt_vecs}; + GarminXTFormat format_garmin_xt_fmt; GarminFitFormat format_fit_fmt; GeoJsonFormat geojson_fmt; GlobalsatSportFormat globalsat_sport_fmt; From 6562dd190bfd492f8d7f6b8b09a8f5e57356b9e7 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 17:49:24 -0700 Subject: [PATCH 048/132] convert garmin_txt to Format class (#1231) * convert garmin_txt to Format class * fix includes for qt5 --- CMakeLists.txt | 1 + garmin_txt.cc | 381 ++++++++++++++++++++----------------------------- garmin_txt.h | 203 ++++++++++++++++++++++++++ vecs.cc | 10 +- 4 files changed, 357 insertions(+), 238 deletions(-) create mode 100644 garmin_txt.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 38f2ff4cd..3308221d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,6 +210,7 @@ set(HEADERS gbfile.h gbser.h gbser_private.h + garmin_txt.h garmin_xt.h gdb.h geocache.h diff --git a/garmin_txt.cc b/garmin_txt.cc index f7b1575fd..81f5d1b59 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -20,92 +20,60 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#if CSVFMTS_ENABLED -#include "defs.h" +#include "garmin_txt.h" -#if CSVFMTS_ENABLED #include // for for_each, sort -#include // for array +#include // for array, array<>::iterator #include // for toupper #include // for fabs, floor #include // for uint16_t #include // for sscanf, fprintf, snprintf, stderr #include // for abs #include // for strstr, strlen -#include // for time_t, gmtime, localtime, strftime -#include // for optional -#include // for as_const, pair, make_pair +#include // for gmtime, time_t, localtime, strftime, tm +#include // for optional +#include // for add_const_t +#include // for pair, as_const, make_pair #include // for QByteArray #include // for QChar, QChar::Other_Control #include // for QDateTime -#include // for QIODevice, QIODevice::ReadOnly, QIODevice::WriteOnly +#include // for QDebug +#include // for QIODevice, QIODeviceBase::ReadOnly, QIODeviceBase::WriteOnly #include // for QList, QList<>::const_iterator #include // for QString, operator!= #include // for QStringList +#include // for qMakeStringPrivate, QStringLiteral #include // for QTextStream #include // for QVector #include // for CaseInsensitive #include // for qRound, qPrintable +#include "defs.h" #include "csv_util.h" // for csv_linesplit #include "formspec.h" // for FormatSpecificDataList #include "garmin_fs.h" // for garmin_fs_t #include "garmin_tables.h" // for gt_display_modes_e, gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, gt_get_mps_grid_longname, gt_lookup_datum_index, gt_lookup_grid_type, GDB, gt_get_icao_cc, gt_get_icao_country, gt_get_mps_datum_name, gt_waypt_class_names, GT_DISPLAY_MODE... #include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS84_To_UKOSMap_M #include "src/core/datetime.h" // for DateTime -#include "src/core/logging.h" // for Fatal +#include "src/core/logging.h" // for FatalMsg #include "src/core/textstream.h" // for TextStream #define MYNAME "garmin_txt" -struct gtxt_flags_t { - unsigned int metric:1; - unsigned int celsius:1; - unsigned int utc:1; - unsigned int enum_waypoints:1; - unsigned int route_header_written:1; - unsigned int track_header_written:1; -}; - -static gpsbabel::TextStream* fin = nullptr; -static gpsbabel::TextStream* fout = nullptr; -static route_head* current_trk; -static route_head* current_rte; -static int waypoints; -static int routepoints; -static const Waypoint** wpt_a; -static int wpt_a_ct; -static grid_type grid_index; -static int datum_index; -static const char* datum_str; -static int current_line; -static QString date_time_format; -static int precision = 3; -static time_t utc_offs = 0; -static gtxt_flags_t gtxt_flags; - -enum header_type { - waypt_header = 0, - rtept_header, - trkpt_header, - route_header, - track_header, - unknown_header +const QVector GarminTxtFormat::headers = { + "Name\tDescription\tType\tPosition\tAltitude\tDepth\tProximity\tTemperature\t" + "Display Mode\tColor\tSymbol\tFacility\tCity\tState\tCountry\t" + "Date Modified\tLink\tCategories", + "Waypoint Name\tDistance\tLeg Length\tCourse", + "Position\tTime\tAltitude\tDepth\tTemperature\tLeg Length\tLeg Time\tLeg Speed\tLeg Course", + "Name\tLength\tCourse\tWaypoints\tLink", + "Name\tStart Time\tElapsed Time\tLength\tAverage Speed\tLink" }; -inline header_type& operator++(header_type& s) // prefix -{ - return s = static_cast(s + 1); -} -inline header_type operator++(header_type& s, int) // postfix -{ - header_type ret(s); - ++s; - return ret; -} - inline gt_display_modes_e& operator++(gt_display_modes_e& s) // prefix { return s = static_cast(s + 1); @@ -117,78 +85,22 @@ inline gt_display_modes_e operator++(gt_display_modes_e& s, int) // postfix return ret; } -static std::array>, unknown_header> header_mapping_info; -static QStringList header_column_names; - -static constexpr double kGarminUnknownAlt = 1.0e25; -static constexpr char kDefaultDateFormat[] = "dd/mm/yyyy"; -static constexpr char kDefaultTimeFormat[] = "HH:mm:ss"; - -static bool is_valid_alt(double alt) +bool GarminTxtFormat::is_valid_alt(double alt) { return (alt != unknown_alt) && (alt < kGarminUnknownAlt); } -static char* opt_datum = nullptr; -static char* opt_dist = nullptr; -static char* opt_temp = nullptr; -static char* opt_date_format = nullptr; -static char* opt_time_format = nullptr; -static char* opt_precision = nullptr; -static char* opt_utc = nullptr; -static char* opt_grid = nullptr; - -static -QVector garmin_txt_args = { - {"date", &opt_date_format, "Read/Write date format (i.e. yyyy/mm/dd)", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, - {"datum", &opt_datum, "GPS datum (def. WGS 84)", "WGS 84", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, - {"dist", &opt_dist, "Distance unit [m=metric, s=statute]", "m", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, - {"grid", &opt_grid, "Write position using this grid.", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, - {"prec", &opt_precision, "Precision of coordinates", "3", ARGTYPE_INT, ARG_NOMINMAX, nullptr}, - {"temp", &opt_temp, "Temperature unit [c=Celsius, f=Fahrenheit]", "c", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, - {"time", &opt_time_format, "Read/Write time format (i.e. HH:mm:ss xx)", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, - {"utc", &opt_utc, "Write timestamps with offset x to UTC time", nullptr, ARGTYPE_INT, "-23", "+23", nullptr}, -}; - -class PathInfo -{ -public: - double length {0}; - time_t start {0}; - time_t time {0}; - double speed {0}; - double total {0}; - int count {0}; - const Waypoint* prev_wpt {nullptr}; - const Waypoint* first_wpt {nullptr}; - const Waypoint* last_wpt {nullptr}; -}; - -static PathInfo* route_info; -static int route_idx; -static PathInfo* cur_info; - -static const QVector headers = { - "Name\tDescription\tType\tPosition\tAltitude\tDepth\tProximity\tTemperature\t" - "Display Mode\tColor\tSymbol\tFacility\tCity\tState\tCountry\t" - "Date Modified\tLink\tCategories", - "Waypoint Name\tDistance\tLeg Length\tCourse", - "Position\tTime\tAltitude\tDepth\tTemperature\tLeg Length\tLeg Time\tLeg Speed\tLeg Course", - "Name\tLength\tCourse\tWaypoints\tLink", - "Name\tStart Time\tElapsed Time\tLength\tAverage Speed\tLink" -}; - /* helpers */ -static const char* -get_option_val(const char* option, const char* def) +const char* +GarminTxtFormat::get_option_val(const char* option, const char* def) { const char* c = (option != nullptr) ? option : def; return c; } -static void -init_date_and_time_format() +void +GarminTxtFormat::init_date_and_time_format() { // This is old, and weird, code.. date_time_format is a global that's // explicitly malloced and freed elsewhere. This isn't very C++ at all, @@ -202,8 +114,8 @@ init_date_and_time_format() date_time_format = QStringLiteral("%1 %2").arg(d1, t1); } -static void -convert_datum(const Waypoint* wpt, double* dest_lat, double* dest_lon) +void +GarminTxtFormat::convert_datum(const Waypoint* wpt, double* dest_lat, double* dest_lon) const { double alt; @@ -218,8 +130,8 @@ convert_datum(const Waypoint* wpt, double* dest_lat, double* dest_lon) /* Waypoint preparation */ -static void -enum_waypt_cb(const Waypoint* wpt) +void +GarminTxtFormat::enum_waypt_cb(const Waypoint* wpt) { const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); int wpt_class = garmin_fs_t::get_wpt_class(gmsd, 0); @@ -244,21 +156,21 @@ enum_waypt_cb(const Waypoint* wpt) /* common route and track pre-work */ -static void -prework_hdr_cb(const route_head* /*unused*/) +void +GarminTxtFormat::prework_hdr_cb(const route_head* /*unused*/) { cur_info = &route_info[route_idx]; } -static void -prework_tlr_cb(const route_head* /*unused*/) +void +GarminTxtFormat::prework_tlr_cb(const route_head* /*unused*/) { cur_info->last_wpt = cur_info->prev_wpt; route_idx++; } -static void -prework_wpt_cb(const Waypoint* wpt) +void +GarminTxtFormat::prework_wpt_cb(const Waypoint* wpt) { const Waypoint* prev = cur_info->prev_wpt; @@ -277,8 +189,8 @@ prework_wpt_cb(const Waypoint* wpt) /* output helpers */ -static void -print_position(const Waypoint* wpt) +void +GarminTxtFormat::print_position(const Waypoint* wpt) { int valid = 1; double lat, lon, north, east; @@ -363,8 +275,8 @@ print_position(const Waypoint* wpt) } } -static void -print_date_and_time(const time_t time, const bool time_only) +void +GarminTxtFormat::print_date_and_time(const time_t time, const bool time_only) { std::tm tm{}; char tbuf[32]; @@ -390,8 +302,8 @@ print_date_and_time(const time_t time, const bool time_only) *fout << "\t"; } -static void -print_categories(uint16_t categories) +void +GarminTxtFormat::print_categories(uint16_t categories) { const QStringList categoryList = garmin_fs_t::print_categories(categories); if (!categoryList.isEmpty()) { @@ -399,8 +311,8 @@ print_categories(uint16_t categories) } } -static void -print_course(const Waypoint* A, const Waypoint* B) /* seems to be okay */ +void +GarminTxtFormat::print_course(const Waypoint* A, const Waypoint* B) /* seems to be okay */ { if ((A != nullptr) && (B != nullptr) && (A != B)) { int course = qRound(waypt_course(A, B)); @@ -408,8 +320,8 @@ print_course(const Waypoint* A, const Waypoint* B) /* seems to be okay */ } } -static void -print_distance(const double distance, const bool no_scale, const bool with_tab, const int decis) +void +GarminTxtFormat::print_distance(const double distance, const bool no_scale, const bool with_tab, const int decis) { double dist = distance; @@ -443,8 +355,8 @@ print_distance(const double distance, const bool no_scale, const bool with_tab, } } -static void -print_speed(const double distance, const time_t time) +void +GarminTxtFormat::print_speed(const double distance, const time_t time) { double dist = distance; const char* unit; @@ -474,8 +386,8 @@ print_speed(const double distance, const time_t time) *fout << "\t"; } -static void -print_temperature(const float temperature) +void +GarminTxtFormat::print_temperature(const float temperature) { if (gtxt_flags.celsius) { *fout << QString::asprintf("%.f C", temperature); @@ -484,8 +396,8 @@ print_temperature(const float temperature) } } -static void -print_string(const char* fmt, const QString& string) +void +GarminTxtFormat::print_string(const char* fmt, const QString& string) { /* remove unwanted characters from source string */ QString cleanstring; @@ -502,8 +414,8 @@ print_string(const char* fmt, const QString& string) /* main cb's */ -static void -write_waypt(const Waypoint* wpt) +void +GarminTxtFormat::write_waypt(const Waypoint* wpt) { const char* wpt_type; @@ -588,8 +500,8 @@ write_waypt(const Waypoint* wpt) *fout << "\r\n"; } -static void -route_disp_hdr_cb(const route_head* rte) +void +GarminTxtFormat::route_disp_hdr_cb(const route_head* rte) { cur_info = &route_info[route_idx]; cur_info->prev_wpt = nullptr; @@ -614,14 +526,14 @@ route_disp_hdr_cb(const route_head* rte) *fout << QStringLiteral("\r\nHeader\t%1\r\n\r\n").arg(headers[rtept_header]); } -static void -route_disp_tlr_cb(const route_head* /*unused*/) +void +GarminTxtFormat::route_disp_tlr_cb(const route_head* /*unused*/) { route_idx++; } -static void -route_disp_wpt_cb(const Waypoint* wpt) +void +GarminTxtFormat::route_disp_wpt_cb(const Waypoint* wpt) { const Waypoint* prev = cur_info->prev_wpt; @@ -642,8 +554,8 @@ route_disp_wpt_cb(const Waypoint* wpt) cur_info->prev_wpt = wpt; } -static void -track_disp_hdr_cb(const route_head* track) +void +GarminTxtFormat::track_disp_hdr_cb(const route_head* track) { cur_info = &route_info[route_idx]; cur_info->prev_wpt = nullptr; @@ -669,14 +581,14 @@ track_disp_hdr_cb(const route_head* track) *fout << QStringLiteral("\r\n\r\nHeader\t%1\r\n\r\n").arg(headers[trkpt_header]); } -static void -track_disp_tlr_cb(const route_head* /*unused*/) +void +GarminTxtFormat::track_disp_tlr_cb(const route_head* /*unused*/) { route_idx++; } -static void -track_disp_wpt_cb(const Waypoint* wpt) +void +GarminTxtFormat::track_disp_wpt_cb(const Waypoint* wpt) { const Waypoint* prev = cur_info->prev_wpt; time_t delta; @@ -719,8 +631,8 @@ track_disp_wpt_cb(const Waypoint* wpt) * %%% global callbacks called by gpsbabel main process %%% * *******************************************************************************/ -static void -garmin_txt_utc_option() +void +GarminTxtFormat::garmin_txt_utc_option() { if (opt_utc != nullptr) { if (case_ignore_strcmp(opt_utc, "utc") == 0) { @@ -733,16 +645,16 @@ garmin_txt_utc_option() } } -static void -garmin_txt_adjust_time(QDateTime& dt) +void +GarminTxtFormat::garmin_txt_adjust_time(QDateTime& dt) const { if (gtxt_flags.utc) { dt = dt.toUTC().addSecs(dt.offsetFromUtc() - utc_offs); } } -static void -garmin_txt_wr_init(const QString& fname) +void +GarminTxtFormat::wr_init(const QString& fname) { gtxt_flags = {}; @@ -790,8 +702,8 @@ garmin_txt_wr_init(const QString& fname) garmin_txt_utc_option(); } -static void -garmin_txt_wr_deinit() +void +GarminTxtFormat::wr_deinit() { fout->close(); delete fout; @@ -800,9 +712,40 @@ garmin_txt_wr_deinit() date_time_format.squeeze(); } -static void -garmin_txt_write() +void +GarminTxtFormat::write() { + auto enum_waypt_cb_lambda = [this](const Waypoint* waypointp)->void { + enum_waypt_cb(waypointp); + }; + auto prework_hdr_cb_lambda = [this](const route_head* rte)->void { + prework_hdr_cb(rte); + }; + auto prework_tlr_cb_lambda = [this](const route_head* rte)->void { + prework_tlr_cb(rte); + }; + auto prework_wpt_cb_lambda = [this](const Waypoint* waypointp)->void { + prework_wpt_cb(waypointp); + }; + auto route_disp_hdr_cb_lambda = [this](const route_head* rte)->void { + route_disp_hdr_cb(rte); + }; + auto route_disp_tlr_cb_lambda = [this](const route_head* rte)->void { + route_disp_tlr_cb(rte); + }; + auto route_disp_wpt_cb_lambda = [this](const Waypoint* waypointp)->void { + route_disp_wpt_cb(waypointp); + }; + auto track_disp_hdr_cb_lambda = [this](const route_head* rte)->void { + track_disp_hdr_cb(rte); + }; + auto track_disp_tlr_cb_lambda = [this](const route_head* rte)->void { + track_disp_tlr_cb(rte); + }; + auto track_disp_wpt_cb_lambda = [this](const Waypoint* waypointp)->void { + track_disp_wpt_cb(waypointp); + }; + QString grid_str = gt_get_mps_grid_longname(grid_index, MYNAME); grid_str = grid_str.replace('*', "°"); *fout << "Grid\t" << grid_str << "\r\n"; @@ -812,15 +755,15 @@ garmin_txt_write() waypoints = 0; gtxt_flags.enum_waypoints = 1; /* enum all waypoints */ - waypt_disp_all(enum_waypt_cb); - route_disp_all(nullptr, nullptr, enum_waypt_cb); + waypt_disp_all(enum_waypt_cb_lambda); + route_disp_all(nullptr, nullptr, enum_waypt_cb_lambda); gtxt_flags.enum_waypoints = 0; if (waypoints > 0) { wpt_a_ct = 0; wpt_a = new const Waypoint*[waypoints] {}; - waypt_disp_all(enum_waypt_cb); - route_disp_all(nullptr, nullptr, enum_waypt_cb); + waypt_disp_all(enum_waypt_cb_lambda); + route_disp_all(nullptr, nullptr, enum_waypt_cb_lambda); auto sort_waypt_lambda = [](const Waypoint* wa, const Waypoint* wb)->bool { return wa->shortname.compare(wb->shortname, Qt::CaseInsensitive) < 0; }; @@ -835,10 +778,11 @@ garmin_txt_write() route_idx = 0; route_info = new PathInfo[route_count()]; routepoints = 0; - route_disp_all(prework_hdr_cb, prework_tlr_cb, prework_wpt_cb); + route_disp_all(prework_hdr_cb_lambda, prework_tlr_cb_lambda, prework_wpt_cb_lambda); + if (routepoints > 0) { route_idx = 0; - route_disp_all(route_disp_hdr_cb, route_disp_tlr_cb, route_disp_wpt_cb); + route_disp_all(route_disp_hdr_cb_lambda, route_disp_tlr_cb_lambda, route_disp_wpt_cb_lambda); } delete[] route_info; route_info = nullptr; @@ -847,11 +791,11 @@ garmin_txt_write() route_idx = 0; route_info = new PathInfo[track_count()]; routepoints = 0; - track_disp_all(prework_hdr_cb, prework_tlr_cb, prework_wpt_cb); + track_disp_all(prework_hdr_cb_lambda, prework_tlr_cb_lambda, prework_wpt_cb_lambda); if (routepoints > 0) { route_idx = 0; - track_disp_all(track_disp_hdr_cb, track_disp_tlr_cb, track_disp_wpt_cb); + track_disp_all(track_disp_hdr_cb_lambda, track_disp_tlr_cb_lambda, track_disp_wpt_cb_lambda); } delete[] route_info; } @@ -860,8 +804,8 @@ garmin_txt_write() /* helpers */ -static void -free_headers() +void +GarminTxtFormat::free_headers() { std::for_each(header_mapping_info.begin(), header_mapping_info.end(), [](auto& list)->void { list.clear(); }); @@ -870,8 +814,8 @@ free_headers() // Super simple attempt to convert strftime/strptime spec to Qt spec. // This misses a LOT of cases and vagaries, but the reality is that we // see very few date formats here. -static QString -strftime_to_timespec(const char* s) +QString +GarminTxtFormat::strftime_to_timespec(const char* s) { QString q; int l = strlen(s); @@ -944,15 +888,15 @@ strftime_to_timespec(const char* s) /* data parsers */ -static QDateTime -parse_date_and_time(const QString& str) +QDateTime +GarminTxtFormat::parse_date_and_time(const QString& str) { QString timespec = strftime_to_timespec(CSTR(date_time_format)); return QDateTime::fromString(QString(str).trimmed(), timespec); } -static uint16_t -parse_categories(const QString& str) +uint16_t +GarminTxtFormat::parse_categories(const QString& str) const { uint16_t res = 0; @@ -970,8 +914,8 @@ parse_categories(const QString& str) return res; } -static bool -parse_temperature(const QString& str, double* temperature) +bool +GarminTxtFormat::parse_temperature(const QString& str, double* temperature) const { double value; unsigned char unit; @@ -999,8 +943,8 @@ parse_temperature(const QString& str, double* temperature) return false; } -static void -parse_header(const QStringList& lineparts) +void +GarminTxtFormat::parse_header(const QStringList& lineparts) { header_column_names.clear(); for (const auto& name : lineparts) { @@ -1008,8 +952,8 @@ parse_header(const QStringList& lineparts) } } -static bool -parse_display(const QString& str, int* val) +bool +GarminTxtFormat::parse_display(const QString& str, int* val) const { if (str.isEmpty()) { return false; @@ -1025,8 +969,8 @@ parse_display(const QString& str, int* val) return false; } -static void -bind_fields(const header_type ht) +void +GarminTxtFormat::bind_fields(const header_type ht) { if ((grid_index < 0) || (datum_index < 0)) { fatal(MYNAME ": Incomplete or invalid file header!"); @@ -1058,8 +1002,8 @@ bind_fields(const header_type ht) header_column_names.clear(); } -static void -parse_grid(const QStringList& lineparts) +void +GarminTxtFormat::parse_grid(const QStringList& lineparts) { if (lineparts.empty()) { fatal(MYNAME ": Missing grid headline!\n"); @@ -1078,8 +1022,8 @@ parse_grid(const QStringList& lineparts) } } -static void -parse_datum(const QStringList& lineparts) +void +GarminTxtFormat::parse_datum(const QStringList& lineparts) { if (lineparts.empty()) { fatal(MYNAME ": Missing GPS datum headline!\n"); @@ -1089,8 +1033,8 @@ parse_datum(const QStringList& lineparts) datum_index = gt_lookup_datum_index(CSTR(str), MYNAME); } -static void -parse_waypoint(const QStringList& lineparts) +void +GarminTxtFormat::parse_waypoint(const QStringList& lineparts) { int column = -1; @@ -1197,8 +1141,8 @@ parse_waypoint(const QStringList& lineparts) waypt_add(wpt); } -static void -parse_route_header(const QStringList& lineparts) +void +GarminTxtFormat::parse_route_header(const QStringList& lineparts) { int column = -1; @@ -1226,8 +1170,8 @@ parse_route_header(const QStringList& lineparts) current_rte = rte; } -static void -parse_track_header(const QStringList& lineparts) +void +GarminTxtFormat::parse_track_header(const QStringList& lineparts) { int column = -1; @@ -1255,8 +1199,8 @@ parse_track_header(const QStringList& lineparts) } -static void -parse_route_waypoint(const QStringList& lineparts) +void +GarminTxtFormat::parse_route_waypoint(const QStringList& lineparts) { int column = -1; Waypoint* wpt = nullptr; @@ -1287,8 +1231,8 @@ parse_route_waypoint(const QStringList& lineparts) } } -static void -parse_track_waypoint(const QStringList& lineparts) +void +GarminTxtFormat::parse_track_waypoint(const QStringList& lineparts) { int column = -1; @@ -1349,8 +1293,8 @@ parse_track_waypoint(const QStringList& lineparts) /***************************************************************/ -static void -garmin_txt_rd_init(const QString& fname) +void +GarminTxtFormat::rd_init(const QString& fname) { gtxt_flags = {}; @@ -1367,8 +1311,8 @@ garmin_txt_rd_init(const QString& fname) garmin_txt_utc_option(); } -static void -garmin_txt_rd_deinit() +void +GarminTxtFormat::rd_deinit() { free_headers(); header_column_names.clear(); @@ -1379,8 +1323,8 @@ garmin_txt_rd_deinit() date_time_format.squeeze(); } -static void -garmin_txt_read() +void +GarminTxtFormat::read() { QString buff; @@ -1424,27 +1368,4 @@ garmin_txt_read() } } - -/* - * The file encoding is windows-1252. - * Conversion between windows-1252 and utf-16 is handled by the stream. - * Conversion between utf-16 and utf-8 is handled by this format. - * Let main know char strings have already been converted to utf-8 - * so it doesn't attempt to re-convert any char strings including gmsd data. - */ - -ff_vecs_t garmin_txt_vecs = { - ff_type_file, - FF_CAP_RW_ALL, - garmin_txt_rd_init, - garmin_txt_wr_init, - garmin_txt_rd_deinit, - garmin_txt_wr_deinit, - garmin_txt_read, - garmin_txt_write, - nullptr, - &garmin_txt_args, - NULL_POS_OPS -}; - #endif // CSVFMTS_ENABLED diff --git a/garmin_txt.h b/garmin_txt.h new file mode 100644 index 000000000..82346a387 --- /dev/null +++ b/garmin_txt.h @@ -0,0 +1,203 @@ +/* + + Support for MapSource Text Export (Tab delimited) files. + + Copyright (C) 2006 Olaf Klein, o.b.klein@gpsbabel.org + Copyright (C) 2004-2022 Robert Lipe, robertlipe+source@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ +#ifndef GARMIN_TXT_H_INCLUDED_ +#define GARMIN_TXT_H_INCLUDED_ + +#if CSVFMTS_ENABLED + +#include // for array +#include // for uint16_t +#include // for time_t +#include // for pair + +#include // for QDateTime +#include // for QList +#include // for QString +#include // for QStringList +#include // for QVector + +#include "defs.h" +#include "format.h" // for Format +#include "src/core/textstream.h" // for TextStream + + +class GarminTxtFormat : public Format +{ +public: + QVector* get_args() override + { + return &garmin_txt_args; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + return FF_CAP_RW_ALL; + } + + void rd_init(const QString& fname) override; + void read() override; + void rd_deinit() override; + void wr_init(const QString& fname) override; + void write() override; + void wr_deinit() override; + +private: + /* Constants */ + + static constexpr double kGarminUnknownAlt = 1.0e25; + static constexpr char kDefaultDateFormat[] = "dd/mm/yyyy"; + static constexpr char kDefaultTimeFormat[] = "HH:mm:ss"; + + static const QVector headers; + + /* Types */ + + struct gtxt_flags_t { + unsigned int metric:1; + unsigned int celsius:1; + unsigned int utc:1; + unsigned int enum_waypoints:1; + unsigned int route_header_written:1; + unsigned int track_header_written:1; + }; + + enum header_type { + waypt_header = 0, + rtept_header, + trkpt_header, + route_header, + track_header, + unknown_header + }; + + class PathInfo + { + public: + double length {0}; + time_t start {0}; + time_t time {0}; + double speed {0}; + double total {0}; + int count {0}; + const Waypoint* prev_wpt {nullptr}; + const Waypoint* first_wpt {nullptr}; + const Waypoint* last_wpt {nullptr}; + }; + + /* Member Functions */ + + static bool is_valid_alt(double alt); + static const char* get_option_val(const char* option, const char* def); + void init_date_and_time_format(); + void convert_datum(const Waypoint* wpt, double* dest_lat, double* dest_lon) const; + void enum_waypt_cb(const Waypoint* wpt); + void prework_hdr_cb(const route_head* unused); + void prework_tlr_cb(const route_head* unused); + void prework_wpt_cb(const Waypoint* wpt); + void print_position(const Waypoint* wpt); + void print_date_and_time(time_t time, bool time_only); + void print_categories(uint16_t categories); + void print_course(const Waypoint* A, const Waypoint* B); + void print_distance(double distance, bool no_scale, bool with_tab, int decis); + void print_speed(double distance, time_t time); + void print_temperature(float temperature); + void print_string(const char* fmt, const QString& string); + void write_waypt(const Waypoint* wpt); + void route_disp_hdr_cb(const route_head* rte); + void route_disp_tlr_cb(const route_head* unused); + void route_disp_wpt_cb(const Waypoint* wpt); + void track_disp_hdr_cb(const route_head* track); + void track_disp_tlr_cb(const route_head* unused); + void track_disp_wpt_cb(const Waypoint* wpt); + void garmin_txt_utc_option(); + void garmin_txt_adjust_time(QDateTime& dt) const; + void free_headers(); + static QString strftime_to_timespec(const char* s); + QDateTime parse_date_and_time(const QString& str); + uint16_t parse_categories(const QString& str) const; + bool parse_temperature(const QString& str, double* temperature) const; + void parse_header(const QStringList& lineparts); + bool parse_display(const QString& str, int* val) const; + void bind_fields(header_type ht); + void parse_grid(const QStringList& lineparts); + void parse_datum(const QStringList& lineparts); + void parse_waypoint(const QStringList& lineparts); + void parse_route_header(const QStringList& lineparts); + void parse_track_header(const QStringList& lineparts); + void parse_route_waypoint(const QStringList& lineparts); + void parse_track_waypoint(const QStringList& lineparts); + + /* Data Members */ + + gpsbabel::TextStream* fin = nullptr; + gpsbabel::TextStream* fout = nullptr; + route_head* current_trk{}; + route_head* current_rte{}; + int waypoints{}; + int routepoints{}; + const Waypoint** wpt_a{}; + int wpt_a_ct{}; + grid_type grid_index{}; + int datum_index{}; + const char* datum_str{}; + int current_line{}; + QString date_time_format; + int precision = 3; + time_t utc_offs = 0; + gtxt_flags_t gtxt_flags{}; + + std::array>, unknown_header> header_mapping_info; + QStringList header_column_names; + + char* opt_datum = nullptr; + char* opt_dist = nullptr; + char* opt_temp = nullptr; + char* opt_date_format = nullptr; + char* opt_time_format = nullptr; + char* opt_precision = nullptr; + char* opt_utc = nullptr; + char* opt_grid = nullptr; + + QVector garmin_txt_args = { + {"date", &opt_date_format, "Read/Write date format (i.e. yyyy/mm/dd)", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, + {"datum", &opt_datum, "GPS datum (def. WGS 84)", "WGS 84", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, + {"dist", &opt_dist, "Distance unit [m=metric, s=statute]", "m", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, + {"grid", &opt_grid, "Write position using this grid.", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, + {"prec", &opt_precision, "Precision of coordinates", "3", ARGTYPE_INT, ARG_NOMINMAX, nullptr}, + {"temp", &opt_temp, "Temperature unit [c=Celsius, f=Fahrenheit]", "c", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, + {"time", &opt_time_format, "Read/Write time format (i.e. HH:mm:ss xx)", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, + {"utc", &opt_utc, "Write timestamps with offset x to UTC time", nullptr, ARGTYPE_INT, "-23", "+23", nullptr}, + }; + + PathInfo* route_info{}; + int route_idx{}; + PathInfo* cur_info{}; +}; + +#endif // CSVFMTS_ENABLED +#endif // GARMIN_TXT_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index a963531f8..0db4b44ad 100644 --- a/vecs.cc +++ b/vecs.cc @@ -46,6 +46,7 @@ #include "garmin.h" // for GarminFormat #include "garmin_fit.h" // for GarminFitFormat #include "garmin_gpi.h" // for GarminGPIFormat +#include "garmin_txt.h" // for GarminTxtFormat #include "garmin_xt.h" // for GarminXTFormat #include "gbversion.h" // for WEB_DOC_DIR #include "gdb.h" // for GdbFormat @@ -83,18 +84,11 @@ extern ff_vecs_t geo_vecs; extern ff_vecs_t ozi_vecs; #if MAXIMAL_ENABLED -extern ff_vecs_t gpl_vecs; extern ff_vecs_t mtk_vecs; extern ff_vecs_t mtk_fvecs; extern ff_vecs_t mtk_m241_vecs; extern ff_vecs_t mtk_m241_fvecs; #endif // MAXIMAL_ENABLED -#if MAXIMAL_ENABLED -#if CSVFMTS_ENABLED -extern ff_vecs_t garmin_txt_vecs; -#endif // CSVFMTS_ENABLED -extern ff_vecs_t ggv_log_vecs; -#endif // MAXIMAL_ENABLED #define MYNAME "vecs" @@ -138,7 +132,7 @@ struct Vecs::Impl { UnicsvFormat unicsv_fmt; GtmFormat gtm_fmt; #if CSVFMTS_ENABLED - LegacyFormat garmin_txt_fmt {garmin_txt_vecs}; + GarminTxtFormat garmin_txt_fmt; #endif // CSVFMTS_ENABLED GtrnctrFormat gtc_fmt; GarminGPIFormat garmin_gpi_fmt; From 11592cdfeaa33428d290e2e8a9016b6486e2a7a7 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:18:04 -0700 Subject: [PATCH 049/132] convert ozi to Format class. (#1232) * convert ozi to Format class. There is a subtle difference in the writer, the index is now reset for every invocation. This only matters if the writer is used more than once. I believe this was the intent. * fool with QIODevice and it's inheritence of QIODeviceBase. --- CMakeLists.txt | 1 + ozi.cc | 248 ++++++++++++++++--------------------------------- ozi.h | 198 +++++++++++++++++++++++++++++++++++++++ vecs.cc | 4 +- 4 files changed, 280 insertions(+), 171 deletions(-) create mode 100644 ozi.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3308221d2..1c01b45d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,6 +233,7 @@ set(HEADERS mkshort.h nmea.h osm.h + ozi.h qstarz_bl_1000.h random.h session.h diff --git a/ozi.cc b/ozi.cc index 74e33262a..d1ab73aa9 100644 --- a/ozi.cc +++ b/ozi.cc @@ -36,6 +36,8 @@ */ +#include "ozi.h" + #include // for tolower #include // for lround @@ -43,18 +45,20 @@ #include // for operator==, QChar #include // for QFile #include // for QFileInfo -#include // for operator|, QIODevice::WriteOnly, QIODevice::ReadOnly, QIODevice, QIODevice::OpenModeFlag -#include // for QString +#include // for QFlags +#include // for operator&, QIODevice +#include // for QList, QList<>::const_iterator +#include // for QString, operator== #include // for QStringList +#include // for qMakeStringPrivate, QStringLiteral #include // for QTextStream, operator<<, qSetRealNumberPrecision, QTextStream::FixedNotation -#include // for QVector #include // for CaseInsensitive #include // for qPrintable #include "defs.h" #include "csv_util.h" // for csv_stringclean -#include "formspec.h" // for FsChainAdd, FsChainFind, kFsOzi, FormatSpecificData -#include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_WGS84_M +#include "formspec.h" // for FormatSpecificDataList, kFsOzi +#include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M #include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime #include "src/core/textstream.h" // for TextStream @@ -64,101 +68,8 @@ #define BADCHARS ",\r\n" #define DAYS_SINCE_1990 25569 -struct ozi_fsdata : FormatSpecificData { - ozi_fsdata() : FormatSpecificData(kFsOzi) {} - - ozi_fsdata* clone() const override - { - return new ozi_fsdata(*this); - } - - int fgcolor{0}; - int bgcolor{65535}; -}; - -static gpsbabel::TextStream* stream = nullptr; - -static MakeShort* mkshort_handle; -static route_head* trk_head; -static route_head* rte_head; - -static int track_out_count; -static int route_out_count; -static int route_wpt_count; -static int new_track; - -static char* snlenopt = nullptr; -static char* snwhiteopt = nullptr; -static char* snupperopt = nullptr; -static char* snuniqueopt = nullptr; -static char* wptfgcolor = nullptr; -static char* wptbgcolor = nullptr; -static char* pack_opt = nullptr; -static int datum; -static char* proximityarg = nullptr; -static double proximity; -static char* altunit_opt; -static char* proxunit_opt; -static char altunit; -static char proxunit; -static double alt_scale; -static double prox_scale; -static char* opt_codec; - -static -QVector ozi_args = { - { - "pack", &pack_opt, "Write all tracks into one file", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "snlen", &snlenopt, "Max synthesized shortname length", - "32", ARGTYPE_INT, "1", nullptr, nullptr - }, - { - "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "snupper", &snupperopt, "UPPERCASE synth. shortnames", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "snunique", &snuniqueopt, "Make synth. shortnames unique", - nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "wptfgcolor", &wptfgcolor, "Waypoint foreground color", - "black", ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, - { - "wptbgcolor", &wptbgcolor, "Waypoint background color", - "yellow", ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, - { - "proximity", &proximityarg, "Proximity distance", - "0", ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, - { - "altunit", &altunit_opt, "Unit used in altitude values", - "feet", ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, - { - "proxunit", &proxunit_opt, "Unit used in proximity values", - "miles", ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, - { - "codec", &opt_codec, "codec to use for reading and writing strings (default windows-1252)", - "windows-1252", ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, -}; - -static gpsdata_type ozi_objective; - -static QString ozi_ofname; - -static void -ozi_open_io(const QString& fname, QIODevice::OpenModeFlag mode) +void +OziFormat::ozi_open_io(const QString& fname, QIODevice::OpenModeFlag mode) { stream = new gpsbabel::TextStream; stream->open(fname, mode, MYNAME, opt_codec); @@ -168,8 +79,8 @@ ozi_open_io(const QString& fname, QIODevice::OpenModeFlag mode) } } -static void -ozi_close_io() +void +OziFormat::ozi_close_io() { if (!stream) { return; @@ -179,9 +90,8 @@ ozi_close_io() stream = nullptr; } -static -ozi_fsdata* -ozi_alloc_fsdata() +OziFormat::ozi_fsdata* +OziFormat::ozi_alloc_fsdata() { auto* fsdata = new ozi_fsdata; @@ -192,8 +102,8 @@ ozi_alloc_fsdata() return fsdata; } -static QString -ozi_get_time_str(const Waypoint* waypointp) +QString +OziFormat::ozi_get_time_str(const Waypoint* waypointp) { if (waypointp->creation_time.isValid()) { double time = (waypt_time(waypointp) / SECONDS_PER_DAY) + DAYS_SINCE_1990; @@ -202,8 +112,8 @@ ozi_get_time_str(const Waypoint* waypointp) return QString(""); } -static void -ozi_set_time_str(const QString& str, Waypoint* waypointp) +void +OziFormat::ozi_set_time_str(const QString& str, Waypoint* waypointp) { double ozi_time = str.toDouble(); @@ -213,8 +123,8 @@ ozi_set_time_str(const QString& str, Waypoint* waypointp) } } -static void -ozi_convert_datum(Waypoint* wpt) +void +OziFormat::ozi_convert_datum(Waypoint* wpt) const { if (datum != kDautmWGS84) { double lat, lon, alt; @@ -225,8 +135,8 @@ ozi_convert_datum(Waypoint* wpt) } } -static void -ozi_openfile(const QString& fname) +void +OziFormat::ozi_openfile(const QString& fname) { const char* ozi_extensions[] = {nullptr, "plt", "wpt", "rte"}; @@ -266,8 +176,8 @@ ozi_openfile(const QString& fname) ozi_open_io(tmpname, QFile::WriteOnly); } -static void -ozi_track_hdr(const route_head* rte) +void +OziFormat::ozi_track_hdr(const route_head* rte) { if ((! pack_opt) || (track_out_count == 0)) { ozi_openfile(ozi_ofname); @@ -285,8 +195,8 @@ ozi_track_hdr(const route_head* rte) new_track = 1; } -static void -ozi_track_disp(const Waypoint* waypointp) +void +OziFormat::ozi_track_disp(const Waypoint* waypointp) { double alt; @@ -307,14 +217,20 @@ ozi_track_disp(const Waypoint* waypointp) new_track = 0; } -static void -ozi_track_pr() +void +OziFormat::ozi_track_pr() { - track_disp_all(ozi_track_hdr, nullptr, ozi_track_disp); + auto ozi_track_hdr_lambda = [this](const route_head* rte)->void { + ozi_track_hdr(rte); + }; + auto ozi_track_disp_lambda = [this](const Waypoint* waypointp)->void { + ozi_track_disp(waypointp); + }; + track_disp_all(ozi_track_hdr_lambda, nullptr, ozi_track_disp_lambda); } -static void -ozi_route_hdr(const route_head* rte) +void +OziFormat::ozi_route_hdr(const route_head* rte) { /* prologue on 1st pass only */ if (route_out_count == 0) { @@ -344,8 +260,8 @@ ozi_route_hdr(const route_head* rte) << rte->rte_desc << ",\r\n"; } -static void -ozi_route_disp(const Waypoint* waypointp) +void +OziFormat::ozi_route_disp(const Waypoint* waypointp) { route_wpt_count++; @@ -390,14 +306,20 @@ ozi_route_disp(const Waypoint* waypointp) } -static void -ozi_route_pr() +void +OziFormat::ozi_route_pr() { - route_disp_all(ozi_route_hdr, nullptr, ozi_route_disp); + auto ozi_route_hdr_lambda = [this](const route_head* rte)->void { + ozi_route_hdr(rte); + }; + auto ozi_route_disp_lambda = [this](const Waypoint* waypointp)->void { + ozi_route_disp(waypointp); + }; + route_disp_all(ozi_route_hdr_lambda, nullptr, ozi_route_disp_lambda); } -static void -ozi_init_units(const int direction) /* 0 = in; 1 = out */ +void +OziFormat::ozi_init_units(const int direction) /* 0 = in; 1 = out */ { altunit = tolower(*altunit_opt); switch (altunit) { @@ -433,22 +355,22 @@ ozi_init_units(const int direction) /* 0 = in; 1 = out */ } } -static void -rd_init(const QString& fname) +void +OziFormat::rd_init(const QString& fname) { ozi_open_io(fname, QFile::ReadOnly); ozi_init_units(0); } -static void -rd_deinit() +void +OziFormat::rd_deinit() { ozi_close_io(); } -static void -wr_init(const QString& fname) +void +OziFormat::wr_init(const QString& fname) { /* At this point, we have no idea whether we'll be writing waypoint, @@ -484,8 +406,8 @@ wr_init(const QString& fname) parse_distance(proximityarg, &proximity, 1 / prox_scale, MYNAME); } -static void -wr_deinit() +void +OziFormat::wr_deinit() { ozi_close_io(); ozi_ofname.clear(); @@ -494,8 +416,8 @@ wr_deinit() mkshort_handle = nullptr; } -static void -ozi_parse_waypt(int field, const QString& str, Waypoint* wpt_tmp, ozi_fsdata* fsdata) +void +OziFormat::ozi_parse_waypt(int field, const QString& str, Waypoint* wpt_tmp, ozi_fsdata* fsdata) const { double alt; @@ -589,8 +511,8 @@ ozi_parse_waypt(int field, const QString& str, Waypoint* wpt_tmp, ozi_fsdata* fs } } -static void -ozi_parse_track(int field, const QString& str, Waypoint* wpt_tmp, char* trk_name) +void +OziFormat::ozi_parse_track(int field, const QString& str, Waypoint* wpt_tmp, char* trk_name) { if (str.isEmpty()) { return; @@ -634,8 +556,8 @@ ozi_parse_track(int field, const QString& str, Waypoint* wpt_tmp, char* trk_name } } -static void -ozi_parse_routepoint(int field, const QString& str, Waypoint* wpt_tmp) +void +OziFormat::ozi_parse_routepoint(int field, const QString& str, Waypoint* wpt_tmp) { if (str.isEmpty()) { return; @@ -694,8 +616,8 @@ ozi_parse_routepoint(int field, const QString& str, Waypoint* wpt_tmp) } } -static void -ozi_parse_routeheader(int field, const QString& str) +void +OziFormat::ozi_parse_routeheader(int field, const QString& str) { switch (field) { @@ -724,8 +646,8 @@ ozi_parse_routeheader(int field, const QString& str) } } -static void -data_read() +void +OziFormat::read() { QString buff; char* trk_name = nullptr; @@ -853,10 +775,9 @@ data_read() } } -static void -ozi_waypt_pr(const Waypoint* wpt) +void +OziFormat::ozi_waypt_pr(const Waypoint* wpt, int index) { - static int index = 0; double alt; QString description; QString shortname; @@ -901,8 +822,6 @@ ozi_waypt_pr(const Waypoint* wpt) description = csv_stringclean(wpt->description, BADCHARS); } - index++; - if (wpt->icon_descr.toInt()) { icon = wpt->icon_descr.toInt(); } @@ -931,8 +850,8 @@ ozi_waypt_pr(const Waypoint* wpt) } } -static void -data_write() +void +OziFormat::write() { if (waypt_count()) { track_out_count = route_out_count = 0; @@ -942,7 +861,12 @@ data_write() << "WGS 84\r\n" << "Reserved 2\r\n" << "Reserved 3\r\n"; - waypt_disp_all(ozi_waypt_pr); + + int index = 0; + auto ozi_waypt_pr_lambda = [this, &index](const Waypoint* waypointp)->void { + ozi_waypt_pr(waypointp, ++index); + }; + waypt_disp_all(ozi_waypt_pr_lambda); } if (track_count()) { @@ -957,17 +881,3 @@ data_write() } } - -ff_vecs_t ozi_vecs = { - ff_type_file, - FF_CAP_RW_ALL, - rd_init, - wr_init, - rd_deinit, - wr_deinit, - data_read, - data_write, - nullptr, - &ozi_args, - NULL_POS_OPS -}; diff --git a/ozi.h b/ozi.h new file mode 100644 index 000000000..bcb8a4062 --- /dev/null +++ b/ozi.h @@ -0,0 +1,198 @@ +/* + OziExplorer Waypoints/Tracks/Routes + Comma Delimited + + As described in OziExplorer Help File + + Copyright (C) 2002-2005 Robert Lipe, robertlipe+source@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Reference: + https://www.oziexplorer4.com/eng/help/fileformats.html + + According to the OZI Explorer developer: + "There is no specified character set, it defaults to whatever 8 bit + character set "Windows" defaults to - normally CP-1252 but can vary + depending on Windows regional settings." + + According to the reference, for some text fields: + "comma's not allowed in text fields, character 209 can be used instead + and a comma will be substituted." + This could work for windows-1252, but not for utf-8. + We don't support any special handling for character 209. + + */ +#ifndef OZI_H_INCLUDED_ +#define OZI_H_INCLUDED_ + +#include // for QIODeviceBase, QIODeviceBase::OpenModeFlag +#include // for QString +#include // for QVector + +#include "defs.h" +#include "format.h" // for Format +#include "formspec.h" // for FormatSpecificData, kFsOzi +#include "mkshort.h" // for MakeShort +#include "src/core/textstream.h" // for TextStream + + +class OziFormat : public Format +{ +public: + QVector* get_args() override + { + return &ozi_args; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + return FF_CAP_RW_ALL; + } + + void rd_init(const QString& fname) override; + void read() override; + void rd_deinit() override; + void wr_init(const QString& fname) override; + void write() override; + void wr_deinit() override; + +private: + /* Types */ + + struct ozi_fsdata : FormatSpecificData { + ozi_fsdata() : FormatSpecificData(kFsOzi) {} + + ozi_fsdata* clone() const override + { + return new ozi_fsdata(*this); + } + + int fgcolor{0}; + int bgcolor{65535}; + }; + + /* Member Functions */ + + void ozi_open_io(const QString& fname, QIODevice::OpenModeFlag mode); + void ozi_close_io(); + ozi_fsdata* ozi_alloc_fsdata(); + static QString ozi_get_time_str(const Waypoint* waypointp); + static void ozi_set_time_str(const QString& str, Waypoint* waypointp); + void ozi_convert_datum(Waypoint* wpt) const; + void ozi_openfile(const QString& fname); + void ozi_track_hdr(const route_head* rte); + void ozi_track_disp(const Waypoint* waypointp); + void ozi_track_pr(); + void ozi_route_hdr(const route_head* rte); + void ozi_route_disp(const Waypoint* waypointp); + void ozi_route_pr(); + void ozi_init_units(int direction); + void ozi_parse_waypt(int field, const QString& str, Waypoint* wpt_tmp, ozi_fsdata* fsdata) const; + void ozi_parse_track(int field, const QString& str, Waypoint* wpt_tmp, char* trk_name); + static void ozi_parse_routepoint(int field, const QString& str, Waypoint* wpt_tmp); + void ozi_parse_routeheader(int field, const QString& str); + void data_read(); + void ozi_waypt_pr(const Waypoint* wpt, int index); + void data_write(); + + /* Data Members */ + + gpsbabel::TextStream* stream = nullptr; + + MakeShort* mkshort_handle{}; + route_head* trk_head{}; + route_head* rte_head{}; + + int track_out_count{}; + int route_out_count{}; + int route_wpt_count{}; + int new_track{}; + + char* snlenopt = nullptr; + char* snwhiteopt = nullptr; + char* snupperopt = nullptr; + char* snuniqueopt = nullptr; + char* wptfgcolor = nullptr; + char* wptbgcolor = nullptr; + char* pack_opt = nullptr; + int datum{}; + char* proximityarg = nullptr; + double proximity{}; + char* altunit_opt{}; + char* proxunit_opt{}; + char altunit{}; + char proxunit{}; + double alt_scale{}; + double prox_scale{}; + char* opt_codec{}; + + QVector ozi_args = { + { + "pack", &pack_opt, "Write all tracks into one file", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "snlen", &snlenopt, "Max synthesized shortname length", + "32", ARGTYPE_INT, "1", nullptr, nullptr + }, + { + "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "snupper", &snupperopt, "UPPERCASE synth. shortnames", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "snunique", &snuniqueopt, "Make synth. shortnames unique", + nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "wptfgcolor", &wptfgcolor, "Waypoint foreground color", + "black", ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + { + "wptbgcolor", &wptbgcolor, "Waypoint background color", + "yellow", ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + { + "proximity", &proximityarg, "Proximity distance", + "0", ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + { + "altunit", &altunit_opt, "Unit used in altitude values", + "feet", ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + { + "proxunit", &proxunit_opt, "Unit used in proximity values", + "miles", ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + { + "codec", &opt_codec, "codec to use for reading and writing strings (default windows-1252)", + "windows-1252", ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + }; + + gpsdata_type ozi_objective{unknown_gpsdata}; + + QString ozi_ofname; +}; +#endif // OZI_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index 0db4b44ad..eb198a7f5 100644 --- a/vecs.cc +++ b/vecs.cc @@ -65,6 +65,7 @@ #include "lowranceusr.h" // for LowranceusrFormat #include "nmea.h" // for NmeaFormat #include "osm.h" // for OsmFormat +#include "ozi.h" // for OziFormat #include "qstarz_bl_1000.h" // for QstarzBL1000Format #include "random.h" // for RandomFormat #include "shape.h" // for ShapeFormat @@ -82,7 +83,6 @@ extern ff_vecs_t geo_vecs; -extern ff_vecs_t ozi_vecs; #if MAXIMAL_ENABLED extern ff_vecs_t mtk_vecs; extern ff_vecs_t mtk_fvecs; @@ -111,7 +111,7 @@ struct Vecs::Impl { GarminFormat garmin_fmt; GdbFormat gdb_fmt; NmeaFormat nmea_fmt; - LegacyFormat ozi_fmt {ozi_vecs}; + OziFormat ozi_fmt; KmlFormat kml_fmt; #if MAXIMAL_ENABLED LowranceusrFormat lowranceusr_fmt; From f844ea26aec175fedb6d2e7a7a00826cd00da898 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:42:53 -0700 Subject: [PATCH 050/132] convert mtk formats to Format class. (#1226) --- CMakeLists.txt | 1 + mtk_logger.cc | 367 ++++++------------------------------------ mtk_logger.h | 423 +++++++++++++++++++++++++++++++++++++++++++++++++ vecs.cc | 17 +- 4 files changed, 477 insertions(+), 331 deletions(-) create mode 100644 mtk_logger.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c01b45d9..d96f2d5c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,7 @@ set(HEADERS igc.h lowranceusr.h mkshort.h + mtk_logger.h nmea.h osm.h ozi.h diff --git a/mtk_logger.cc b/mtk_logger.cc index 1838a018d..ac7483593 100644 --- a/mtk_logger.cc +++ b/mtk_logger.cc @@ -52,74 +52,37 @@ */ +#include "mtk_logger.h" - -#include "defs.h" -#include "gbfile.h" /* used for csv output */ -#include "gbser.h" -#include -#include -#include -#include -#include -#include +#include // for isdigit +#include // for va_end, va_start +#include // for memcmp, memset, strncmp, strlen, memmove, strchr, strcpy, strerror, strstr #if __WIN32__ -#include +#include // for _chsize #else -#include +#include // for ftruncate #endif -#define MYNAME "mtk_logger" +#include // for QByteArray +#include // for QChar +#include // for QDateTime +#include // for QDir +#include // for QFile +#include // for QLatin1Char +#include // for qMakeStringPrivate, QStringLiteral +#include // for QThread +#include // for qPrintable, UTC +#include // for errno, ERANGE +#include // for fabs +#include // for strtoul, strtol + +#include "defs.h" +#include "gbfile.h" // for gbfprintf, gbfputc, gbfputs, gbfclose, gbfopen, gbfile +#include "gbser.h" // for gbser_read_line, gbser_set_port, gbser_OK, gbser_deinit, gbser_init, gbser_print, gbser_TIMEOUT +#include "src/core/datetime.h" // for DateTime -/* MTK packet id's -- currently unused... */ -enum MTK_NMEA_PACKET { - PMTK_TEST = 0, - PMTK_ACK = 1, - PMTK_SYS_MSG = 10, - PMTK_CMD_HOT_START = 101, - PMTK_CMD_WARM_START = 102, - PMTK_CMD_COLD_START = 103, - PMTK_CMD_FULL_COLD_START = 104, - PMTK_CMD_LOG = 182, /* Data log commands */ - PMTK_SET_NMEA_BAUDRATE = 251, - PMTK_API_SET_DGPS_MODE = 301, - PMTK_API_SET_SBAS_ENABLED = 313, - PMTK_API_SET_NMEA_OUTPUT = 314, - PMTK_API_SET_PWR_SAV_MODE = 320, - PMTK_API_SET_DATUM = 330, - PMTK_API_SET_DATUM_ADVANCE = 331, - PMTK_API_SET_USER_OPTION = 390, - PMTK_API_Q_FIX_CTL = 400, - PMTK_API_Q_DGPS_MODE = 401, - PMTK_API_Q_SBAS_ENABLED = 413, - PMTK_API_Q_NMEA_OUTPUT = 414, - PMTK_API_Q_PWR_SAV_MODE = 420, - PMTK_API_Q_DATUM = 430, - PMTK_API_Q_DATUM_ADVANCE = 431, - PMTK_API_GET_USER_OPTION = 490, - PMTK_DT_FIX_CTL = 500, - PMTK_DT_DGPS_MODE = 501, - PMTK_DT_SBAS_ENABLED = 513, - PMTK_DT_NMEA_OUTPUT = 514, - PMTK_DT_PWR_SAV_MODE = 520, - PMTK_DT_DATUM = 530, - PMTK_DT_FLASH_USER_OPTION = 590, - PMTK_Q_VERSION = 604, - PMTK_Q_RELEASE = 605, - PMTK_DT_VERSION = 704, - PMTK_DT_RELEASE = 705 -}; - -static const unsigned char LOG_RST[16] = { - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, /* start marker */ - 0x00, 0x00, 0x00, 0x00, 0x00, /* data */ - 0xbb, 0xbb, 0xbb, 0xbb -}; /* end marker */ - -static const char* MTK_ACK[] = { /* Flags returned from PMTK001 ack packet */ - "Invalid packet", "Unsupported packet type", - "Valid packet but action failed", "Valid packet, action success" -}; + +#define MYNAME "mtk_logger" #define MTK_EVT_BITMASK (1<<0x02) #define MTK_EVT_PERIOD (1<<0x03) @@ -128,160 +91,14 @@ static const char* MTK_ACK[] = { /* Flags returned from PMTK001 ack packet */ #define MTK_EVT_START (1<<0x07) #define MTK_EVT_WAYPT (1<<0x10) /* Holux waypoint follows... */ -/* *************************************** */ - -/* Data id, type, sizes used by MTK chipset - don't touch.... */ -enum { - UTC = 0, - VALID, - LATITUDE, - LONGITUDE, - HEIGHT, - SPEED, - HEADING, - DSTA, - DAGE, - PDOP, - HDOP, - VDOP, - NSAT, - SID, - ELEVATION, - AZIMUTH, - SNR, - RCR, - MILLISECOND, - DISTANCE, -} /* DATA_TYPES */; - -static struct log_type { - int id; - int size; - const char* name; -} log_type[32] = { - { 0, 4, "UTC" }, - { 1, 2, "VALID" }, - { 2, 8, "LATITUDE,N/S"}, - { 3, 8, "LONGITUDE,E/W"}, - { 4, 4, "HEIGHT" }, - { 5, 4, "SPEED" }, - { 6, 4, "HEADING" }, - { 7, 2, "DSTA" }, - { 8, 4, "DAGE" }, - { 9, 2, "PDOP" }, - { 10, 2, "HDOP"}, - { 11, 2, "VDOP"}, - { 12, 2, "NSAT (USED/VIEW)"}, - { 13, 4, "SID",}, - { 14, 2, "ELEVATION" }, - { 15, 2, "AZIMUTH" }, - { 16, 2, "SNR"}, - { 17, 2, "RCR"}, - { 18, 2, "MILLISECOND"}, - { 19, 8, "DISTANCE" }, - { 20, 0, nullptr}, -}; - -struct sat_info { - char id, used; - short elevation, azimut, snr; -}; - -struct data_item { - time_t timestamp; - short valid; - double lat; - double lon; - float height; - float speed; - float heading; - short dsta; // differential station id - float dage; // differential data age - float pdop, hdop, vdop; - char sat_used, sat_view, sat_count; - short rcr; - unsigned short timestamp_ms; - double distance; - sat_info sat_data[32]; -}; - -struct mtk_loginfo { - unsigned int bitmask; - int logLen; - int period, distance, speed; /* in 10:ths of sec, m, km/h */ - int track_event; -}; - -/* *************************************** */ - -/* MTK chip based devices with different baudrate, tweaks, ... */ -enum MTK_DEVICE_TYPE { - MTK_LOGGER, - HOLUX_M241, - HOLUX_GR245 -}; - #define TIMEOUT 1500 #define MTK_BAUDRATE 115200 #define MTK_BAUDRATE_M241 38400 #define HOLUX245_MASK (1 << 27) -static void* fd; /* serial fd */ -static FILE* fl; /* bin.file fd */ -static char* port; /* serial port name */ -static char* OPT_erase; /* erase ? command option */ -static char* OPT_erase_only; /* erase_only ? command option */ -static char* OPT_log_enable; /* enable ? command option */ -static char* csv_file; /* csv ? command option */ -static char* OPT_block_size_kb; /* block_size_kb ? command option */ -static MTK_DEVICE_TYPE mtk_device = MTK_LOGGER; - -static mtk_loginfo mtk_info; - -const char LIVE_CHAR[4] = {'-', '\\','|','/'}; - -const char CMD_LOG_DISABLE[]= "$PMTK182,5*20\r\n"; -const char CMD_LOG_ENABLE[] = "$PMTK182,4*21\r\n"; -const char CMD_LOG_FORMAT[] = "$PMTK182,2,2*39\r\n"; -const char CMD_LOG_ERASE[] = "$PMTK182,6,1*3E\r\n"; -const char CMD_LOG_STATUS[] = "$PMTK182,2,7*3C\r\n"; - -static int mtk_log_len(unsigned int bitmask); -static void mtk_rd_init(const QString& fname); -static void file_init(const QString& fname); -static void file_deinit() ; -static void holux245_init(); -static void file_read(); -static int mtk_parse_info(const unsigned char* data, int dataLen); - - -// Arguments for log fetch 'mtk' command.. - -static QVector mtk_sargs = { - { - "erase", &OPT_erase, "Erase device data after download", - "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "erase_only", &OPT_erase_only, "Only erase device data, do not download anything", - "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "log_enable", &OPT_log_enable, "Enable logging after download", - "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr - }, - { - "csv", &csv_file, "MTK compatible CSV output file", - nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, - { - "block_size_kb", &OPT_block_size_kb, "Size of blocks in KB to request from device", - "1", ARGTYPE_INT, "1", "64", nullptr - }, -}; - -[[gnu::format(printf, 2, 3)]] static void dbg(int l, const char* msg, ...) + +void MtkLoggerBase::dbg(int l, const char* msg, ...) { va_list ap; va_start(ap, msg); @@ -298,7 +115,7 @@ static QVector mtk_sargs = { // // It returns a temporary C string - it's totally kludged in to replace // TEMP_DATA_BIN being string constants. -static QString GetTempName(bool backup) +QString MtkLoggerBase::GetTempName(bool backup) { const char kData[]= "data.bin"; const char kDataBackup[]= "data_old.bin"; @@ -307,7 +124,7 @@ static QString GetTempName(bool backup) #define TEMP_DATA_BIN GetTempName(false) #define TEMP_DATA_BIN_OLD GetTempName(true) -static int do_send_cmd(const char* cmd, int cmdLen) +int MtkLoggerBase::do_send_cmd(const char* cmd, int cmdLen) { dbg(6, "Send %s ", cmd); int rc = gbser_print(fd, cmd); @@ -319,7 +136,7 @@ static int do_send_cmd(const char* cmd, int cmdLen) } -static int do_cmd(const char* cmd, const char* expect, char** rslt, time_t timeout_sec) +int MtkLoggerBase::do_cmd(const char* cmd, const char* expect, char** rslt, time_t timeout_sec) { char line[256]; int len; @@ -418,13 +235,13 @@ static int do_cmd(const char* cmd, const char* expect, char** rslt, time_t timeo /******************************************************************************* * %%% global callbacks called by gpsbabel main process %%% * *******************************************************************************/ -static void mtk_rd_init_m241(const QString& fname) +void MtkLoggerBase::mtk_rd_init_m241(const QString& fname) { mtk_device = HOLUX_M241; mtk_rd_init(fname); } -static void mtk_rd_init(const QString& fname) +void MtkLoggerBase::mtk_rd_init(const QString& fname) { int rc; char* model; @@ -474,7 +291,7 @@ static void mtk_rd_init(const QString& fname) xfree(model); } -static void mtk_rd_deinit() +void MtkLoggerBase::mtk_rd_deinit() { if (mtk_device == HOLUX_GR245) { int rc = do_cmd("$PHLX827*31\r\n", "PHLX860*32", nullptr, 10); @@ -489,7 +306,7 @@ static void mtk_rd_deinit() xfree(port); } -static int mtk_erase() +int MtkLoggerBase::mtk_erase() { char* lstatus = nullptr; @@ -526,7 +343,7 @@ static int mtk_erase() return 0; } -static void mtk_read() +void MtkLoggerBase::mtk_read() { char cmd[256]; char* line = nullptr; @@ -795,8 +612,7 @@ static void mtk_read() } -static route_head* trk_head = nullptr; -static int add_trackpoint(int idx, unsigned long bmask, data_item* itm) +int MtkLoggerBase::add_trackpoint(int idx, unsigned long bmask, data_item* itm) { auto* trk = new Waypoint; @@ -917,8 +733,7 @@ static int add_trackpoint(int idx, unsigned long bmask, data_item* itm) /********************** MTK Logger -- CSV output *************************/ -static gbfile* cd; -static void mtk_csv_init(char* csv_fname, unsigned long bitmask) +void MtkLoggerBase::mtk_csv_init(char* csv_fname, unsigned long bitmask) { FILE* cf; @@ -969,7 +784,7 @@ static void mtk_csv_init(char* csv_fname, unsigned long bitmask) gbfprintf(cd, "\n"); } -static void mtk_csv_deinit() +void MtkLoggerBase::mtk_csv_deinit() { if (cd != nullptr) { gbfclose(cd); @@ -978,7 +793,7 @@ static void mtk_csv_deinit() } /* Output a single data line in MTK application compatible format - i.e ignore any locale settings... */ -static int csv_line(gbfile* csvFile, int idx, unsigned long bmask, data_item* itm) +int MtkLoggerBase::csv_line(gbfile* csvFile, int idx, unsigned long bmask, data_item* itm) { const char* fix_str = ""; if (bmask & (1U<= 5 && @@ -1501,7 +1316,7 @@ static int is_holux_string(const unsigned char* data, int dataLen) return 0; } -static void file_read() +void MtkLoggerBase::file_read() { // int i, j, k, bLen; unsigned char buf[512]; @@ -1651,91 +1466,5 @@ static void file_read() } -/**************************************************************************/ -// GPS logger will only handle tracks - neither waypoints or tracks... -// Actually, some of the Holux devices will read waypoints. - -/* ascii is the expected character set */ -/* not fixed, can be changed through command line parameter */ - -ff_vecs_t mtk_vecs = { - ff_type_serial, - { - ff_cap_read /* waypoints */, - ff_cap_read /* tracks */, - ff_cap_none /* routes */ - }, - mtk_rd_init, - nullptr, - mtk_rd_deinit, - nullptr, - mtk_read, - nullptr, - nullptr, - &mtk_sargs, - NULL_POS_OPS -}; - -/* ascii is the expected character set */ -/* not fixed, can be changed through command line parameter */ - -ff_vecs_t mtk_m241_vecs = { - ff_type_serial, - { - ff_cap_none /* waypoints */, - ff_cap_read /* tracks */, - ff_cap_none /* routes */ - }, - mtk_rd_init_m241, - nullptr, - mtk_rd_deinit, - nullptr, - mtk_read, - nullptr, - nullptr, - &mtk_sargs, - NULL_POS_OPS -}; - -/* used for mtk-bin */ - -static QVector mtk_fargs = { - { - "csv", &csv_file, "MTK compatible CSV output file", - nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr - }, -}; - -/* master process: don't convert anything */ - -ff_vecs_t mtk_fvecs = { - ff_type_file, - { ff_cap_read, ff_cap_read, ff_cap_none }, - file_init, - nullptr, - file_deinit, - nullptr, - file_read, - nullptr, - nullptr, - &mtk_fargs, - NULL_POS_OPS -}; - -/* master process: don't convert anything */ - -ff_vecs_t mtk_m241_fvecs = { - ff_type_file, - { ff_cap_read, ff_cap_read, ff_cap_none }, - file_init_m241, - nullptr, - file_deinit, - nullptr, - file_read, - nullptr, - nullptr, - &mtk_fargs, - NULL_POS_OPS -}; /* End file: mtk_logger.c */ /**************************************************************************/ diff --git a/mtk_logger.h b/mtk_logger.h new file mode 100644 index 000000000..f54b8ed08 --- /dev/null +++ b/mtk_logger.h @@ -0,0 +1,423 @@ +/* + Download track data from GPS loggers based in MTK chipset. + + Copyright (C) 2007 Per Borgentun, e4borgen(at)yahoo.com + With lot of inspiration from wbt-200.c + Copyright (C) 2006 Andy Armstrong + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ +/* + -------------------------------------------------------------- + This module will download track data from a MTK chipset based GPS logger. + It will also convert the raw data.bin file to MTK compatible CSV and + gpsbabel output of your choice. + It has been tested with Transystem i-Blue 747 but other devices should + work as well (Qstarz BT-Q1000, iTrek Z1, ...) + + For more info and tweaks on MTK based loggers + + + For info about the used log format: + + + Module updated 2008-2009. Now also handles Holux M-241 and + Holux GR-245 aka. GPSport-245 devices. These devices have small differences + in the log format and use a lower baudrate to transfer the data. + + Example usage:: + # Read from USB port, output trackpoints & waypoints in GPX format + ./gpsbabel -D 2 -t -w -i mtk -f /dev/ttyUSB0 -o gpx -F out.gpx + + # Parse an existing .bin file (data_2007_09_04.bin), output trackpoints as + # both CSV file and GPX, discard points without fix + ./gpsbabel -D 2 -t -i mtk-bin,csv=data__2007_09_04.csv -f data_2007_09_04.bin -x discard,fixnone -o gpx -F out.gpx + + Tip: Check out the -x height,wgs84tomsl filter to correct the altitude. + Todo: + o .... + + */ +#ifndef MTK_LOGGER_H_INCLUDED_ +#define MTK_LOGGER_H_INCLUDED_ + +#include // for FILE +#include // for time_t + +#include // for QString +#include // for QVector + +#include "defs.h" +#include "format.h" // for Format +#include "gbfile.h" // for gbfile + + +class MtkLoggerBase +{ +protected: + /* MTK packet id's -- currently unused... */ + enum MTK_NMEA_PACKET { + PMTK_TEST = 0, + PMTK_ACK = 1, + PMTK_SYS_MSG = 10, + PMTK_CMD_HOT_START = 101, + PMTK_CMD_WARM_START = 102, + PMTK_CMD_COLD_START = 103, + PMTK_CMD_FULL_COLD_START = 104, + PMTK_CMD_LOG = 182, /* Data log commands */ + PMTK_SET_NMEA_BAUDRATE = 251, + PMTK_API_SET_DGPS_MODE = 301, + PMTK_API_SET_SBAS_ENABLED = 313, + PMTK_API_SET_NMEA_OUTPUT = 314, + PMTK_API_SET_PWR_SAV_MODE = 320, + PMTK_API_SET_DATUM = 330, + PMTK_API_SET_DATUM_ADVANCE = 331, + PMTK_API_SET_USER_OPTION = 390, + PMTK_API_Q_FIX_CTL = 400, + PMTK_API_Q_DGPS_MODE = 401, + PMTK_API_Q_SBAS_ENABLED = 413, + PMTK_API_Q_NMEA_OUTPUT = 414, + PMTK_API_Q_PWR_SAV_MODE = 420, + PMTK_API_Q_DATUM = 430, + PMTK_API_Q_DATUM_ADVANCE = 431, + PMTK_API_GET_USER_OPTION = 490, + PMTK_DT_FIX_CTL = 500, + PMTK_DT_DGPS_MODE = 501, + PMTK_DT_SBAS_ENABLED = 513, + PMTK_DT_NMEA_OUTPUT = 514, + PMTK_DT_PWR_SAV_MODE = 520, + PMTK_DT_DATUM = 530, + PMTK_DT_FLASH_USER_OPTION = 590, + PMTK_Q_VERSION = 604, + PMTK_Q_RELEASE = 605, + PMTK_DT_VERSION = 704, + PMTK_DT_RELEASE = 705 + }; + + static constexpr unsigned char LOG_RST[16] = { + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, /* start marker */ + 0x00, 0x00, 0x00, 0x00, 0x00, /* data */ + 0xbb, 0xbb, 0xbb, 0xbb + }; /* end marker */ + + static constexpr const char* MTK_ACK[] = { /* Flags returned from PMTK001 ack packet */ + "Invalid packet", "Unsupported packet type", + "Valid packet but action failed", "Valid packet, action success" + }; + + /* *************************************** */ + + /* Data id, type, sizes used by MTK chipset - don't touch.... */ + enum { + UTC = 0, + VALID, + LATITUDE, + LONGITUDE, + HEIGHT, + SPEED, + HEADING, + DSTA, + DAGE, + PDOP, + HDOP, + VDOP, + NSAT, + SID, + ELEVATION, + AZIMUTH, + SNR, + RCR, + MILLISECOND, + DISTANCE, + } /* DATA_TYPES */; + + struct log_type_t { + int id; + int size; + const char* name; + }; + log_type_t log_type[32] = { + { 0, 4, "UTC" }, + { 1, 2, "VALID" }, + { 2, 8, "LATITUDE,N/S"}, + { 3, 8, "LONGITUDE,E/W"}, + { 4, 4, "HEIGHT" }, + { 5, 4, "SPEED" }, + { 6, 4, "HEADING" }, + { 7, 2, "DSTA" }, + { 8, 4, "DAGE" }, + { 9, 2, "PDOP" }, + { 10, 2, "HDOP"}, + { 11, 2, "VDOP"}, + { 12, 2, "NSAT (USED/VIEW)"}, + { 13, 4, "SID",}, + { 14, 2, "ELEVATION" }, + { 15, 2, "AZIMUTH" }, + { 16, 2, "SNR"}, + { 17, 2, "RCR"}, + { 18, 2, "MILLISECOND"}, + { 19, 8, "DISTANCE" }, + { 20, 0, nullptr}, + }; + + struct sat_info { + char id, used; + short elevation, azimut, snr; + }; + + struct data_item { + time_t timestamp; + short valid; + double lat; + double lon; + float height; + float speed; + float heading; + short dsta; // differential station id + float dage; // differential data age + float pdop, hdop, vdop; + char sat_used, sat_view, sat_count; + short rcr; + unsigned short timestamp_ms; + double distance; + sat_info sat_data[32]; + }; + + struct mtk_loginfo { + unsigned int bitmask; + int logLen; + int period, distance, speed; /* in 10:ths of sec, m, km/h */ + int track_event; + }; + + /* *************************************** */ + + /* MTK chip based devices with different baudrate, tweaks, ... */ + enum MTK_DEVICE_TYPE { + MTK_LOGGER, + HOLUX_M241, + HOLUX_GR245 + }; + + + void* fd{}; /* serial fd */ + FILE* fl{}; /* bin.file fd */ + char* port{}; /* serial port name */ + char* OPT_erase{}; /* erase ? command option */ + char* OPT_erase_only{}; /* erase_only ? command option */ + char* OPT_log_enable{}; /* enable ? command option */ + char* csv_file{}; /* csv ? command option */ + char* OPT_block_size_kb{}; /* block_size_kb ? command option */ + MTK_DEVICE_TYPE mtk_device = MTK_LOGGER; + + mtk_loginfo mtk_info{}; + + static constexpr char LIVE_CHAR[4] = {'-', '\\','|','/'}; + + static constexpr char CMD_LOG_DISABLE[]= "$PMTK182,5*20\r\n"; + static constexpr char CMD_LOG_ENABLE[] = "$PMTK182,4*21\r\n"; + static constexpr char CMD_LOG_FORMAT[] = "$PMTK182,2,2*39\r\n"; + static constexpr char CMD_LOG_ERASE[] = "$PMTK182,6,1*3E\r\n"; + static constexpr char CMD_LOG_STATUS[] = "$PMTK182,2,7*3C\r\n"; + +// Arguments for log fetch 'mtk' command.. + + QVector mtk_sargs = { + { + "erase", &OPT_erase, "Erase device data after download", + "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "erase_only", &OPT_erase_only, "Only erase device data, do not download anything", + "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "log_enable", &OPT_log_enable, "Enable logging after download", + "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + }, + { + "csv", &csv_file, "MTK compatible CSV output file", + nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + { + "block_size_kb", &OPT_block_size_kb, "Size of blocks in KB to request from device", + "1", ARGTYPE_INT, "1", "64", nullptr + }, + }; + + QVector mtk_fargs = { + { + "csv", &csv_file, "MTK compatible CSV output file", + nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr + }, + }; + + route_head* trk_head = nullptr; + + gbfile* cd{}; + + [[gnu::format(printf, 2, 3)]] static void dbg(int l, const char* msg, ...); + static QString GetTempName(bool backup); + int do_send_cmd(const char* cmd, int cmdLen); + int do_cmd(const char* cmd, const char* expect, char** rslt, time_t timeout_sec); + void mtk_rd_init_m241(const QString& fname); + void mtk_rd_init(const QString& fname); + void mtk_rd_deinit(); + int mtk_erase(); + void mtk_read(); + int add_trackpoint(int idx, long unsigned int bmask, data_item* itm); + void mtk_csv_init(char* csv_fname, long unsigned int bitmask); + void mtk_csv_deinit(); + static int csv_line(gbfile* csvFile, int idx, long unsigned int bmask, data_item* itm); + int mtk_parse(unsigned char* data, int dataLen, unsigned int bmask); + int mtk_parse_info(const unsigned char* data, int dataLen); + int mtk_log_len(unsigned int bitmask); + void file_init_m241(const QString& fname); + void file_init(const QString& fname); + void file_deinit(); + void holux245_init(); + int is_holux_string(const unsigned char* data, int dataLen); + void file_read(); +}; + +class MtkFormat : public Format, private MtkLoggerBase +{ +public: + QVector* get_args() override + { + return &mtk_sargs; + } + + ff_type get_type() const override + { + return ff_type_serial; + } + + QVector get_cap() const override + { + return { ff_cap_read, ff_cap_read, ff_cap_none }; + } + + void rd_init(const QString& fname) override + { + mtk_rd_init(fname); + }; + void read() override + { + mtk_read(); + }; + void rd_deinit() override + { + mtk_rd_deinit(); + }; +}; + +class MtkM241Format : public Format, private MtkLoggerBase +{ +public: + QVector* get_args() override + { + return &mtk_sargs; + } + + ff_type get_type() const override + { + return ff_type_serial; + } + + QVector get_cap() const override + { + return { ff_cap_none, ff_cap_read, ff_cap_none }; + } + + void rd_init(const QString& fname) override + { + mtk_rd_init_m241(fname); + }; + void read() override + { + mtk_read(); + }; + void rd_deinit() override + { + mtk_rd_deinit(); + }; +}; + +class MtkFileFormat : public Format, private MtkLoggerBase +{ +public: + QVector* get_args() override + { + return &mtk_fargs; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + return { ff_cap_read, ff_cap_read, ff_cap_none }; + } + + void rd_init(const QString& fname) override + { + file_init(fname); + }; + void read() override + { + file_read(); + }; + void rd_deinit() override + { + file_deinit(); + }; +}; + +class MtkM241FileFormat : public Format, private MtkLoggerBase +{ +public: + QVector* get_args() override + { + return &mtk_fargs; + } + + ff_type get_type() const override + { + return ff_type_file; + } + + QVector get_cap() const override + { + return { ff_cap_read, ff_cap_read, ff_cap_none }; + } + + void rd_init(const QString& fname) override + { + file_init_m241(fname); + }; + void read() override + { + file_read(); + }; + void rd_deinit() override + { + file_deinit(); + }; +}; +#endif // MTK_LOGGER_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index eb198a7f5..4d8826d03 100644 --- a/vecs.cc +++ b/vecs.cc @@ -63,6 +63,7 @@ #include "kml.h" // for KmlFormat #include "legacyformat.h" // for LegacyFormat #include "lowranceusr.h" // for LowranceusrFormat +#include "mtk_logger.h" // for MtkFormat, MtkM241Format, MtkFileFormat, MtkM241FileFormat #include "nmea.h" // for NmeaFormat #include "osm.h" // for OsmFormat #include "ozi.h" // for OziFormat @@ -82,14 +83,6 @@ #include "googletakeout.h" // for GoogleTakeoutFormat -extern ff_vecs_t geo_vecs; -#if MAXIMAL_ENABLED -extern ff_vecs_t mtk_vecs; -extern ff_vecs_t mtk_fvecs; -extern ff_vecs_t mtk_m241_vecs; -extern ff_vecs_t mtk_m241_fvecs; -#endif // MAXIMAL_ENABLED - #define MYNAME "vecs" template @@ -123,10 +116,10 @@ struct Vecs::Impl { TextFormat text_fmt; HtmlFormat html_fmt; IgcFormat igc_fmt; - LegacyFormat mtk_fmt {mtk_vecs}; - LegacyFormat mtk_ffmt {mtk_fvecs}; - LegacyFormat mtk_m241_fmt {mtk_m241_vecs}; - LegacyFormat mtk_m241_ffmt {mtk_m241_fvecs}; + MtkFormat mtk_fmt; + MtkFileFormat mtk_ffmt; + MtkM241Format mtk_m241_fmt; + MtkM241FileFormat mtk_m241_ffmt; #endif // MAXIMAL_ENABLED #if MAXIMAL_ENABLED UnicsvFormat unicsv_fmt; From b41da9dbb907005b3b11af9df1e1dc0f7329e394 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 19:07:36 -0700 Subject: [PATCH 051/132] retire LegacyFormat class. (#1233) --- CMakeLists.txt | 1 - defs.h | 40 --------------------- legacyformat.h => deprecated/legacyformat.h | 0 vecs.cc | 1 - 4 files changed, 42 deletions(-) rename legacyformat.h => deprecated/legacyformat.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d96f2d5c7..b02d70d55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,7 +227,6 @@ set(HEADERS html.h inifile.h kml.h - legacyformat.h igc.h lowranceusr.h mkshort.h diff --git a/defs.h b/defs.h index 99e3a54bc..1e4523f43 100644 --- a/defs.h +++ b/defs.h @@ -807,14 +807,6 @@ struct posn_status { extern posn_status tracking_status; -using ff_init = void (*)(const QString&); -using ff_deinit = void (*)(); -using ff_read = void (*)(); -using ff_write = void (*)(); -using ff_exit = void (*)(); -using ff_writeposn = void (*)(Waypoint*); -using ff_readposn = Waypoint* (*)(posn_status*); - #define ARGTYPE_UNKNOWN 0x00000000U #define ARGTYPE_INT 0x00000001U #define ARGTYPE_FLOAT 0x00000002U @@ -886,38 +878,6 @@ enum ff_cap { #define FF_CAP_RW_WPT \ { (ff_cap) (ff_cap_read | ff_cap_write), ff_cap_none, ff_cap_none} -/* - * Format capabilities for realtime positioning. - */ -struct position_ops_t { - ff_init rd_init; - ff_readposn rd_position; - ff_deinit rd_deinit; - - ff_init wr_init; - ff_writeposn wr_position; - ff_deinit wr_deinit; -}; - -#define NULL_POS_OPS { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, } - -/* - * Describe the file format to the caller. - */ -struct ff_vecs_t { - ff_type type; - QVector cap; - ff_init rd_init; - ff_init wr_init; - ff_deinit rd_deinit; - ff_deinit wr_deinit; - ff_read read; - ff_write write; - ff_exit exit; - QVector* args; - position_ops_t position_ops; -}; - [[noreturn]] void fatal(QDebug& msginstance); // cppcheck 2.10.3 fails to assign noreturn attribute to fatal if // the noreturn attribute is listed before the gnu::format attribute. diff --git a/legacyformat.h b/deprecated/legacyformat.h similarity index 100% rename from legacyformat.h rename to deprecated/legacyformat.h diff --git a/vecs.cc b/vecs.cc index 4d8826d03..42c1f4291 100644 --- a/vecs.cc +++ b/vecs.cc @@ -61,7 +61,6 @@ #include "igc.h" // for IgcFormat #include "inifile.h" // for inifile_readstr #include "kml.h" // for KmlFormat -#include "legacyformat.h" // for LegacyFormat #include "lowranceusr.h" // for LowranceusrFormat #include "mtk_logger.h" // for MtkFormat, MtkM241Format, MtkFileFormat, MtkM241FileFormat #include "nmea.h" // for NmeaFormat From d9448e835e4478418973b2d93305ed1a1dab2cae Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 18 Nov 2023 19:36:42 -0700 Subject: [PATCH 052/132] simplify usage of homebrew on CI macos-11. (#1234) homebrew installs are taking an extreme amount of time on macos-11, with the following message: Warning: You are using macOS 11. We (and Apple) do not provide support for this old version. It is expected behaviour that some formulae will fail to build in this old version. It is expected behaviour that Homebrew will be buggy and slow. To alleviate this pain skip the installation of jing and all it's dependencies on macos-11. --- .github/workflows/macos.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 31ad8eced..cdd796ec1 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -75,7 +75,10 @@ jobs: # brew update # skip update for now to avoid link issues AND many slow dependency upGRADES. brew install ninja brew install docbook docbook-xsl fop gnu-sed - brew install jing-trang + # brew install is taking forever on macos-11, skip jing-trang and all it's dependencies. + if [ "${{ matrix.os }}" != "macos-11" ]; then + brew install jing-trang + fi - name: Script env: From c8f517940abcfe8fd61e10394621eb8c16651278 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sun, 19 Nov 2023 06:00:31 -0700 Subject: [PATCH 053/132] misc cleanups (#1235) --- CMakeLists.txt | 1 - garmin_gpi.cc | 2 +- tpo.h | 14 ++------------ vecs.cc | 2 +- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b02d70d55..da33def6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,7 +256,6 @@ set(HEADERS jeeps/gpscom.h jeeps/gpsdatum.h jeeps/gpsdevice.h - jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsport.h diff --git a/garmin_gpi.cc b/garmin_gpi.cc index 3f9a824fb..a936cd373 100644 --- a/garmin_gpi.cc +++ b/garmin_gpi.cc @@ -452,7 +452,7 @@ GarminGPIFormat::read_tag(const char* caller, const int tag, Waypoint* wpt) case 0x8000b: /* address (street/city...) */ (void) gbfgetint32(fin); - // FALLTHROUGH + [[fallthrough]]; case 0xb: /* as seen in German POI files. */ PP; mask = gbfgetint16(fin); /* address fields mask */ diff --git a/tpo.h b/tpo.h index 43a0c7e40..ddcf9ebc9 100644 --- a/tpo.h +++ b/tpo.h @@ -138,7 +138,7 @@ class Tpo2Format : public Format, private TpoFormatBase public: QVector* get_args() override { - return &tpo2_args; + return nullptr; } ff_type get_type() const override @@ -165,11 +165,6 @@ class Tpo2Format : public Format, private TpoFormatBase { tpo_rd_deinit(); } - -private: - /* Data Members */ - - QVector tpo2_args = {}; }; class Tpo3Format : public Format, private TpoFormatBase @@ -177,7 +172,7 @@ class Tpo3Format : public Format, private TpoFormatBase public: QVector* get_args() override { - return &tpo3_args; + return nullptr; } ff_type get_type() const override @@ -204,10 +199,5 @@ class Tpo3Format : public Format, private TpoFormatBase { tpo_rd_deinit(); } - -private: - /* Data Members */ - - QVector tpo3_args = {}; }; #endif // TPO_H_INCLUDED_ diff --git a/vecs.cc b/vecs.cc index 42c1f4291..1a232f408 100644 --- a/vecs.cc +++ b/vecs.cc @@ -706,7 +706,7 @@ void Vecs::disp_vec_options(const QString& vecname, const QVector* ar { if (args) { for (const auto& arg : *args) { - if (*arg.argval && arg.argval) { + if (arg.argval && *arg.argval) { printf("options: module/option=value: %s/%s=\"%s\"", qPrintable(vecname), qPrintable(arg.argstring), *arg.argval); if (case_ignore_strcmp(arg.defaultvalue, *arg.argval) == 0) { From e251cac4f51c857435bb8e64d003a2d4db4e8f13 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 20 Nov 2023 11:01:17 -0700 Subject: [PATCH 054/132] straggling nits (#1236) * actually quit using gpsfmt.h * use auto * empty statements * join declaration and assignment * fix tab * make member funct static * delete renamed prototypes * const pointers * more const pointers * empty statements --- defs.h | 4 ++-- googletakeout.cc | 2 +- gpx.cc | 2 +- gpx.h | 4 ++-- jeeps/gps.h | 1 - mtk_logger.h | 32 ++++++++++++++++++++------------ ozi.h | 2 -- route.cc | 4 ++-- src/core/xmlstreamwriter.h | 6 +++--- src/core/xmltag.cc | 2 +- text.cc | 2 +- xcsv.cc | 3 +-- 12 files changed, 34 insertions(+), 30 deletions(-) diff --git a/defs.h b/defs.h index 1e4523f43..7604be2f1 100644 --- a/defs.h +++ b/defs.h @@ -701,8 +701,8 @@ void track_disp_session(const session_t* se, route_hdr rh, route_trl rt, waypt_c void route_flush_all_routes(); void route_flush_all_tracks(); void route_deinit(); -void route_append(RouteList* src); -void track_append(RouteList* src); +void route_append(const RouteList* src); +void track_append(const RouteList* src); void route_backup(RouteList** head_bak); void route_restore(RouteList* head_bak); void route_swap(RouteList& other); diff --git a/googletakeout.cc b/googletakeout.cc index af824ae23..eb061239d 100644 --- a/googletakeout.cc +++ b/googletakeout.cc @@ -65,7 +65,7 @@ static Waypoint* takeout_waypoint( const QString* start_str ) { - Waypoint* waypoint = new Waypoint(); + auto* waypoint = new Waypoint(); waypoint->latitude = lat_e7 / 1e7; waypoint->longitude = lon_e7 / 1e7; if (shortname && shortname->length() > 0) { diff --git a/gpx.cc b/gpx.cc index f8e0cebc3..04e3e408b 100644 --- a/gpx.cc +++ b/gpx.cc @@ -1184,7 +1184,7 @@ GpxFormat::write_attributes(const QXmlStreamAttributes& attributes) const } void -GpxFormat::fprint_xml_chain(XmlTag* tag) const +GpxFormat::fprint_xml_chain(const XmlTag* tag) const { while (tag) { writer->writeStartElement(tag->tagname); diff --git a/gpx.h b/gpx.h index c0d0218ac..741c91bb8 100644 --- a/gpx.h +++ b/gpx.h @@ -221,7 +221,7 @@ class GpxFormat : public Format void tag_wpt(const QXmlStreamAttributes& attr); void tag_cache_desc(const QXmlStreamAttributes& attr); void tag_gs_cache(const QXmlStreamAttributes& attr) const; - void tag_garmin_fs(tag_type tag, const QString& text, Waypoint* waypt); + static void tag_garmin_fs(tag_type tag, const QString& text, Waypoint* waypt); void start_something_else(QStringView el, const QXmlStreamAttributes& attr); void end_something_else(); void tag_log_wpt(const QXmlStreamAttributes& attr) const; @@ -230,7 +230,7 @@ class GpxFormat : public Format void gpx_cdata(QStringView s); QString qualifiedName() const; void write_attributes(const QXmlStreamAttributes& attributes) const; - void fprint_xml_chain(XmlTag* tag) const; + void fprint_xml_chain(const XmlTag* tag) const; void write_gpx_url(const UrlList& urls) const; void write_gpx_url(const Waypoint* waypointp) const; void write_gpx_url(const route_head* rh) const; diff --git a/jeeps/gps.h b/jeeps/gps.h index f883911f3..b8d1e7046 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -241,7 +241,6 @@ using pcb_fn = int (*)(int, GPS_SWay**); #include "jeeps/gpsapp.h" #include "jeeps/gpsprot.h" #include "jeeps/gpscom.h" -#include "jeeps/gpsfmt.h" #include "jeeps/gpsmath.h" #include "jeeps/gpsmem.h" #include "jeeps/gpsrqst.h" diff --git a/mtk_logger.h b/mtk_logger.h index f54b8ed08..7b8b7602e 100644 --- a/mtk_logger.h +++ b/mtk_logger.h @@ -314,15 +314,17 @@ class MtkFormat : public Format, private MtkLoggerBase void rd_init(const QString& fname) override { mtk_rd_init(fname); - }; + } + void read() override { mtk_read(); - }; + } + void rd_deinit() override { mtk_rd_deinit(); - }; + } }; class MtkM241Format : public Format, private MtkLoggerBase @@ -346,15 +348,17 @@ class MtkM241Format : public Format, private MtkLoggerBase void rd_init(const QString& fname) override { mtk_rd_init_m241(fname); - }; + } + void read() override { mtk_read(); - }; + } + void rd_deinit() override { mtk_rd_deinit(); - }; + } }; class MtkFileFormat : public Format, private MtkLoggerBase @@ -378,15 +382,17 @@ class MtkFileFormat : public Format, private MtkLoggerBase void rd_init(const QString& fname) override { file_init(fname); - }; + } + void read() override { file_read(); - }; + } + void rd_deinit() override { file_deinit(); - }; + } }; class MtkM241FileFormat : public Format, private MtkLoggerBase @@ -410,14 +416,16 @@ class MtkM241FileFormat : public Format, private MtkLoggerBase void rd_init(const QString& fname) override { file_init_m241(fname); - }; + } + void read() override { file_read(); - }; + } + void rd_deinit() override { file_deinit(); - }; + } }; #endif // MTK_LOGGER_H_INCLUDED_ diff --git a/ozi.h b/ozi.h index bcb8a4062..fc4478a47 100644 --- a/ozi.h +++ b/ozi.h @@ -109,9 +109,7 @@ class OziFormat : public Format void ozi_parse_track(int field, const QString& str, Waypoint* wpt_tmp, char* trk_name); static void ozi_parse_routepoint(int field, const QString& str, Waypoint* wpt_tmp); void ozi_parse_routeheader(int field, const QString& str); - void data_read(); void ozi_waypt_pr(const Waypoint* wpt, int index); - void data_write(); /* Data Members */ diff --git a/route.cc b/route.cc index f8fdd8422..a065bd5fb 100644 --- a/route.cc +++ b/route.cc @@ -206,13 +206,13 @@ route_deinit() } void -route_append(RouteList* src) +route_append(const RouteList* src) { src->copy(&global_route_list); } void -track_append(RouteList* src) +track_append(const RouteList* src) { src->copy(&global_track_list); } diff --git a/src/core/xmlstreamwriter.h b/src/core/xmlstreamwriter.h index 87b236e80..2d0372f4d 100644 --- a/src/core/xmlstreamwriter.h +++ b/src/core/xmlstreamwriter.h @@ -60,7 +60,7 @@ class XmlStreamWriter : public QXmlStreamWriter explicit xml_command(xml_wrt_cmd_t t, QString n = QString(), QString v = QString()) - : type(t), name(std::move(n)), value(std::move(v)) {}; + : type(t), name(std::move(n)), value(std::move(v)) {} xml_wrt_cmd_t type; QString name; @@ -74,7 +74,7 @@ class XmlStreamWriter : public QXmlStreamWriter { stack.append(other.stack); element_count += other.element_count; - }; + } void append(const xml_command& cmd) { @@ -94,7 +94,7 @@ class XmlStreamWriter : public QXmlStreamWriter case xml_wrt_cmd_t::name_space: break; } - }; + } xml_stack_t stack; int element_count{0}; diff --git a/src/core/xmltag.cc b/src/core/xmltag.cc index 2376bce3d..717979ea4 100644 --- a/src/core/xmltag.cc +++ b/src/core/xmltag.cc @@ -91,7 +91,7 @@ free_xml_tag(XmlTag* tag) // FIXME: at some point, this becomes a plain ole copy constructor. static void -copy_xml_tag(XmlTag** copy, XmlTag* src, XmlTag* parent) +copy_xml_tag(XmlTag** copy, const XmlTag* src, XmlTag* parent) { if (!src) { *copy = nullptr; diff --git a/text.cc b/text.cc index 74a9df387..46533eaa8 100644 --- a/text.cc +++ b/text.cc @@ -147,7 +147,7 @@ TextFormat::text_disp(const Waypoint* wpt) logpart = curlog->xml_findfirst(u"groundspeak:date"); if (logpart) { - gpsbabel::DateTime logtime = xml_parse_time(logpart->cdata).toUTC();; + gpsbabel::DateTime logtime = xml_parse_time(logpart->cdata).toUTC(); *file_out << logtime.toString(u"yyyy-MM-dd") << "\n"; } diff --git a/xcsv.cc b/xcsv.cc index 004781481..747660622 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -646,8 +646,7 @@ XcsvFormat::xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle: } break; case XcsvStyle::XT_GEOCACHE_LAST_FOUND: { - QDate date; - date = yyyymmdd_to_time(value); + QDate date = yyyymmdd_to_time(value); wpt->AllocGCData()->last_found = date.startOfDay(); break; } From e8c5cc295bbab9dd559fc9e72d4548372c0ac7cc Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 23 Nov 2023 06:24:49 -0700 Subject: [PATCH 055/132] bring static functions into googltakeout class. (#1240) and other tidy modernizations. --- googletakeout.cc | 30 ++++++------- googletakeout.h | 109 +++++++++++++++++++++++++---------------------- 2 files changed, 72 insertions(+), 67 deletions(-) diff --git a/googletakeout.cc b/googletakeout.cc index eb061239d..5ba243c83 100644 --- a/googletakeout.cc +++ b/googletakeout.cc @@ -40,24 +40,17 @@ #include "src/core/file.h" // for File #include "src/core/logging.h" // for Debug, FatalMsg, Warning -#define MYNAME "Google Takeout" -#define TIMELINE_OBJECTS "timelineObjects" -static const QList takeout_month_names{ - "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", - "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" -}; - -static void takeout_fatal(const QString& message) { +void GoogleTakeoutFormat::takeout_fatal(const QString& message) { fatal(FatalMsg() << MYNAME << ": " << message); } -static void takeout_warning(const QString& message) { +void GoogleTakeoutFormat::takeout_warning(const QString& message) { Warning() << MYNAME << ": " << message; } /* create a waypoint from late7/lone7 and optional metadata */ -static Waypoint* takeout_waypoint( +Waypoint* GoogleTakeoutFormat::takeout_waypoint( int lat_e7, int lon_e7, const QString* shortname, @@ -81,7 +74,7 @@ static Waypoint* takeout_waypoint( return waypoint; } -static bool track_maybe_add_wpt(route_head* route, Waypoint* waypoint) { +bool GoogleTakeoutFormat::track_maybe_add_wpt(route_head* route, Waypoint* waypoint) { if (waypoint->latitude == 0 && waypoint->longitude == 0) { if (global_opts.debug_level >= 2) { Debug(2) << "Track " << route->rte_name << "@" << @@ -95,7 +88,7 @@ static bool track_maybe_add_wpt(route_head* route, Waypoint* waypoint) { return true; } -static QList readJson( +QList GoogleTakeoutFormat::GoogleTakeoutInputStream::readJson( const QString& source) { if (global_opts.debug_level >= 2) { @@ -142,7 +135,7 @@ static QList readJson( return timeline; } -static QList readDir( +QList GoogleTakeoutFormat::GoogleTakeoutInputStream::readDir( const QString& source) { if (global_opts.debug_level >= 2) { @@ -158,6 +151,10 @@ static QList readDir( * folders */ if (baseName.length() == 4 && baseName.toInt() > 0) { + static const QList takeout_month_names{ + "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", + "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" + }; for (auto&& month : takeout_month_names) { const QString path = source + "/" + baseName + "_" + month + ".json"; const QFileInfo info{path}; @@ -337,7 +334,6 @@ GoogleTakeoutFormat::add_activity_segment(const QJsonObject& activitySegment) * TODO: do something with simplifiedRawPath */ int n_points = 0; - Waypoint* waypoint = nullptr; auto* route = new route_head; const QJsonObject startLoc = activitySegment[START_LOCATION].toObject(); const QJsonObject endLoc = activitySegment[END_LOCATION].toObject(); @@ -347,7 +343,7 @@ GoogleTakeoutFormat::add_activity_segment(const QJsonObject& activitySegment) track_add_head(route); QString timestamp; timestamp = activitySegment[DURATION][START_TIMESTAMP].toString(); - waypoint = takeout_waypoint( + Waypoint* waypoint = takeout_waypoint( startLoc[LOCATION_LATE7].toInt(), startLoc[LOCATION_LONE7].toInt(), nullptr, nullptr, @@ -404,7 +400,7 @@ GoogleTakeoutFormat::add_activity_segment(const QJsonObject& activitySegment) return n_points; } -void GoogleTakeoutInputStream::loadSource(const QString& source) { +void GoogleTakeoutFormat::GoogleTakeoutInputStream::loadSource(const QString& source) { const QFileInfo info{source}; if (info.isDir()) { sources += readDir(source); @@ -415,7 +411,7 @@ void GoogleTakeoutInputStream::loadSource(const QString& source) { } } -QJsonValue GoogleTakeoutInputStream::next() { +QJsonValue GoogleTakeoutFormat::GoogleTakeoutInputStream::next() { if (!timelineObjects.isEmpty()) { QJsonValue nextObject = timelineObjects.first(); timelineObjects.removeFirst(); diff --git a/googletakeout.h b/googletakeout.h index b3489d928..fcfe55aac 100644 --- a/googletakeout.h +++ b/googletakeout.h @@ -26,7 +26,6 @@ #include // for QJsonValue #include // for QList #include // for QString -#include // for qMakeStringPrivate, QStringLiteral #include // for QVector #include "defs.h" @@ -38,29 +37,6 @@ * * TODO: Allow date ranges */ -class GoogleTakeoutInputStream -{ -public: - /* Special Member Functions */ - GoogleTakeoutInputStream() = default; - GoogleTakeoutInputStream(const QString& source) : sources({source}) {} - - /* Member Functions */ - - // Returns the next timelineObject, or a null QJsonValue if we're at the end - QJsonValue next(); - -private: - /* Member Functions */ - - void loadSource(const QString& source); - - /* Data Members */ - - QList sources; - QList timelineObjects; -}; - /* Read-only Google Timeline Location History gpsbabel Format */ class GoogleTakeoutFormat : public Format { @@ -75,7 +51,7 @@ class GoogleTakeoutFormat : public Format ff_type get_type() const override { - return ff_type_file; + return ff_type_file; } QVector get_cap() const override @@ -90,35 +66,68 @@ class GoogleTakeoutFormat : public Format private: /* Constants */ - const QString PLACE_VISIT = QStringLiteral("placeVisit"); - const QString ACTIVITY_SEGMENT = QStringLiteral("activitySegment"); - const QString ACTIVITY_TYPE = QStringLiteral("activityType"); - const QString LOCATION = QStringLiteral("location"); - const QString LOCATION_LATE7 = QStringLiteral("latitudeE7"); - const QString LOCATION_LONE7 = QStringLiteral("longitudeE7"); - const QString NAME = QStringLiteral("name"); - const QString ADDRESS = QStringLiteral("address"); - const QString DURATION = QStringLiteral("duration"); - const QString START_TIMESTAMP = QStringLiteral("startTimestamp"); - const QString START_LOCATION = QStringLiteral("startLocation"); - const QString END_TIMESTAMP = QStringLiteral("endTimestamp"); - const QString END_LOCATION = QStringLiteral("endLocation"); - const QString TIMESTAMP = QStringLiteral("timestamp"); - const QString SIMPLE_PATH = QStringLiteral("simplifiedRawPath"); - const QString POINTS = QStringLiteral("points"); - const QString WAYPOINT_PATH = QStringLiteral("waypointPath"); - const QString WAYPOINTS = QStringLiteral("waypoints"); - // for some reason that probably only a former Google engineer knows,); - // we use = QStringLiteral("latE7"/"lngE7" here instead of "latitudeE7"/"longitudeE7".); - // +10 points for brevity, but -100 points for inconsistency.); - const QString LATE7 = QStringLiteral("latE7"); - const QString LONE7 = QStringLiteral("lngE7"); + static constexpr char MYNAME[] = "Google Takeout"; + static constexpr char TIMELINE_OBJECTS[] = "timelineObjects"; + static constexpr char16_t PLACE_VISIT[] = u"placeVisit"; + static constexpr char16_t ACTIVITY_SEGMENT[] = u"activitySegment"; + static constexpr char16_t ACTIVITY_TYPE[] = u"activityType"; + static constexpr char16_t LOCATION[] = u"location"; + static constexpr char16_t LOCATION_LATE7[] = u"latitudeE7"; + static constexpr char16_t LOCATION_LONE7[] = u"longitudeE7"; + static constexpr char16_t NAME[] = u"name"; + static constexpr char16_t ADDRESS[] = u"address"; + static constexpr char16_t DURATION[] = u"duration"; + static constexpr char16_t START_TIMESTAMP[] = u"startTimestamp"; + static constexpr char16_t START_LOCATION[] = u"startLocation"; + static constexpr char16_t END_TIMESTAMP[] = u"endTimestamp"; + static constexpr char16_t END_LOCATION[] = u"endLocation"; + static constexpr char16_t TIMESTAMP[] = u"timestamp"; + static constexpr char16_t SIMPLE_PATH[] = u"simplifiedRawPath"; + static constexpr char16_t POINTS[] = u"points"; + static constexpr char16_t WAYPOINT_PATH[] = u"waypointPath"; + static constexpr char16_t WAYPOINTS [] = u"waypoints"; + // for some reason that probably only a former Google engineer knows,; + // we use[] = u"latE7"/"lngE7" here instead of "latitudeE7"/"longitudeE7".; + // +10 points for brevity, but -100 points for inconsistency.; + static constexpr char16_t LATE7[] = u"latE7"; + static constexpr char16_t LONE7[] = u"lngE7"; + + /* Types */ + + class GoogleTakeoutInputStream + { + public: + /* Special Member Functions */ + GoogleTakeoutInputStream() = default; + GoogleTakeoutInputStream(const QString& source) : sources({source}) {} + + /* Member Functions */ - /* Member Functions */ + // Returns the next timelineObject, or a null QJsonValue if we're at the end + QJsonValue next(); + + private: + /* Member Functions */ + static QList readJson(const QString& source); + static QList readDir(const QString& source); + void loadSource(const QString& source); + + /* Data Members */ + + QList sources; + QList timelineObjects; + }; + + /* Member Functions */ + + static void takeout_fatal(const QString& message); + static void takeout_warning(const QString& message); + Waypoint* takeout_waypoint(int lat_e7, int lon_e7, const QString* shortname, const QString* description, const QString* start_str); + static bool track_maybe_add_wpt(route_head* route, Waypoint* waypoint); + static void title_case(QString& title); void add_place_visit(const QJsonObject& placeVisit); int add_activity_segment(const QJsonObject& activitySegment); - static void title_case(QString& title); /* Data Members */ From c22c7203d8e44d74a42705f7a3cbbd89cfb66335 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 23 Nov 2023 07:22:05 -0700 Subject: [PATCH 056/132] fix errors in gpi writer related to bitmaps. (#1243) Erroneous warnings "garmin_gpi: Code error in load_bitmap_from_file, expected output size 1060, actual output -28." Corrupted colors when input bitmap has 24 bits per pixel. --- garmin_gpi.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/garmin_gpi.cc b/garmin_gpi.cc index a936cd373..3877de63c 100644 --- a/garmin_gpi.cc +++ b/garmin_gpi.cc @@ -1145,7 +1145,6 @@ GarminGPIFormat::load_bitmap_from_file(const char* fname, const unsigned char** } ptr = (unsigned char*) xmalloc(sz); - const unsigned char* const startptr = ptr; dest_h = (gpi_bitmap_header_t*)ptr; *data = ptr; *data_sz = sz; @@ -1176,8 +1175,8 @@ GarminGPIFormat::load_bitmap_from_file(const char* fname, const unsigned char** unsigned char* p = ptr; for (j = 0; j < src_h.width; j++) { - int color = (int32_t)gbfgetint16(f) | (gbfgetc(f) << 16); - le_write32(p, color); + gbfread(p, 1, 3, f); + p[3] = 0x00; p += 4; } for (j = (src_h.width * src_h.bpp) / 8; j < src_line_sz; j++) { @@ -1202,10 +1201,6 @@ GarminGPIFormat::load_bitmap_from_file(const char* fname, const unsigned char** } } - auto bytesout = ptr - startptr; - if (bytesout != *data_sz) { - warning(MYNAME ": Code error in load_bitmap_from_file, expected output size %d, actual output %td.", *data_sz, bytesout); - } gbfclose(f); } From 6d309e1b357e06fd2a76f4eaf6ddb2390ad0eb25 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 30 Nov 2023 05:40:13 -0700 Subject: [PATCH 057/132] make xmlgeneric a class (#1244) * make xmlgeneric a class. * encapsulate more of xmlgeneric * use scoped enum * encapsulate a bit more. * retire xg_string type * use scoped enums * rule of zero applied to xmlgeneric class. * remove test code --- gtrnctr.cc | 40 ++++---- gtrnctr.h | 141 +++++++++++++------------- kml.cc | 34 ++++--- kml.h | 45 ++++----- osm.cc | 27 ++--- osm.h | 37 +++---- xmlgeneric.cc | 156 +++++++++-------------------- xmlgeneric.h | 268 ++++++++++++++++++++++++++++---------------------- 8 files changed, 365 insertions(+), 383 deletions(-) diff --git a/gtrnctr.cc b/gtrnctr.cc index f53cccef6..5a306a79f 100644 --- a/gtrnctr.cc +++ b/gtrnctr.cc @@ -38,7 +38,7 @@ #include // for add_const<>::type #include "defs.h" // for Waypoint, route_head, computed_trkdata, waypt_add, route_disp, track_disp_all, case_ignore_strncmp, track_add_head, track_add_wpt, track_recompute, xml_parse_time, CSTR, wp_flags, WAYPT_SET, unknown_alt -#include "xmlgeneric.h" // for xg_string, build_xg_tag_map, xml_deinit, xml_init, xml_read +#include "xmlgeneric.h" // for xml_deinit, xml_init, xml_read #define MYNAME "gtc" @@ -46,19 +46,21 @@ void GtrnctrFormat::rd_init(const QString& fname) { - xml_init(fname, build_xg_tag_map(this, gtc_map), nullptr, gtc_tags_to_ignore, nullptr, true); + xml_reader = new XmlGenericReader; + xml_reader->xml_init(fname, this, gtc_map, nullptr, gtc_tags_to_ignore, nullptr); } void GtrnctrFormat::read() { - xml_read(); + xml_reader->xml_read(); } void GtrnctrFormat::rd_deinit() { - xml_deinit(); + delete xml_reader; + xml_reader = nullptr; } void @@ -359,39 +361,39 @@ GtrnctrFormat::write() } void -GtrnctrFormat::gtc_trk_s(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_s(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { trk_head = new route_head; track_add_head(trk_head); } void -GtrnctrFormat::gtc_trk_ident(xg_string args, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_ident(const QString& args, const QXmlStreamAttributes* /*unused*/) { trk_head->rte_name = args; } void -GtrnctrFormat::gtc_trk_lap_s(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_lap_s(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { lap_ct++; lap_s = 1; } void -GtrnctrFormat::gtc_trk_lap_e(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_lap_e(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { lap_s = 0; } void -GtrnctrFormat::gtc_trk_pnt_s(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_pnt_s(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { wpt_tmp = new Waypoint; } void -GtrnctrFormat::gtc_trk_pnt_e(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_pnt_e(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { if (wpt_tmp->longitude != 0. && wpt_tmp->latitude != 0.) { if (lap_s) { @@ -414,25 +416,25 @@ GtrnctrFormat::gtc_trk_pnt_e(xg_string /*unused*/, const QXmlStreamAttributes* / } void -GtrnctrFormat::gtc_trk_utc(xg_string args, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_utc(const QString& args, const QXmlStreamAttributes* /*unused*/) { wpt_tmp->creation_time = xml_parse_time(args); } void -GtrnctrFormat::gtc_trk_lat(xg_string args, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_lat(const QString& args, const QXmlStreamAttributes* /*unused*/) { wpt_tmp->latitude = args.toDouble(); } void -GtrnctrFormat::gtc_trk_long(xg_string args, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_long(const QString& args, const QXmlStreamAttributes* /*unused*/) { wpt_tmp->longitude = args.toDouble(); } void -GtrnctrFormat::gtc_trk_alt(xg_string args, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_alt(const QString& args, const QXmlStreamAttributes* /*unused*/) { wpt_tmp->altitude = args.toDouble(); } @@ -451,13 +453,13 @@ void GtrnctrFormat::gtc_trk_cad(const QString& args, const QXmlStreamAttributes* } void -GtrnctrFormat::gtc_trk_pwr(xg_string args, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_pwr(const QString& args, const QXmlStreamAttributes* /*unused*/) { wpt_tmp->power = args.toDouble(); } void -GtrnctrFormat::gtc_trk_spd(xg_string args, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_trk_spd(const QString& args, const QXmlStreamAttributes* /*unused*/) { wpt_tmp->set_speed(args.toDouble()); } @@ -469,7 +471,7 @@ GtrnctrFormat::gtc_wpt_crs_s(const QString& /*unused*/, const QXmlStreamAttribut } void -GtrnctrFormat::gtc_wpt_crs_e(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_wpt_crs_e(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { if (wpt_tmp->longitude != 0. && wpt_tmp->latitude != 0.) { waypt_add(wpt_tmp); @@ -481,14 +483,14 @@ GtrnctrFormat::gtc_wpt_crs_e(xg_string /*unused*/, const QXmlStreamAttributes* / } void -GtrnctrFormat::gtc_wpt_pnt_s(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_wpt_pnt_s(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { wpt_tmp = new Waypoint; lap_ct++; } void -GtrnctrFormat::gtc_wpt_pnt_e(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +GtrnctrFormat::gtc_wpt_pnt_e(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { if (wpt_tmp->longitude != 0. && wpt_tmp->latitude != 0.) { /* Add the begin position of a CourseLap as diff --git a/gtrnctr.h b/gtrnctr.h index 28a11d108..654b0d995 100644 --- a/gtrnctr.h +++ b/gtrnctr.h @@ -35,7 +35,7 @@ #include "format.h" // for Format #include "gbfile.h" // for gbfile #include "src/core/datetime.h" // for DateTime -#include "xmlgeneric.h" // for cb_cdata, xg_functor_map_entry, xg_string, cb_start, cb_end +#include "xmlgeneric.h" // for cb_cdata, xg_functor_map_entry, cb_start, cb_end class GtrnctrFormat : public Format @@ -97,25 +97,25 @@ class GtrnctrFormat : public Format void gtc_crs_hdr(const route_head* rte); void gtc_crs_ftr(const route_head* /* unused */); - void gtc_trk_s(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); - void gtc_trk_ident(xg_string args, const QXmlStreamAttributes* /* unused */); - void gtc_trk_lap_s(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); - void gtc_trk_lap_e(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); - void gtc_trk_pnt_s(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); - void gtc_trk_pnt_e(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); - void gtc_trk_utc(xg_string args, const QXmlStreamAttributes* /* unused */); - void gtc_trk_lat(xg_string args, const QXmlStreamAttributes* /* unused */); - void gtc_trk_long(xg_string args, const QXmlStreamAttributes* /* unused */); - void gtc_trk_alt(xg_string args, const QXmlStreamAttributes* /* unused */); + void gtc_trk_s(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); + void gtc_trk_ident(const QString& args, const QXmlStreamAttributes* /* unused */); + void gtc_trk_lap_s(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); + void gtc_trk_lap_e(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); + void gtc_trk_pnt_s(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); + void gtc_trk_pnt_e(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); + void gtc_trk_utc(const QString& args, const QXmlStreamAttributes* /* unused */); + void gtc_trk_lat(const QString& args, const QXmlStreamAttributes* /* unused */); + void gtc_trk_long(const QString& args, const QXmlStreamAttributes* /* unused */); + void gtc_trk_alt(const QString& args, const QXmlStreamAttributes* /* unused */); void gtc_trk_dist(const QString& args, const QXmlStreamAttributes* /* unused */); void gtc_trk_hr(const QString& args, const QXmlStreamAttributes* /* unused */); void gtc_trk_cad(const QString& args, const QXmlStreamAttributes* /* unused */); - void gtc_trk_pwr(xg_string args, const QXmlStreamAttributes* /* unused */); - void gtc_trk_spd(xg_string args, const QXmlStreamAttributes* /* unused */); + void gtc_trk_pwr(const QString& args, const QXmlStreamAttributes* /* unused */); + void gtc_trk_spd(const QString& args, const QXmlStreamAttributes* /* unused */); void gtc_wpt_crs_s(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); - void gtc_wpt_crs_e(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); - void gtc_wpt_pnt_s(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); - void gtc_wpt_pnt_e(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); + void gtc_wpt_crs_e(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); + void gtc_wpt_pnt_s(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); + void gtc_wpt_pnt_e(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); void gtc_wpt_ident(const QString& args, const QXmlStreamAttributes* /* unused */); void gtc_wpt_lat(const QString& args, const QXmlStreamAttributes* /* unused */); void gtc_wpt_long(const QString& args, const QXmlStreamAttributes* /* unused */); @@ -154,71 +154,72 @@ class GtrnctrFormat : public Format }, }; - QList> gtc_map = { + QList> gtc_map = { /* courses tcx v1 & v2 */ - { &GtrnctrFormat::gtc_trk_s, cb_start, "/Courses/Course" }, - { &GtrnctrFormat::gtc_trk_ident,cb_cdata, "/Courses/Course/Name"}, - { &GtrnctrFormat::gtc_trk_pnt_s,cb_start, "/Courses/Course/Track/Trackpoint" }, - { &GtrnctrFormat::gtc_trk_pnt_e,cb_end, "/Courses/Course/Track/Trackpoint" }, - { &GtrnctrFormat::gtc_trk_utc, cb_cdata, "/Courses/Course/Track/Trackpoint/Time" }, - { &GtrnctrFormat::gtc_trk_lat, cb_cdata, "/Courses/Course/Track/Trackpoint/Position/LatitudeDegrees" }, - { &GtrnctrFormat::gtc_trk_long, cb_cdata, "/Courses/Course/Track/Trackpoint/Position/LongitudeDegrees" }, - { &GtrnctrFormat::gtc_trk_alt, cb_cdata, "/Courses/Course/Track/Trackpoint/AltitudeMeters" }, - { &GtrnctrFormat::gtc_trk_hr, cb_cdata, "/Courses/Course/Track/Trackpoint/HeartRateBpm" }, - { &GtrnctrFormat::gtc_trk_cad, cb_cdata, "/Courses/Course/Track/Trackpoint/Cadence" }, - { &GtrnctrFormat::gtc_wpt_crs_s,cb_start, "/Courses/Course/CoursePoint" }, - { &GtrnctrFormat::gtc_wpt_crs_e,cb_end, "/Courses/Course/CoursePoint" }, - { &GtrnctrFormat::gtc_wpt_ident,cb_cdata, "/Courses/Course/CoursePoint/Name"}, - { &GtrnctrFormat::gtc_trk_utc, cb_cdata, "/Courses/Course/CoursePoint/Time"}, - { &GtrnctrFormat::gtc_wpt_lat, cb_cdata, "/Courses/Course/CoursePoint/Position/LatitudeDegrees"}, - { &GtrnctrFormat::gtc_wpt_long, cb_cdata, "/Courses/Course/CoursePoint/Position/LongitudeDegrees"}, - { &GtrnctrFormat::gtc_trk_alt, cb_cdata, "/Courses/Course/CoursePoint/AltitudeMeters" }, - { &GtrnctrFormat::gtc_wpt_icon, cb_cdata, "/Courses/Course/CoursePoint/PointType" }, - { &GtrnctrFormat::gtc_wpt_notes,cb_cdata, "/Courses/Course/CoursePoint/Notes" }, + { &GtrnctrFormat::gtc_trk_s, xg_cb_type::cb_start, "/Courses/Course" }, + { &GtrnctrFormat::gtc_trk_ident, xg_cb_type::cb_cdata, "/Courses/Course/Name"}, + { &GtrnctrFormat::gtc_trk_pnt_s, xg_cb_type::cb_start, "/Courses/Course/Track/Trackpoint" }, + { &GtrnctrFormat::gtc_trk_pnt_e, xg_cb_type::cb_end, "/Courses/Course/Track/Trackpoint" }, + { &GtrnctrFormat::gtc_trk_utc, xg_cb_type::cb_cdata, "/Courses/Course/Track/Trackpoint/Time" }, + { &GtrnctrFormat::gtc_trk_lat, xg_cb_type::cb_cdata, "/Courses/Course/Track/Trackpoint/Position/LatitudeDegrees" }, + { &GtrnctrFormat::gtc_trk_long, xg_cb_type::cb_cdata, "/Courses/Course/Track/Trackpoint/Position/LongitudeDegrees" }, + { &GtrnctrFormat::gtc_trk_alt, xg_cb_type::cb_cdata, "/Courses/Course/Track/Trackpoint/AltitudeMeters" }, + { &GtrnctrFormat::gtc_trk_hr, xg_cb_type::cb_cdata, "/Courses/Course/Track/Trackpoint/HeartRateBpm" }, + { &GtrnctrFormat::gtc_trk_cad, xg_cb_type::cb_cdata, "/Courses/Course/Track/Trackpoint/Cadence" }, + { &GtrnctrFormat::gtc_wpt_crs_s, xg_cb_type::cb_start, "/Courses/Course/CoursePoint" }, + { &GtrnctrFormat::gtc_wpt_crs_e, xg_cb_type::cb_end, "/Courses/Course/CoursePoint" }, + { &GtrnctrFormat::gtc_wpt_ident, xg_cb_type::cb_cdata, "/Courses/Course/CoursePoint/Name"}, + { &GtrnctrFormat::gtc_trk_utc, xg_cb_type::cb_cdata, "/Courses/Course/CoursePoint/Time"}, + { &GtrnctrFormat::gtc_wpt_lat, xg_cb_type::cb_cdata, "/Courses/Course/CoursePoint/Position/LatitudeDegrees"}, + { &GtrnctrFormat::gtc_wpt_long, xg_cb_type::cb_cdata, "/Courses/Course/CoursePoint/Position/LongitudeDegrees"}, + { &GtrnctrFormat::gtc_trk_alt, xg_cb_type::cb_cdata, "/Courses/Course/CoursePoint/AltitudeMeters" }, + { &GtrnctrFormat::gtc_wpt_icon, xg_cb_type::cb_cdata, "/Courses/Course/CoursePoint/PointType" }, + { &GtrnctrFormat::gtc_wpt_notes, xg_cb_type::cb_cdata, "/Courses/Course/CoursePoint/Notes" }, /* history tcx v2 (activities) */ - { &GtrnctrFormat::gtc_trk_s, cb_start, "/Activities/Activity" }, - { &GtrnctrFormat::gtc_trk_ident,cb_cdata, "/Activities/Activity/Id" }, - { &GtrnctrFormat::gtc_trk_lap_s,cb_start, "/Activities/Activity/Lap" }, - { &GtrnctrFormat::gtc_trk_lap_e,cb_end, "/Activities/Activity/Lap" }, - { &GtrnctrFormat::gtc_trk_pnt_s,cb_start, "/Activities/Activity/Lap/Track/Trackpoint" }, - { &GtrnctrFormat::gtc_trk_pnt_e,cb_end, "/Activities/Activity/Lap/Track/Trackpoint" }, - { &GtrnctrFormat::gtc_trk_utc, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Time" }, - { &GtrnctrFormat::gtc_trk_lat, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Position/LatitudeDegrees" }, - { &GtrnctrFormat::gtc_trk_long, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Position/LongitudeDegrees" }, - { &GtrnctrFormat::gtc_trk_alt, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/AltitudeMeters" }, - { &GtrnctrFormat::gtc_trk_dist, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/DistanceMeters" }, - { &GtrnctrFormat::gtc_trk_hr, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/HeartRateBpm" }, - { &GtrnctrFormat::gtc_trk_cad, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Cadence" }, - { &GtrnctrFormat::gtc_trk_pwr, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Extensions/ns3:TPX/ns3:Watts" }, + { &GtrnctrFormat::gtc_trk_s, xg_cb_type::cb_start, "/Activities/Activity" }, + { &GtrnctrFormat::gtc_trk_ident, xg_cb_type::cb_cdata, "/Activities/Activity/Id" }, + { &GtrnctrFormat::gtc_trk_lap_s, xg_cb_type::cb_start, "/Activities/Activity/Lap" }, + { &GtrnctrFormat::gtc_trk_lap_e, xg_cb_type::cb_end, "/Activities/Activity/Lap" }, + { &GtrnctrFormat::gtc_trk_pnt_s, xg_cb_type::cb_start, "/Activities/Activity/Lap/Track/Trackpoint" }, + { &GtrnctrFormat::gtc_trk_pnt_e, xg_cb_type::cb_end, "/Activities/Activity/Lap/Track/Trackpoint" }, + { &GtrnctrFormat::gtc_trk_utc, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Time" }, + { &GtrnctrFormat::gtc_trk_lat, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Position/LatitudeDegrees" }, + { &GtrnctrFormat::gtc_trk_long, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Position/LongitudeDegrees" }, + { &GtrnctrFormat::gtc_trk_alt, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/AltitudeMeters" }, + { &GtrnctrFormat::gtc_trk_dist, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/DistanceMeters" }, + { &GtrnctrFormat::gtc_trk_hr, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/HeartRateBpm" }, + { &GtrnctrFormat::gtc_trk_cad, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Cadence" }, + { &GtrnctrFormat::gtc_trk_pwr, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Extensions/ns3:TPX/ns3:Watts" }, // Sample from Marcelo Kittlein 5/2014 declares a default namespace with the start tag of the TPX element, // and thus doesn't use prefixes. - { &GtrnctrFormat::gtc_trk_pwr, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Extensions/TPX/Watts" }, + { &GtrnctrFormat::gtc_trk_pwr, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Extensions/TPX/Watts" }, // It looks like Speed and Watts should be siblings, but Garmin can't get // their namespace act very consistent. This works for a sample provided // by Laurent Desmons in 5/2013. - { &GtrnctrFormat::gtc_trk_spd, cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Extensions/TPX/Speed" }, + { &GtrnctrFormat::gtc_trk_spd, xg_cb_type::cb_cdata, "/Activities/Activity/Lap/Track/Trackpoint/Extensions/TPX/Speed" }, /* history tcx v1 */ - { &GtrnctrFormat::gtc_trk_s, cb_start, "/History/Run" }, - { &GtrnctrFormat::gtc_trk_ident,cb_cdata, "/History/Run/Id" }, - { &GtrnctrFormat::gtc_trk_lap_s,cb_start, "/History/Run/Lap" }, - { &GtrnctrFormat::gtc_trk_lap_e,cb_end, "/History/Run/Lap" }, - { &GtrnctrFormat::gtc_trk_pnt_s,cb_start, "/History/Run/Lap/Track/Trackpoint" }, - { &GtrnctrFormat::gtc_trk_pnt_e,cb_end, "/History/Run/Lap/Track/Trackpoint" }, - { &GtrnctrFormat::gtc_trk_utc, cb_cdata, "/History/Run/Lap/Track/Trackpoint/Time" }, - { &GtrnctrFormat::gtc_trk_lat, cb_cdata, "/History/Run/Lap/Track/Trackpoint/Position/LatitudeDegrees" }, - { &GtrnctrFormat::gtc_trk_long, cb_cdata, "/History/Run/Lap/Track/Trackpoint/Position/LongitudeDegrees" }, - { &GtrnctrFormat::gtc_trk_alt, cb_cdata, "/History/Run/Lap/Track/Trackpoint/AltitudeMeters" }, - { &GtrnctrFormat::gtc_trk_hr, cb_cdata, "/History/Run/Lap/Track/Trackpoint/HeartRateBpm" }, - { &GtrnctrFormat::gtc_trk_cad, cb_cdata, "/History/Run/Lap/Track/Trackpoint/Cadence" }, - - { &GtrnctrFormat::gtc_wpt_pnt_s,cb_start, "/Courses/Course/Lap/BeginPosition" }, - { &GtrnctrFormat::gtc_wpt_pnt_e,cb_end, "/Courses/Course/Lap/BeginPosition" }, - { &GtrnctrFormat::gtc_wpt_lat, cb_cdata, "/Courses/Course/Lap/BeginPosition/LatitudeDegrees" }, - { &GtrnctrFormat::gtc_wpt_long, cb_cdata, "/Courses/Course/Lap/BeginPosition/LongitudeDegrees" }, - { &GtrnctrFormat::gtc_trk_alt, cb_cdata, "/Courses/Course/Lap/BeginAltitudeMeters" } + { &GtrnctrFormat::gtc_trk_s, xg_cb_type::cb_start, "/History/Run" }, + { &GtrnctrFormat::gtc_trk_ident, xg_cb_type::cb_cdata, "/History/Run/Id" }, + { &GtrnctrFormat::gtc_trk_lap_s, xg_cb_type::cb_start, "/History/Run/Lap" }, + { &GtrnctrFormat::gtc_trk_lap_e, xg_cb_type::cb_end, "/History/Run/Lap" }, + { &GtrnctrFormat::gtc_trk_pnt_s, xg_cb_type::cb_start, "/History/Run/Lap/Track/Trackpoint" }, + { &GtrnctrFormat::gtc_trk_pnt_e, xg_cb_type::cb_end, "/History/Run/Lap/Track/Trackpoint" }, + { &GtrnctrFormat::gtc_trk_utc, xg_cb_type::cb_cdata, "/History/Run/Lap/Track/Trackpoint/Time" }, + { &GtrnctrFormat::gtc_trk_lat, xg_cb_type::cb_cdata, "/History/Run/Lap/Track/Trackpoint/Position/LatitudeDegrees" }, + { &GtrnctrFormat::gtc_trk_long, xg_cb_type::cb_cdata, "/History/Run/Lap/Track/Trackpoint/Position/LongitudeDegrees" }, + { &GtrnctrFormat::gtc_trk_alt, xg_cb_type::cb_cdata, "/History/Run/Lap/Track/Trackpoint/AltitudeMeters" }, + { &GtrnctrFormat::gtc_trk_hr, xg_cb_type::cb_cdata, "/History/Run/Lap/Track/Trackpoint/HeartRateBpm" }, + { &GtrnctrFormat::gtc_trk_cad, xg_cb_type::cb_cdata, "/History/Run/Lap/Track/Trackpoint/Cadence" }, + + { &GtrnctrFormat::gtc_wpt_pnt_s, xg_cb_type::cb_start, "/Courses/Course/Lap/BeginPosition" }, + { &GtrnctrFormat::gtc_wpt_pnt_e, xg_cb_type::cb_end, "/Courses/Course/Lap/BeginPosition" }, + { &GtrnctrFormat::gtc_wpt_lat, xg_cb_type::cb_cdata, "/Courses/Course/Lap/BeginPosition/LatitudeDegrees" }, + { &GtrnctrFormat::gtc_wpt_long, xg_cb_type::cb_cdata, "/Courses/Course/Lap/BeginPosition/LongitudeDegrees" }, + { &GtrnctrFormat::gtc_trk_alt, xg_cb_type::cb_cdata, "/Courses/Course/Lap/BeginAltitudeMeters" } }; + XmlGenericReader* xml_reader{nullptr}; int gtc_indent_level{}; }; diff --git a/kml.cc b/kml.cc index 8e59b3eca..d7e9c826b 100644 --- a/kml.cc +++ b/kml.cc @@ -57,7 +57,7 @@ #include "src/core/xmlstreamwriter.h" // for XmlStreamWriter #include "src/core/xmltag.h" // for xml_findfirst, xml_tag, fs_xml, xml_attribute, xml_findnext #include "units.h" // for UnitsFormatter, UnitsFormatter... -#include "xmlgeneric.h" // for cb_cdata, cb_end, cb_start, xg_callback, xg_string, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping +#include "xmlgeneric.h" // for cb_cdata, cb_end, cb_start, xg_callback, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping // Icons provided and hosted by Google. Used with permission. @@ -134,7 +134,7 @@ void KmlFormat::kml_step_color() kml_color_sequencer.seq += kml_color_sequencer.step; } -void KmlFormat::wpt_s(xg_string /*args*/, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::wpt_s(const QString& /*args*/, const QXmlStreamAttributes* /*attrs*/) { if (wpt_tmp) { fatal(MYNAME ": wpt_s: invalid kml file\n"); @@ -148,7 +148,7 @@ void KmlFormat::wpt_s(xg_string /*args*/, const QXmlStreamAttributes* /*attrs*/) wpt_timespan_end = gpsbabel::DateTime(); } -void KmlFormat::wpt_e(xg_string /*args*/, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::wpt_e(const QString& /*args*/, const QXmlStreamAttributes* /*attrs*/) { if (!wpt_tmp) { fatal(MYNAME ": wpt_e: invalid kml file\n"); @@ -163,7 +163,7 @@ void KmlFormat::wpt_e(xg_string /*args*/, const QXmlStreamAttributes* /*attrs*/) wpt_tmp_queued = false; } -void KmlFormat::wpt_name(xg_string args, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::wpt_name(const QString& args, const QXmlStreamAttributes* /*attrs*/) { if (!wpt_tmp) { fatal(MYNAME ": wpt_name: invalid kml file\n"); @@ -179,7 +179,7 @@ void KmlFormat::wpt_desc(const QString& args, const QXmlStreamAttributes* /*attr wpt_tmp->description += args.trimmed(); } -void KmlFormat::wpt_time(xg_string args, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::wpt_time(const QString& args, const QXmlStreamAttributes* /*attrs*/) { if (!wpt_tmp) { fatal(MYNAME ": wpt_time: invalid kml file\n"); @@ -187,12 +187,12 @@ void KmlFormat::wpt_time(xg_string args, const QXmlStreamAttributes* /*attrs*/) wpt_tmp->SetCreationTime(xml_parse_time(args)); } -void KmlFormat::wpt_ts_begin(xg_string args, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::wpt_ts_begin(const QString& args, const QXmlStreamAttributes* /*attrs*/) { wpt_timespan_begin = xml_parse_time(args); } -void KmlFormat::wpt_ts_end(xg_string args, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::wpt_ts_end(const QString& args, const QXmlStreamAttributes* /*attrs*/) { wpt_timespan_end = xml_parse_time(args); } @@ -215,14 +215,14 @@ void KmlFormat::wpt_coord(const QString& args, const QXmlStreamAttributes* /*att wpt_tmp_queued = true; } -void KmlFormat::wpt_icon(xg_string args, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::wpt_icon(const QString& args, const QXmlStreamAttributes* /*attrs*/) { if (wpt_tmp) { wpt_tmp->icon_descr = args; } } -void KmlFormat::trk_coord(xg_string args, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::trk_coord(const QString& args, const QXmlStreamAttributes* /*attrs*/) { auto* trk_head = new route_head; if (wpt_tmp && !wpt_tmp->shortname.isEmpty()) { @@ -274,7 +274,7 @@ void KmlFormat::trk_coord(xg_string args, const QXmlStreamAttributes* /*attrs*/) } } -void KmlFormat::gx_trk_s(xg_string /*args*/, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::gx_trk_s(const QString& /*args*/, const QXmlStreamAttributes* /*attrs*/) { gx_trk_head = new route_head; if (wpt_tmp && !wpt_tmp->shortname.isEmpty()) { @@ -290,7 +290,7 @@ void KmlFormat::gx_trk_s(xg_string /*args*/, const QXmlStreamAttributes* /*attrs gx_trk_coords = new QList>; } -void KmlFormat::gx_trk_e(xg_string /*args*/, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::gx_trk_e(const QString& /*args*/, const QXmlStreamAttributes* /*attrs*/) { // Check that for every temporal value (kml:when) in a kml:Track there is a position (kml:coord) value. // Check that for every temporal value (kml:when) in a gx:Track there is a position (gx:coord) value. @@ -331,7 +331,7 @@ void KmlFormat::gx_trk_e(xg_string /*args*/, const QXmlStreamAttributes* /*attrs gx_trk_coords = nullptr; } -void KmlFormat::gx_trk_when(xg_string args, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::gx_trk_when(const QString& args, const QXmlStreamAttributes* /*attrs*/) { if (! gx_trk_times) { fatal(MYNAME ": gx_trk_when: invalid kml file\n"); @@ -339,7 +339,7 @@ void KmlFormat::gx_trk_when(xg_string args, const QXmlStreamAttributes* /*attrs* gx_trk_times->append(xml_parse_time(args)); } -void KmlFormat::gx_trk_coord(xg_string args, const QXmlStreamAttributes* /*attrs*/) +void KmlFormat::gx_trk_coord(const QString& args, const QXmlStreamAttributes* /*attrs*/) { if (! gx_trk_coords) { fatal(MYNAME ": gx_trk_coord: invalid kml file\n"); @@ -355,17 +355,19 @@ void KmlFormat::gx_trk_coord(xg_string args, const QXmlStreamAttributes* /*attrs void KmlFormat::rd_init(const QString& fname) { - xml_init(fname, build_xg_tag_map(this, kml_map), nullptr, kml_tags_to_ignore, kml_tags_to_skip, true); + xml_reader = new XmlGenericReader; + xml_reader->xml_init(fname, this, kml_map, nullptr, kml_tags_to_ignore, kml_tags_to_skip); } void KmlFormat::read() { - xml_read(); + xml_reader->xml_read(); } void KmlFormat::rd_deinit() { - xml_deinit(); + delete xml_reader; + xml_reader = nullptr; } void KmlFormat::wr_init(const QString& fname) diff --git a/kml.h b/kml.h index 64b7f1f72..eef489c57 100644 --- a/kml.h +++ b/kml.h @@ -37,7 +37,7 @@ #include "src/core/file.h" // for File #include "src/core/xmlstreamwriter.h" // for XmlStreamWriter #include "units.h" // for UnitsFormatter -#include "xmlgeneric.h" // for cb_cdata, cb_end, cb_start, xg_callback, xg_string, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping +#include "xmlgeneric.h" // for cb_cdata, cb_end, cb_start, xg_callback, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping class KmlFormat : public Format @@ -331,29 +331,30 @@ class KmlFormat : public Format gb_color color; } kml_color_sequencer; - QList> kml_map = { - {&KmlFormat::wpt_s, cb_start, "/Placemark"}, - {&KmlFormat::wpt_e, cb_end, "/Placemark"}, - {&KmlFormat::wpt_name, cb_cdata, "/Placemark/name"}, - {&KmlFormat::wpt_desc, cb_cdata, "/Placemark/description"}, - {&KmlFormat::wpt_ts_begin, cb_cdata,"/Placemark/TimeSpan/begin"}, - {&KmlFormat::wpt_ts_end, cb_cdata, "/Placemark/TimeSpan/end"}, - {&KmlFormat::wpt_time, cb_cdata, "/Placemark/TimeStamp/when"}, + QList> kml_map = { + {&KmlFormat::wpt_s, xg_cb_type::cb_start, "/Placemark"}, + {&KmlFormat::wpt_e, xg_cb_type::cb_end, "/Placemark"}, + {&KmlFormat::wpt_name, xg_cb_type::cb_cdata, "/Placemark/name"}, + {&KmlFormat::wpt_desc, xg_cb_type::cb_cdata, "/Placemark/description"}, + {&KmlFormat::wpt_ts_begin, xg_cb_type::cb_cdata,"/Placemark/TimeSpan/begin"}, + {&KmlFormat::wpt_ts_end, xg_cb_type::cb_cdata, "/Placemark/TimeSpan/end"}, + {&KmlFormat::wpt_time, xg_cb_type::cb_cdata, "/Placemark/TimeStamp/when"}, // Alias for above used in KML 2.0 - {&KmlFormat::wpt_time, cb_cdata, "/Placemark/TimeInstant/timePosition"}, - {&KmlFormat::wpt_coord, cb_cdata, "/Placemark/(.+/)?Point/coordinates"}, - {&KmlFormat::wpt_icon, cb_cdata, "/Placemark/Style/Icon/href"}, - {&KmlFormat::trk_coord, cb_cdata, "/Placemark/(.+/)?LineString/coordinates"}, - {&KmlFormat::trk_coord, cb_cdata, "/Placemark/(.+)/?LinearRing/coordinates"}, - {&KmlFormat::gx_trk_s, cb_start, "/Placemark/(.+/)?gx:Track"}, - {&KmlFormat::gx_trk_e, cb_end, "/Placemark/(.+/)?gx:Track"}, - {&KmlFormat::gx_trk_when, cb_cdata, "/Placemark/(.+/)?gx:Track/when"}, - {&KmlFormat::gx_trk_coord, cb_cdata, "/Placemark/(.+/)?gx:Track/gx:coord"}, - {&KmlFormat::gx_trk_s, cb_start, "/Placemark/(.+/)?Track"}, // KML 2.3 - {&KmlFormat::gx_trk_e, cb_end, "/Placemark/(.+/)?Track"}, // KML 2.3 - {&KmlFormat::gx_trk_when, cb_cdata, "/Placemark/(.+/)?Track/when"}, // KML 2.3 - {&KmlFormat::gx_trk_coord, cb_cdata, "/Placemark/(.+/)?Track/coord"}, // KML 2.3 + {&KmlFormat::wpt_time, xg_cb_type::cb_cdata, "/Placemark/TimeInstant/timePosition"}, + {&KmlFormat::wpt_coord, xg_cb_type::cb_cdata, "/Placemark/(.+/)?Point/coordinates"}, + {&KmlFormat::wpt_icon, xg_cb_type::cb_cdata, "/Placemark/Style/Icon/href"}, + {&KmlFormat::trk_coord, xg_cb_type::cb_cdata, "/Placemark/(.+/)?LineString/coordinates"}, + {&KmlFormat::trk_coord, xg_cb_type::cb_cdata, "/Placemark/(.+)/?LinearRing/coordinates"}, + {&KmlFormat::gx_trk_s, xg_cb_type::cb_start, "/Placemark/(.+/)?gx:Track"}, + {&KmlFormat::gx_trk_e, xg_cb_type::cb_end, "/Placemark/(.+/)?gx:Track"}, + {&KmlFormat::gx_trk_when, xg_cb_type::cb_cdata, "/Placemark/(.+/)?gx:Track/when"}, + {&KmlFormat::gx_trk_coord, xg_cb_type::cb_cdata, "/Placemark/(.+/)?gx:Track/gx:coord"}, + {&KmlFormat::gx_trk_s, xg_cb_type::cb_start, "/Placemark/(.+/)?Track"}, // KML 2.3 + {&KmlFormat::gx_trk_e, xg_cb_type::cb_end, "/Placemark/(.+/)?Track"}, // KML 2.3 + {&KmlFormat::gx_trk_when, xg_cb_type::cb_cdata, "/Placemark/(.+/)?Track/when"}, // KML 2.3 + {&KmlFormat::gx_trk_coord, xg_cb_type::cb_cdata, "/Placemark/(.+/)?Track/coord"}, // KML 2.3 }; + XmlGenericReader* xml_reader{nullptr}; // The TimeSpan/begin and TimeSpan/end DateTimes: gpsbabel::DateTime wpt_timespan_begin, wpt_timespan_end; diff --git a/osm.cc b/osm.cc index 1409cc831..298f0b07c 100644 --- a/osm.cc +++ b/osm.cc @@ -34,7 +34,7 @@ #include "osm.h" #include "src/core/datetime.h" // for DateTime #include "src/core/xmlstreamwriter.h" // for XmlStreamWriter -#include "xmlgeneric.h" // for xg_string, build_xg_tag_map, xml_deinit, xml_init, xml_read +#include "xmlgeneric.h" // for xml_deinit, xml_init, xml_read #define MYNAME "osm" @@ -413,7 +413,7 @@ OsmFormat::osm_strip_html(const QString& str) } void -OsmFormat::osm_node_end(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +OsmFormat::osm_node_end(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { if (wpt) { if (wpt->wpt_flags.fmt_use) { @@ -426,7 +426,7 @@ OsmFormat::osm_node_end(xg_string /*unused*/, const QXmlStreamAttributes* /*unus } void -OsmFormat::osm_node(xg_string /*unused*/, const QXmlStreamAttributes* attrv) +OsmFormat::osm_node(const QString& /*unused*/, const QXmlStreamAttributes* attrv) { wpt = new Waypoint; @@ -457,7 +457,7 @@ OsmFormat::osm_node(xg_string /*unused*/, const QXmlStreamAttributes* attrv) } void -OsmFormat::osm_node_tag(xg_string /*unused*/, const QXmlStreamAttributes* attrv) +OsmFormat::osm_node_tag(const QString& /*unused*/, const QXmlStreamAttributes* attrv) { QString key, value; signed char ikey; @@ -510,7 +510,7 @@ OsmFormat::osm_node_tag(xg_string /*unused*/, const QXmlStreamAttributes* attrv) } void -OsmFormat::osm_way(xg_string /*unused*/, const QXmlStreamAttributes* attrv) +OsmFormat::osm_way(const QString& /*unused*/, const QXmlStreamAttributes* attrv) { rte = new route_head; // create a wpt to represent the route center if it has a center tag @@ -521,7 +521,7 @@ OsmFormat::osm_way(xg_string /*unused*/, const QXmlStreamAttributes* attrv) } void -OsmFormat::osm_way_nd(xg_string /*unused*/, const QXmlStreamAttributes* attrv) +OsmFormat::osm_way_nd(const QString& /*unused*/, const QXmlStreamAttributes* attrv) { if (attrv->hasAttribute("ref")) { QString atstr = attrv->value("ref").toString(); @@ -537,7 +537,7 @@ OsmFormat::osm_way_nd(xg_string /*unused*/, const QXmlStreamAttributes* attrv) } void -OsmFormat::osm_way_tag(xg_string /*unused*/, const QXmlStreamAttributes* attrv) +OsmFormat::osm_way_tag(const QString& /*unused*/, const QXmlStreamAttributes* attrv) { QString key, value; signed char ikey; @@ -574,7 +574,7 @@ OsmFormat::osm_way_tag(xg_string /*unused*/, const QXmlStreamAttributes* attrv) } void -OsmFormat::osm_way_center(xg_string /*unused*/, const QXmlStreamAttributes* attrv) +OsmFormat::osm_way_center(const QString& /*unused*/, const QXmlStreamAttributes* attrv) { wpt->wpt_flags.fmt_use = 1; @@ -587,7 +587,7 @@ OsmFormat::osm_way_center(xg_string /*unused*/, const QXmlStreamAttributes* attr } void -OsmFormat::osm_way_end(xg_string /*unused*/, const QXmlStreamAttributes* /*unused*/) +OsmFormat::osm_way_end(const QString& /*unused*/, const QXmlStreamAttributes* /*unused*/) { if (rte) { route_add_head(rte); @@ -615,19 +615,22 @@ OsmFormat::rd_init(const QString& fname) osm_features_init(); } - xml_init(fname, build_xg_tag_map(this, osm_map), nullptr, nullptr, nullptr, true); + xml_reader = new XmlGenericReader; + xml_reader->xml_init(fname, this, osm_map); } void OsmFormat::read() { - xml_read(); + xml_reader->xml_read(); } void OsmFormat::rd_deinit() { - xml_deinit(); + delete xml_reader; + xml_reader = nullptr; + waypoints.clear(); } diff --git a/osm.h b/osm.h index 87590b45b..4a07c2350 100644 --- a/osm.h +++ b/osm.h @@ -33,7 +33,7 @@ #include "format.h" // for Format #include "src/core/file.h" // for File #include "src/core/xmlstreamwriter.h" // for XmlStreamWriter -#include "xmlgeneric.h" // for xg_functor_map_entry, cb_start, cb_end, xg_string +#include "xmlgeneric.h" // for xg_functor_map_entry, cb_start, cb_end class OsmFormat : public Format @@ -88,14 +88,14 @@ class OsmFormat : public Format char osm_feature_ikey(const QString& key) const; QString osm_feature_symbol(int ikey, const char* value) const; static QString osm_strip_html(const QString& str); - void osm_node_end(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); - void osm_node(xg_string /* unused */, const QXmlStreamAttributes* attrv); - void osm_node_tag(xg_string /* unused */, const QXmlStreamAttributes* attrv); - void osm_way(xg_string /* unused */, const QXmlStreamAttributes* attrv); - void osm_way_nd(xg_string /* unused */, const QXmlStreamAttributes* attrv); - void osm_way_tag(xg_string /* unused */, const QXmlStreamAttributes* attrv); - void osm_way_center(xg_string /* unused */, const QXmlStreamAttributes* attrv); - void osm_way_end(xg_string /* unused */, const QXmlStreamAttributes* /* unused */); + void osm_node_end(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); + void osm_node(const QString& /* unused */, const QXmlStreamAttributes* attrv); + void osm_node_tag(const QString& /* unused */, const QXmlStreamAttributes* attrv); + void osm_way(const QString& /* unused */, const QXmlStreamAttributes* attrv); + void osm_way_nd(const QString& /* unused */, const QXmlStreamAttributes* attrv); + void osm_way_tag(const QString& /* unused */, const QXmlStreamAttributes* attrv); + void osm_way_center(const QString& /* unused */, const QXmlStreamAttributes* attrv); + void osm_way_end(const QString& /* unused */, const QXmlStreamAttributes* /* unused */); void osm_init_icons(); void osm_write_tag(const QString& key, const QString& value) const; void osm_disp_feature(const Waypoint* waypoint) const; @@ -133,15 +133,16 @@ class OsmFormat : public Format route_head* rte{}; Waypoint* wpt{}; - QList> osm_map = { - {&OsmFormat::osm_node, cb_start, "/osm/node"}, - {&OsmFormat::osm_node_tag, cb_start, "/osm/node/tag"}, - {&OsmFormat::osm_node_end, cb_end, "/osm/node"}, - {&OsmFormat::osm_way, cb_start, "/osm/way"}, - {&OsmFormat::osm_way_nd, cb_start, "/osm/way/nd"}, - {&OsmFormat::osm_way_tag, cb_start, "/osm/way/tag"}, - {&OsmFormat::osm_way_center, cb_start, "/osm/way/center"}, - {&OsmFormat::osm_way_end, cb_end, "/osm/way"} + QList> osm_map { + {&OsmFormat::osm_node, xg_cb_type::cb_start, "/osm/node"}, + {&OsmFormat::osm_node_tag, xg_cb_type::cb_start, "/osm/node/tag"}, + {&OsmFormat::osm_node_end, xg_cb_type::cb_end, "/osm/node"}, + {&OsmFormat::osm_way, xg_cb_type::cb_start, "/osm/way"}, + {&OsmFormat::osm_way_nd, xg_cb_type::cb_start, "/osm/way/nd"}, + {&OsmFormat::osm_way_tag, xg_cb_type::cb_start, "/osm/way/tag"}, + {&OsmFormat::osm_way_center, xg_cb_type::cb_start, "/osm/way/center"}, + {&OsmFormat::osm_way_end, xg_cb_type::cb_end, "/osm/way"} }; + XmlGenericReader* xml_reader{nullptr}; }; #endif // OSM_H_INCLUDED_ diff --git a/xmlgeneric.cc b/xmlgeneric.cc index 0d5a70c24..1aae5b6e7 100644 --- a/xmlgeneric.cc +++ b/xmlgeneric.cc @@ -19,37 +19,24 @@ */ -#include // for QByteArray -#include // for QHash -#include // for QIODevice, QIODevice::ReadOnly -#include // for QLatin1Char -#include -#include // for QStringView -#include // for QTextCodec -#include // for QXmlStreamAttributes -#include // for QXmlStreamReader, QXmlStreamReader::Characters, QXmlStreamReader::EndElement, QXmlStreamReader::IncludeChildElements, QXmlStreamReader::StartDocument, QXmlStreamReader::StartElement -#include // for qPrintable - -#include "defs.h" #include "xmlgeneric.h" -#include "src/core/file.h" // for File +#include // for as_const -enum xg_shortcut { - xg_shortcut_none = 0, - xg_shortcut_skip, - xg_shortcut_ignore -}; +#include // for QByteArray +#include // for QHash +#include // for QIODevice +#include // for QLatin1Char +#include // for QStringView +#include // for QTextCodec +#include // for QXmlStreamAttributes, QXmlStreamReader::Characters, QXmlStreamReader::EndElement, QXmlStreamReader::IncludeChildElements, QXmlStreamReader::StartDocument, QXmlStreamReader::StartElement +#include // for QXmlStreamReader +//#include // for QHash, QIODeviceBase::ReadOnly +#include // for qPrintable -static const QList* xg_tag_tbl; -static bool dynamic_tag_tbl; -static QHash* xg_shortcut_taglist; +#include "defs.h" // for fatal +#include "src/core/file.h" // for File -static QString rd_fname; -static QByteArray reader_data; -static const char* xg_encoding; -static QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); -static QTextCodec* codec = utf8_codec; // Qt has no vanilla ASCII encoding =( #define MYNAME "XML Reader" @@ -63,107 +50,60 @@ static QTextCodec* codec = utf8_codec; // Qt has no vanilla ASCII encoding =( * xml strains and insulates us from a lot of the grubbiness of expat. */ -static XgCallbackBase* -xml_tbl_lookup(const QString& tag, xg_cb_type cb_type) +XmlGenericReader::XgCallbackBase* +XmlGenericReader::xml_tbl_lookup(const QString& tag, xg_cb_type cb_type) { - for (const auto& tm : *xg_tag_tbl) { + for (const auto& tm : std::as_const(xg_tag_tbl)) { if (cb_type == tm.cb_type) { QRegularExpressionMatch match = tm.tag_re.match(tag); if (match.hasMatch()) { - return tm.tag_cb; + return tm.tag_cb.get(); } } } return nullptr; } -static void -xml_common_init(const QString& fname, const char* encoding, - const char* const* ignorelist, const char* const* skiplist) +void +XmlGenericReader::xml_common_init(const QString& fname, const char* encoding, + const char* const* ignorelist, const char* const* skiplist) { rd_fname = fname; - xg_encoding = encoding; - if (encoding) { - QTextCodec* tcodec = QTextCodec::codecForName(encoding); - if (tcodec) { - codec = tcodec; + if (encoding != nullptr) { + codec = QTextCodec::codecForName(encoding); + if (codec == nullptr) { + fatal(MYNAME " : codec \"%s\" is not available.\n", encoding); } + } else { + codec = QTextCodec::codecForName("UTF-8"); } - xg_shortcut_taglist = new QHash; + xg_shortcut_taglist.clear(); if (ignorelist != nullptr) { for (; ignorelist && *ignorelist; ++ignorelist) { - xg_shortcut_taglist->insert(QString::fromUtf8(*ignorelist), xg_shortcut_ignore); + xg_shortcut_taglist.insert(QString::fromUtf8(*ignorelist), xg_shortcut::sc_ignore); } } if (skiplist != nullptr) { for (; skiplist && *skiplist; ++skiplist) { - xg_shortcut_taglist->insert(QString::fromUtf8(*skiplist), xg_shortcut_skip); - } - } -} - -void -xml_init(const QString& fname, const QList* tbl, const char* encoding, - const char* const* ignorelist, const char* const* skiplist, bool dynamic_tbl) -{ - xg_tag_tbl = tbl; - dynamic_tag_tbl = dynamic_tbl; - - xml_common_init(fname, encoding, ignorelist, skiplist); -} - -void -xml_init(const QString& fname, const QList& tbl, const char* encoding, - const char* const* ignorelist, const char* const* skiplist) -{ - auto* tag_tbl = new QList; - dynamic_tag_tbl = true; - for (const auto& tm : tbl) { - auto* cb = new XgFunctionPtrCallback(tm.tag_cb); - QRegularExpression re(QRegularExpression::anchoredPattern(tm.tag_pattern)); - assert(re.isValid()); - tag_tbl->append({cb, tm.cb_type, re}); - } - xg_tag_tbl = tag_tbl; - - xml_common_init(fname, encoding, ignorelist, skiplist); -} - -void -xml_deinit() -{ - if (dynamic_tag_tbl) { - for (const auto& tm : *xg_tag_tbl) { - delete tm.tag_cb; + xg_shortcut_taglist.insert(QString::fromUtf8(*skiplist), xg_shortcut::sc_skip); } - delete xg_tag_tbl; } - xg_tag_tbl = nullptr; - - reader_data.clear(); - rd_fname.clear(); - - xg_encoding = nullptr; - codec = utf8_codec; - - delete xg_shortcut_taglist; - xg_shortcut_taglist = nullptr; } -static xg_shortcut -xml_shortcut(QStringView name) +XmlGenericReader::xg_shortcut +XmlGenericReader::xml_shortcut(QStringView name) { QString key = name.toString(); - if (xg_shortcut_taglist->contains(key)) { - return xg_shortcut_taglist->value(key); + if (xg_shortcut_taglist.contains(key)) { + return xg_shortcut_taglist.value(key); } - return xg_shortcut_none; + return xg_shortcut::sc_none; } -static void -xml_run_parser(QXmlStreamReader& reader) +void +XmlGenericReader::xml_run_parser(QXmlStreamReader& reader) { XgCallbackBase* cb; QString current_tag; @@ -184,10 +124,10 @@ xml_run_parser(QXmlStreamReader& reader) case QXmlStreamReader::StartElement: switch (xml_shortcut(reader.name())) { - case xg_shortcut_skip: + case xg_shortcut::sc_skip: reader.skipCurrentElement(); goto readnext; - case xg_shortcut_ignore: + case xg_shortcut::sc_ignore: goto readnext; default: break; @@ -196,13 +136,13 @@ xml_run_parser(QXmlStreamReader& reader) current_tag.append(QLatin1Char('/')); current_tag.append(reader.qualifiedName()); - cb = xml_tbl_lookup(current_tag, cb_start); + cb = xml_tbl_lookup(current_tag, xg_cb_type::cb_start); if (cb) { const QXmlStreamAttributes attrs = reader.attributes(); (*cb)(nullptr, &attrs); } - cb = xml_tbl_lookup(current_tag, cb_cdata); + cb = xml_tbl_lookup(current_tag, xg_cb_type::cb_cdata); if (cb) { QString c = reader.readElementText(QXmlStreamReader::IncludeChildElements); // readElementText advances the tokenType to QXmlStreamReader::EndElement, @@ -215,11 +155,11 @@ xml_run_parser(QXmlStreamReader& reader) break; case QXmlStreamReader::EndElement: - if (xml_shortcut(reader.name()) == xg_shortcut_skip) { + if (xml_shortcut(reader.name()) == xg_shortcut::sc_skip) { goto readnext; } - cb = xml_tbl_lookup(current_tag, cb_end); + cb = xml_tbl_lookup(current_tag, xg_cb_type::cb_end); if (cb) { (*cb)(reader.name().toString(), nullptr); } @@ -242,7 +182,7 @@ xml_run_parser(QXmlStreamReader& reader) } } -void xml_read() +void XmlGenericReader::xml_read() { gpsbabel::File file(rd_fname); @@ -252,7 +192,7 @@ void xml_read() xml_run_parser(reader); if (reader.hasError()) { - fatal(MYNAME ":Read error: %s (%s, line %lld, col %lld)\n", + fatal(MYNAME " :Read error: %s (%s, line %lld, col %lld)\n", qPrintable(reader.errorString()), qPrintable(file.fileName()), reader.lineNumber(), @@ -262,14 +202,14 @@ void xml_read() // Chucks some bytes into the global QByteArray buffer and waits for // xml_readstring() to parse. -void xml_readprefixstring(const char* str) +void XmlGenericReader::xml_readprefixstring(const char* str) { reader_data.append(str); } // Parses a bytestream as if it were a file. Looks for an // for assert +#include // for make_shared, shared_ptr +#include // for QByteArray +#include // for QHash #include // for QList #include // for QRegularExpression #include // for QString +#include // for QStringView +#include // for QTextCodec #include // for QXmlStreamAttributes +#include // for QXmlStreamReader -// Maybe the XmlGeneric string callback really shouldn't have a type -// of its own; this was a crutch during the move from char* to QString. -// It's "just" a search and replace to make it go away, but it might -// be convenient to overload some day. -using xg_string = const QString&; - -enum xg_cb_type { - cb_start = 1, +enum class xg_cb_type { + cb_unknown = 0, + cb_start, cb_cdata, cb_end, }; -class XgCallbackBase -{ -public: - XgCallbackBase() = default; - virtual ~XgCallbackBase() = default; - XgCallbackBase(const XgCallbackBase&) = delete; - XgCallbackBase& operator=(const XgCallbackBase&) = delete; - XgCallbackBase(XgCallbackBase&&) = delete; - XgCallbackBase& operator=(XgCallbackBase&&) = delete; - - virtual void operator()(xg_string string, const QXmlStreamAttributes* attrs) const = 0; -}; - -template -class XgFunctor : public XgCallbackBase +/* + * xml_init will build and own a table of XgFunctor and/or + * XgFunctionPtrCallback entries from a list + * of non-static member functions and/or function pointers. + * + * QList> some_map = { + * {&SomeFormat::memberfn, cb_start, "/Placemark"}, + * {staticfn, cb_cdata, "/Placemark/coord"}, + * }; + * + * The this pointer from the Format instance must be passed if any + * of the callbacks are member functions, otherwise nullptr can be passed + * as this. + * + * xml_init(fname, this, some_map, encoding, ignorelist, skiplist); + * + */ +class XmlGenericReader { public: - using XgCb = void (XgFormat::*)(xg_string, const QXmlStreamAttributes*); - XgFunctor(XgFormat* obj, XgCb cb) : that_(obj), cb_(cb) {} - void operator()(xg_string string, const QXmlStreamAttributes* attrs) const override + /* Types */ + + // formats pass a list containing member function pointers and/or function pointers. + template + struct xg_fmt_map_entry { + // Constructor from a Member Function Pointer + using XgMfpCb = void (MyFormat::*)(const QString&, const QXmlStreamAttributes*); + xg_fmt_map_entry(XgMfpCb mfp, xg_cb_type ty, const char* tp) : tag_mfp_cb(mfp), cb_type(ty), tag_pattern(tp) {} + // Constructor from a Function Pointer. + using XgFpCb = void (const QString&, const QXmlStreamAttributes*); + xg_fmt_map_entry(XgFpCb fp, xg_cb_type ty, const char* tp) : tag_fp_cb(fp), cb_type(ty), tag_pattern(tp) {} + + /* Data Members */ + + XgMfpCb tag_mfp_cb{nullptr}; + XgFpCb* tag_fp_cb{nullptr}; + xg_cb_type cb_type{xg_cb_type::cb_unknown}; + const char* tag_pattern{nullptr}; + }; + + /* Member Functions */ + + template + void xml_init(const QString& fname, MyFormat* instance, const QList>& tbl, + const char* encoding = nullptr, + const char* const* ignorelist = nullptr, + const char* const* skiplist = nullptr) { - (that_->*cb_)(string, attrs); + build_xg_tag_map(instance, tbl); + + xml_common_init(fname, encoding, ignorelist, skiplist); } + void xml_read(); + void xml_readstring(const char* str); + void xml_readprefixstring(const char* str); + void xml_readunicode(const QString& str); + private: - XgFormat* that_; - XgCb cb_; -}; + /* Types */ -class XgFunctionPtrCallback : public XgCallbackBase -{ -public: - using XgCb = void (xg_string, const QXmlStreamAttributes*); - explicit XgFunctionPtrCallback(XgCb cb) : cb_(cb) {} - void operator()(xg_string string, const QXmlStreamAttributes* attrs) const override + class XgCallbackBase + { + public: + XgCallbackBase() = default; + virtual ~XgCallbackBase() = default; + XgCallbackBase(const XgCallbackBase&) = delete; + XgCallbackBase& operator=(const XgCallbackBase&) = delete; + XgCallbackBase(XgCallbackBase&&) = delete; + XgCallbackBase& operator=(XgCallbackBase&&) = delete; + + virtual void operator()(const QString& string, const QXmlStreamAttributes* attrs) const = 0; + }; + + template + class XgFunctor : public XgCallbackBase { - (*cb_)(string, attrs); + public: + using XgCb = void (XgFormat::*)(const QString&, const QXmlStreamAttributes*); + XgFunctor(XgFormat* obj, XgCb cb) : that_(obj), cb_(cb) {} + void operator()(const QString& string, const QXmlStreamAttributes* attrs) const override + { + (that_->*cb_)(string, attrs); + } + + private: + XgFormat* that_; + XgCb cb_; + }; + + class XgFunctionPtrCallback : public XgCallbackBase + { + public: + using XgCb = void (const QString&, const QXmlStreamAttributes*); + explicit XgFunctionPtrCallback(XgCb cb) : cb_(cb) {} + void operator()(const QString& string, const QXmlStreamAttributes* attrs) const override + { + (*cb_)(string, attrs); + } + + private: + XgCb* cb_; + }; + + // xml processing uses a list of xg_tag_map_entries. + struct xg_tag_map_entry { + std::shared_ptr tag_cb{nullptr}; + xg_cb_type cb_type{xg_cb_type::cb_unknown}; + QRegularExpression tag_re; + }; + + enum class xg_shortcut { + sc_none = 0, + sc_skip, + sc_ignore + }; + + /* Member Functions */ + + XgCallbackBase* xml_tbl_lookup(const QString& tag, xg_cb_type cb_type); + void xml_common_init(const QString& fname, const char* encoding, + const char* const* ignorelist, const char* const* skiplist); + xg_shortcut xml_shortcut(QStringView name); + void xml_run_parser(QXmlStreamReader& reader); + + // translate xg_fmt_map_entries to xg_tag_map_entries. + template + void build_xg_tag_map(MyFormat* instance, const QList>& map) + { + xg_tag_tbl.clear(); + for (const auto& entry : map) { + xg_tag_map_entry tme; + if (entry.tag_mfp_cb != nullptr) { + tme.tag_cb = std::make_shared>(instance, entry.tag_mfp_cb); + } else { + tme.tag_cb = std::make_shared(entry.tag_fp_cb); + } + QRegularExpression re(QRegularExpression::anchoredPattern(entry.tag_pattern)); + assert(re.isValid()); + tme.cb_type = entry.cb_type; + tme.tag_re = re; + xg_tag_tbl.append(tme); + } } -private: - XgCb* cb_; -}; + /* Data Members */ -// xml processing uses a QList. -// You may generated this yourself. See method 1 below. -// Or it may be generated for you using one of the subsequent -// methods. -struct xg_tag_map_entry { - XgCallbackBase* tag_cb; - xg_cb_type cb_type; - QRegularExpression tag_re; -}; + QList xg_tag_tbl; + QHash xg_shortcut_taglist; -// Table generation from an array containing function pointers. -// The above table can be generated by xml_init. See method 2 below. -// This is how things done historically before the Format class was -// introduced. -using xg_callback = void (xg_string, const QXmlStreamAttributes*); -struct xg_tag_mapping { - xg_callback* tag_cb; - xg_cb_type cb_type; - const char* tag_pattern; -}; + QString rd_fname; + QByteArray reader_data; + QTextCodec* codec{nullptr}; // Qt has no vanilla ASCII encoding =( -// Table generation from a list containing member function pointers. -// The above table can be generated by xml_init. See method 3 below. -template -struct xg_functor_map_entry { - using XgCb = void (MyFormat::*)(xg_string, const QXmlStreamAttributes*); - XgCb tag_cb; - xg_cb_type cb_type; - const char* tag_pattern; }; -template -QList* build_xg_tag_map(MyFormat* instance, const QList& map) -{ - auto* tag_tbl = new QList; - for (const auto& entry : map) { - auto* tag_cb = new XgFunctor(instance, entry.tag_cb); - QRegularExpression re(QRegularExpression::anchoredPattern(entry.tag_pattern)); - assert(re.isValid()); - tag_tbl->append({tag_cb, entry.cb_type, re}); - } - return tag_tbl; -} - -/* - * There are multiple ways to initialize with xml_init. - * - * 1. Build your own QList, and pass it. - * You own the table, you must do any required clean up. - * Your callbacks may be a mix of function pointers wrapped in XgFunctors - * and non-static member functions wrapped in XgFunctionPtrCallbacks. - * and XgFunctionPtrCallback(for static member functions or global functions) entries. - * xml_init(fname, tbl, encoding, ignorelist, skiplist, false); - * You must set the dynamic_tbl parameter to false so xml_deninit doesn't - * attempt to free the table resources when xml_deinit is called. - * - * 2. Have xml_init build and own a table of XgFunctionPtrCallback entries - * from an list of function pointers, i.e. a QList of xg_tag_mapping elements. - * This only works when all callbacks are function pointers. - * xml_init(fname, tbl, encoding, ignorelist, skiplist); - * Generated table entries will automatically be freed. - * - * 3. Have xml_init build and own a table of XgFunctor entries from a list - * of non-static member functions, i.e. a QList. - * This only works when all callbacks are non-static member functions. - * xml_init(fname, build_xg_tag_map(instance, map), encoding, ignorelist, skiplist, true); - * You must set the dynamic_tbl parameter to true to free the generated table - * resources when xml_deinit is called. - * - */ -void xml_init(const QString& fname, const QList* tbl, const char* encoding, - const char* const* ignorelist = nullptr, - const char* const* skiplist = nullptr, bool dynamic_tbl = false); -void xml_init(const QString& fname, const QList& tbl,const char* encoding, - const char* const* ignorelist = nullptr, - const char* const* skiplist = nullptr); -void xml_read(); -void xml_readstring(const char* str); -void xml_readprefixstring(const char* str); -void xml_readunicode(const QString& str); -void xml_deinit(); - #endif // XMLGENERIC_H_INCLUDED_ From 476cfa6beae071166263352c3bd93b527693a20a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 08:26:12 -0700 Subject: [PATCH 058/132] Bump actions/setup-python from 4 to 5 (#1245) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/macos.yml | 2 +- .github/workflows/windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index cdd796ec1..d6f6294c2 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -52,7 +52,7 @@ jobs: - name: Qt install setup if: steps.cache.outputs.cache-hit != 'true' - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.9' diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index fa003068d..71b288a1a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -82,7 +82,7 @@ jobs: - name: Install Qt setup(aqt) if: steps.cache.outputs.cache-hit != 'true' - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.9' From 34a25de2c1d3b22ccecfcefe7e900e6d554c2895 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 16 Dec 2023 08:20:43 -0700 Subject: [PATCH 059/132] remove CMakeSettings.json (#1246) which had machine specific windows configuration values. --- CMakeSettings.json | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 CMakeSettings.json diff --git a/CMakeSettings.json b/CMakeSettings.json deleted file mode 100644 index 8e1f10f59..000000000 --- a/CMakeSettings.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:/Qt/6.5.3/msvc2019_64", - "buildCommandArgs": "", - "ctestCommandArgs": "" - }, - { - "name": "x64-Clang-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "-DCMAKE_PREFIX_PATH=C:/Qt/6.5.3/msvc2019_64 -DCMAKE_VERBOSE_MAKEFILE=ON", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "inheritEnvironments": [ "clang_cl_x64_x64" ] - } - ] -} \ No newline at end of file From 1176172d848fdb4f33a3099ee1ac1975ddcd686a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 18 Dec 2023 06:17:09 -0700 Subject: [PATCH 060/132] modernize google maps javascript (#1247) to avoid: "js: Google Maps JavaScript API has been loaded directly without a callback. This is not supported and can lead to race conditions and suboptimal performance. For supported loading patterns please see https://goo.gle/js-api-loading" --- gui/gmapbase.html | 56 +++++++++++++++++++++++++++++++++++------------ gui/map.cc | 3 +-- gui/map.h | 5 +++++ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/gui/gmapbase.html b/gui/gmapbase.html index 15a50f8be..71422331a 100644 --- a/gui/gmapbase.html +++ b/gui/gmapbase.html @@ -3,8 +3,14 @@ Google Maps JavaScript - - + diff --git a/gui/map.cc b/gui/map.cc index 228959f21..e6e82fa60 100644 --- a/gui/map.cc +++ b/gui/map.cc @@ -76,8 +76,6 @@ Map::Map(QWidget* parent, stopWatch_.start(); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); manager_ = new QNetworkAccessManager(this); - connect(this,&QWebEngineView::loadFinished, - this,&Map::loadFinishedX); this->logTime("Start map constructor"); auto* mclicker = new MarkerClicker(this); @@ -85,6 +83,7 @@ Map::Map(QWidget* parent, this->page()->setWebChannel(channel); // Note: A current limitation is that objects must be registered before any client is initialized. channel->registerObject(QStringLiteral("mclicker"), mclicker); + connect(mclicker, &MarkerClicker::loadFinished, this, &Map::loadFinishedX); connect(mclicker, &MarkerClicker::markerClicked, this, &Map::markerClicked); connect(mclicker, &MarkerClicker::logTime, this, &Map::logTime); diff --git a/gui/map.h b/gui/map.h index 1ea743aab..6c2e69b7a 100644 --- a/gui/map.h +++ b/gui/map.h @@ -60,10 +60,15 @@ public slots: { emit logTime(s); } + void loadedX() + { + emit loadFinished(true); + } signals: void markerClicked(int t, int i); void logTime(const QString& s); + void loadFinished(bool b); }; From 596a8737ae8f5a70391bf662e1cf287854f5a035 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 09:02:24 -0700 Subject: [PATCH 061/132] Bump github/codeql-action from 2 to 3 (#1248) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 27efd0025..b3d5abc35 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -46,7 +46,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -57,7 +57,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -71,4 +71,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 From 1cad1ae5dbf863201cf246c76b7d9a7194a8188d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 09:52:23 -0700 Subject: [PATCH 062/132] Bump actions/upload-artifact from 3 to 4 (#1249) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/gendocs.yml | 2 +- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- .github/workflows/windows.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gendocs.yml b/.github/workflows/gendocs.yml index 3e9ea55a3..a6b64fb8a 100644 --- a/.github/workflows/gendocs.yml +++ b/.github/workflows/gendocs.yml @@ -48,7 +48,7 @@ jobs: - name: 'Upload Artifacts' if: matrix.RELEASE - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Documents path: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index d6f6294c2..4a0a20e26 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -100,7 +100,7 @@ jobs: ./tools/uploadtool/upload_github.sh gui/GPSBabel-*.dmg - name: 'Upload Artifacts' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: MacOS_Installer ${{ join(matrix.*) }} path: gui/GPSBabel-*.dmg diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9a1f92802..d4c8cec17 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -113,7 +113,7 @@ jobs: ./tools/uploadtool/upload_github.sh ${{ steps.build-snap.outputs.snap }} - name: Upload Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ steps.build-snap.outputs.snap }} path: ${{ steps.build-snap.outputs.snap }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 71b288a1a..563f8d825 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -126,7 +126,7 @@ jobs: ./tools/uploadtool/upload_github.sh bld/gui/GPSBabel-*-Setup.exe - name: 'Upload Artifacts' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Windows_Installer ${{ join(matrix.*) }} path: | From ae253b3a397e82a9f86c1a574ea8cea63a73612c Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 18 Dec 2023 10:13:36 -0700 Subject: [PATCH 063/132] update codeql workflow template (#1250) --- .github/workflows/codeql-analysis.yml | 46 ++++++++++++++++----------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b3d5abc35..614f9ef20 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -8,16 +8,14 @@ # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. -# ******** NOTE ******** - +# name: "CodeQL" on: push: - branches: [ master ] + branches: [ "master" ] pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] + branches: [ "master" ] schedule: - cron: '27 4 * * 2' workflow_dispatch: ~ @@ -25,7 +23,17 @@ on: jobs: analyze: name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. runs-on: ubuntu-latest + timeout-minutes: 360 + permissions: + actions: read + contents: read + security-events: write container: image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_jammy env: @@ -34,11 +42,11 @@ jobs: strategy: fail-fast: false matrix: - # language: [ 'cpp', 'javascript' ] - language: [ 'cpp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + language: [ 'c-cpp' ] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - name: Checkout repository @@ -52,23 +60,25 @@ jobs: # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. #- run: | - # make bootstrap - # make release + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 From bd237f2b7f5ee5d87dc24d9b539533f1c548e16f Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 23 Dec 2023 07:22:07 -0700 Subject: [PATCH 064/132] update codacy badge (#1251) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3aeabed79..8a2a957ec 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Passing is good. We like passing. The latest official release is available at http://www.gpsbabel.org/download.html. -We are proud of our rating on Codacy: [![Codacy Badge](https://app.codacy.com/project/badge/Grade/b87af2d47325425cbaeea5805eff2c6b)](https://www.codacy.com/gh/GPSBabel/gpsbabel/dashboard?utm_source=github.com&utm_medium=referral&utm_content=GPSBabel/gpsbabel&utm_campaign=Badge_Grade) +We are proud of our rating on Codacy: [![Codacy Badge](https://app.codacy.com/project/badge/Grade/b87af2d47325425cbaeea5805eff2c6b)](https://app.codacy.com/gh/GPSBabel/gpsbabel/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) If you aren't a programmer or a writer, we need help with gear, hosting costs, tool license prices, answering questions on the mailing lists, etc. Please [support GPSBabel](https://www.gpsbabel.org/contribute.html) any way you can. From ad68e02d07ec83e8dc1f7cc8c6b79ba098cda2a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 10:42:05 -0700 Subject: [PATCH 065/132] Bump actions/cache from 3 to 4 (#1256) Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/macos.yml | 2 +- .github/workflows/windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 4a0a20e26..adb6086ba 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -44,7 +44,7 @@ jobs: uses: actions/checkout@v4 - name: Cache Qt - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache with: path: ~/Cache diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 563f8d825..ba596ce36 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -74,7 +74,7 @@ jobs: uses: actions/checkout@v4 - name: Cache Qt - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache with: path: ~/Cache From 6081fe49ec15ea8fd0c081aa6a55b0a266755fe7 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 25 Jan 2024 09:14:44 -0700 Subject: [PATCH 066/132] update shapelib to 1.6.0 (#1257) --- shapelib/{COPYING => LICENSE-LGPL} | 24 +- shapelib/LICENSE-MIT | 21 + shapelib/README.GPSBabel | 2 +- shapelib/dbf_api.html | 46 +- shapelib/dbfopen.c | 2325 +++++++++--------- shapelib/safileio.c | 293 +-- shapelib/shapefil.h | 1028 ++++---- shapelib/shapelib.html | 76 +- shapelib/shp_api.html | 90 +- shapelib/shpopen.c | 3565 ++++++++++++++-------------- 10 files changed, 3505 insertions(+), 3965 deletions(-) rename shapelib/{COPYING => LICENSE-LGPL} (97%) create mode 100644 shapelib/LICENSE-MIT diff --git a/shapelib/COPYING b/shapelib/LICENSE-LGPL similarity index 97% rename from shapelib/COPYING rename to shapelib/LICENSE-LGPL index 0b643ac83..12735e6c2 100644 --- a/shapelib/COPYING +++ b/shapelib/LICENSE-LGPL @@ -1,16 +1,15 @@ - - GNU LIBRARY GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -100,7 +99,7 @@ works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. - GNU LIBRARY GENERAL PUBLIC LICENSE + GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which @@ -134,7 +133,7 @@ such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - + 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an @@ -412,7 +411,7 @@ decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. @@ -435,9 +434,9 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS - Appendix: How to Apply These Terms to Your New Libraries + How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that @@ -464,8 +463,8 @@ convey the exclusion of warranty; and each file should have at least the Library General Public License for more details. You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. @@ -480,4 +479,3 @@ necessary. Here is a sample; alter the names: Ty Coon, President of Vice That's all there is to it! - diff --git a/shapelib/LICENSE-MIT b/shapelib/LICENSE-MIT new file mode 100644 index 000000000..34fb3422c --- /dev/null +++ b/shapelib/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 1999, Frank Warmerdam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/shapelib/README.GPSBabel b/shapelib/README.GPSBabel index a3f953509..f5bba78a8 100644 --- a/shapelib/README.GPSBabel +++ b/shapelib/README.GPSBabel @@ -1,4 +1,4 @@ -This is a subset of Shapelib v1.5.0 from http://shapelib.maptools.org/ +This is a subset of Shapelib v1.6.0 from http://shapelib.maptools.org/ The source is unmodified. It's subsetted here only to reduce the amount of size in our tree that it takes and to reduce ongoing diff --git a/shapelib/dbf_api.html b/shapelib/dbf_api.html index 0bd0da1b8..cdd29a22f 100644 --- a/shapelib/dbf_api.html +++ b/shapelib/dbf_api.html @@ -22,13 +22,13 @@

DBFOpen()

pszDBFFile: The name of the xBase (.dbf) file to access. pszAccess: The fopen() style access string. At this time only - "rb" (read-only binary) and "rb+" (read/write binary) + "rb" (read-only binary) and "rb+" (read/write binary) should be used. The DBFOpen() function should be used to establish access to an existing - xBase format table file. The returned DBFHandle is passed to other - access functions, and DBFClose() should be invoked to recover resources, and + xBase format table file. The returned DBFHandle is passed to other + access functions, and DBFClose() should be invoked to recover resources, and flush changes to disk when complete. The DBFCreate() function should called to create new xBase files. As a convenience, DBFOpen() can be called with the name of a .shp or .shx file, and it will figure out the @@ -43,8 +43,8 @@

DBFCreate()

pszDBFFile: The name of the xBase (.dbf) file to create. - - The DBFCreate() function creates a new xBase format file with the given + + The DBFCreate() function creates a new xBase format file with the given name, and returns an access handle that can be used with other DBF functions. The newly created file will have no fields, and no records. Fields should be added with DBFAddField() before any records add written. @@ -105,19 +105,19 @@

DBFGetFieldInfo()

hDBF: The access handle for the file to be queried, as returned by DBFOpen(), or DBFCreate(). - iField: The field to be queried. This should be a number between + iField: The field to be queried. This should be a number between 0 and n-1, where n is the number fields on the file, as returned by DBFGetFieldCount(). pszFieldName: If this pointer is not NULL the name of the requested field - will be written to this location. The pszFieldName buffer + will be written to this location. The pszFieldName buffer should be at least 12 character is size in order to hold - the longest possible field name of 11 characters plus a + the longest possible field name of 11 characters plus a terminating zero character. pnWidth: If this pointer is not NULL, the width of the requested field will be returned in the int pointed to by pnWidth. This is - the width in characters. + the width in characters. pnDecimals: If this pointer is not NULL, the number of decimal places precision defined for the field will be returned. This is @@ -145,7 +145,7 @@

DBFGetFieldInfo()

DBFAddField()

-int DBFAddField( DBFHandle hDBF, const char * pszFieldName, 
+int DBFAddField( DBFHandle hDBF, const char * pszFieldName,
                  DBFFieldType eType, int nWidth, int nDecimals );
 
   hDBF:		The access handle for the file to be updated, as returned by
@@ -186,7 +186,7 @@ 

DBFReadIntegerAttribute()

 int DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
-  
+
   hDBF:		The access handle for the file to be queried, as returned by
 		DBFOpen(), or DBFCreate().
 
@@ -206,7 +206,7 @@ 

DBFReadDoubleAttribute()

 double DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
-  
+
   hDBF:		The access handle for the file to be queried, as returned by
 		DBFOpen(), or DBFCreate().
 
@@ -226,7 +226,7 @@ 

DBFReadStringAttribute()

 const char *DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
-  
+
   hDBF:		The access handle for the file to be queried, as returned by
 		DBFOpen(), or DBFCreate().
 
@@ -237,10 +237,10 @@ 

DBFReadStringAttribute()

The DBFReadStringAttribute() will read the value of one field and return - it as a string. This function may be used on any field type (including + it as a string. This function may be used on any field type (including FTInteger and FTDouble) and will return the string representation stored in the .dbf file. The returned pointer is to an internal buffer - which is only valid untill the next DBF function call. It's contents may + which is only valid until the next DBF function call. It's contents may be copied with normal string functions such as strcpy(), or strdup(). If the TRIM_DBF_WHITESPACE macro is defined in shapefil.h (it is by default) then all leading and trailing space (ASCII 32) characters will be stripped @@ -252,7 +252,7 @@

DBFIsAttributeNULL()

 int DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
-  
+
   hDBF:		The access handle for the file to be queried, as returned by
 		DBFOpen(), or DBFCreate().
 
@@ -265,7 +265,7 @@ 

DBFIsAttributeNULL()

This function will return TRUE if the indicated field is NULL valued otherwise FALSE. Note that NULL fields are represented in the .dbf file as having all spaces in the field. Reading NULL fields will result in - a value of 0.0 or an empty string with the other DBFRead*Attribute() + a value of 0.0 or an empty string with the other DBFRead*Attribute() functions.

@@ -289,7 +289,7 @@

DBFWriteIntegerAttribute

The DBFWriteIntegerAttribute() function is used to write a value to a numeric field (FTInteger, or FTDouble). If the write succeeds the value TRUE will -be returned, otherwise FALSE will be returned. If the value is too large to +be returned, otherwise FALSE will be returned. If the value is too large to fit in the field, it will be truncated and FALSE returned.

@@ -313,7 +313,7 @@

DBFWriteDoubleAttribute()

The DBFWriteDoubleAttribute() function is used to write a value to a numeric field (FTInteger, or FTDouble). If the write succeeds the value TRUE will -be returned, otherwise FALSE will be returned. If the value is too large to +be returned, otherwise FALSE will be returned. If the value is too large to fit in the field, it will be truncated and FALSE returned.

@@ -336,8 +336,8 @@

DBFWriteStringAttribute()

The DBFWriteStringAttribute() function is used to write a value to a string -field (FString). If the write succeeds the value TRUE willbe returned, -otherwise FALSE will be returned. If the value is too large to +field (FString). If the write succeeds the value TRUE willbe returned, +otherwise FALSE will be returned. If the value is too large to fit in the field, it will be truncated and FALSE returned.

@@ -358,7 +358,7 @@

DBFWriteNULLAttribute()

The DBFWriteNULLAttribute() function is used to clear the indicated field to a NULL value. In the .dbf file this is represented by setting the entire -field to spaces. If the write succeeds the value TRUE willbe returned, +field to spaces. If the write succeeds the value TRUE willbe returned, otherwise FALSE will be returned.

@@ -414,7 +414,7 @@

DBFGetNativeFieldType()

hDBF: The access handle for the file. iField: The field index to query. - +
This function returns the DBF type code of the indicated field. It will diff --git a/shapelib/dbfopen.c b/shapelib/dbfopen.c index 218db70cf..ee5be97f0 100644 --- a/shapelib/dbfopen.c +++ b/shapelib/dbfopen.c @@ -1,5 +1,4 @@ /****************************************************************************** - * $Id: dbfopen.c,v 1.94 2018-08-16 15:39:07 erouault Exp $ * * Project: Shapelib * Purpose: Implementation of .dbf access API documented in dbf_api.html. @@ -7,199 +6,16 @@ * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam - * Copyright (c) 2012-2013, Even Rouault + * Copyright (c) 2012-2019, Even Rouault * - * This software is available under the following "MIT Style" license, - * or at the option of the licensee under the LGPL (see COPYING). This - * option is discussed in more detail in shapelib.html. - * - * -- - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - ****************************************************************************** - * - * $Log: dbfopen.c,v $ - * Revision 1.94 2018-08-16 15:39:07 erouault - * * shpopen.c, dbfopen.c, shptree.c, sbnsearch.c: resyc with GDAL - * internal shapelib. Mostly to allow building those files as C++ - * without warning. Also add FTDate entry in DBFFieldType - * (see https://github.com/OSGeo/gdal/pull/308). And some other - * code cleanups - * - * Revision 1.93 2018-08-16 15:24:46 erouault - * * dbfopen.c: fix a bug where the end of file character was - * written on top of the first character of the first field name - * when deleting a field on a .dbf without records. - * Fixes https://github.com/OSGeo/gdal/issues/863 - * - * Revision 1.92 2016-12-05 18:44:08 erouault - * * dbfopen.c, shapefil.h: write DBF end-of-file character 0x1A by default. - * This behaviour can be controlled with the DBFSetWriteEndOfFileChar() - * function. - * - * Revision 1.91 2016-12-05 12:44:05 erouault - * * Major overhaul of Makefile build system to use autoconf/automake. - * - * * Warning fixes in contrib/ - * - * Revision 1.90 2016-12-04 15:30:15 erouault - * * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with - * GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo - * structures extended with new members. New functions: - * DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX, - * SHPSetFastModeReadObject - * - * * sbnsearch.c: new file to implement original ESRI .sbn spatial - * index reading. (no write support). New functions: - * SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree, - * SBNSearchDiskTreeInteger, SBNSearchFreeIds - * - * * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates - * with new file and symbols. - * - * * commit: helper script to cvs commit - * - * Revision 1.89 2011-07-24 05:59:25 fwarmerdam - * minimize use of CPLError in favor of SAHooks.Error() - * - * Revision 1.88 2011-05-13 17:35:17 fwarmerdam - * added DBFReorderFields() and DBFAlterFields() functions (from Even) - * - * Revision 1.87 2011-05-07 22:41:02 fwarmerdam - * ensure pending record is flushed when adding a native field (GDAL #4073) - * - * Revision 1.86 2011-04-17 15:15:29 fwarmerdam - * Removed unused variable. - * - * Revision 1.85 2010-12-06 16:09:34 fwarmerdam - * fix buffer read overrun fetching code page (bug 2276) - * - * Revision 1.84 2009-10-29 19:59:48 fwarmerdam - * avoid crash on truncated header (gdal #3093) - * - * Revision 1.83 2008/11/12 14:28:15 fwarmerdam - * DBFCreateField() now works on files with records - * - * Revision 1.82 2008/11/11 17:47:09 fwarmerdam - * added DBFDeleteField() function - * - * Revision 1.81 2008/01/03 17:48:13 bram - * in DBFCreate, use default code page LDID/87 (= 0x57, ANSI) - * instead of LDID/3. This seems to be the same as what ESRI - * would be doing by default. - * - * Revision 1.80 2007/12/30 14:36:39 fwarmerdam - * avoid syntax issue with last comment. - * - * Revision 1.79 2007/12/30 14:35:48 fwarmerdam - * Avoid char* / unsigned char* warnings. - * - * Revision 1.78 2007/12/18 18:28:07 bram - * - create hook for client specific atof (bugzilla ticket 1615) - * - check for NULL handle before closing cpCPG file, and close after reading. - * - * Revision 1.77 2007/12/15 20:25:21 bram - * dbfopen.c now reads the Code Page information from the DBF file, and exports - * this information as a string through the DBFGetCodePage function. This is - * either the number from the LDID header field ("LDID/") or as the - * content of an accompanying .CPG file. When creating a DBF file, the code can - * be set using DBFCreateEx. - * - * Revision 1.76 2007/12/12 22:21:32 bram - * DBFClose: check for NULL psDBF handle before trying to close it. - * - * Revision 1.75 2007/12/06 13:58:19 fwarmerdam - * make sure file offset calculations are done in as SAOffset - * - * Revision 1.74 2007/12/06 07:00:25 fwarmerdam - * dbfopen now using SAHooks for fileio - * - * Revision 1.73 2007/09/03 19:48:11 fwarmerdam - * move DBFReadAttribute() static dDoubleField into dbfinfo - * - * Revision 1.72 2007/09/03 19:34:06 fwarmerdam - * Avoid use of static tuple buffer in DBFReadTuple() - * - * Revision 1.71 2006/06/22 14:37:18 fwarmerdam - * avoid memory leak if dbfopen fread fails - * - * Revision 1.70 2006/06/17 17:47:05 fwarmerdam - * use calloc() for dbfinfo in DBFCreate - * - * Revision 1.69 2006/06/17 15:34:32 fwarmerdam - * disallow creating fields wider than 255 - * - * Revision 1.68 2006/06/17 15:12:40 fwarmerdam - * Fixed C++ style comments. - * - * Revision 1.67 2006/06/17 00:24:53 fwarmerdam - * Don't treat non-zero decimals values as high order byte for length - * for strings. It causes serious corruption for some files. - * http://bugzilla.remotesensing.org/show_bug.cgi?id=1202 - * - * Revision 1.66 2006/03/29 18:26:20 fwarmerdam - * fixed bug with size of pachfieldtype in dbfcloneempty - * - * Revision 1.65 2006/02/15 01:14:30 fwarmerdam - * added DBFAddNativeFieldType - * - * Revision 1.64 2006/02/09 00:29:04 fwarmerdam - * Changed to put spaces into string fields that are NULL as - * per http://bugzilla.maptools.org/show_bug.cgi?id=316. - * - * Revision 1.63 2006/01/25 15:35:43 fwarmerdam - * check success on DBFFlushRecord - * - * Revision 1.62 2006/01/10 16:28:03 fwarmerdam - * Fixed typo in CPLError. - * - * Revision 1.61 2006/01/10 16:26:29 fwarmerdam - * Push loading record buffer into DBFLoadRecord. - * Implement CPL error reporting if USE_CPL defined. - * - * Revision 1.60 2006/01/05 01:27:27 fwarmerdam - * added dbf deletion mark/fetch - * - * Revision 1.59 2005/03/14 15:20:28 fwarmerdam - * Fixed last change. - * - * Revision 1.58 2005/03/14 15:18:54 fwarmerdam - * Treat very wide fields with no decimals as double. This is - * more than 32bit integer fields. - * - * Revision 1.57 2005/02/10 20:16:54 fwarmerdam - * Make the pszStringField buffer for DBFReadAttribute() static char [256] - * as per bug 306. - * - * Revision 1.56 2005/02/10 20:07:56 fwarmerdam - * Fixed bug 305 in DBFCloneEmpty() - header length problem. - * - * Revision 1.55 2004/09/26 20:23:46 fwarmerdam - * avoid warnings with rcsid and signed/unsigned stuff - * - * Revision 1.54 2004/09/15 16:26:10 fwarmerdam - * Treat all blank numeric fields as null too. - */ + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later + ******************************************************************************/ #include "shapefil.h" #include +#include +#include #include #include #include @@ -208,76 +24,62 @@ #include "cpl_string.h" #else -#if defined(WIN32) || defined(_WIN32) -# define STRCASECMP(a,b) (stricmp(a,b)) -# else +#if defined(_MSC_VER) +#define STRCASECMP(a, b) (_stricmp(a, b)) +#elif defined(WIN32) || defined(_WIN32) +#define STRCASECMP(a, b) (stricmp(a, b)) +#else #include -# define STRCASECMP(a,b) (strcasecmp(a,b)) +#define STRCASECMP(a, b) (strcasecmp(a, b)) #endif #if defined(_MSC_VER) -# if _MSC_VER < 1900 -# define snprintf _snprintf -# endif +#if _MSC_VER < 1900 +#define snprintf _snprintf +#endif #elif defined(WIN32) || defined(_WIN32) -# ifndef snprintf -# define snprintf _snprintf -# endif +#ifndef snprintf +#define snprintf _snprintf +#endif #endif #define CPLsprintf sprintf #define CPLsnprintf snprintf #endif -SHP_CVSID("$Id: dbfopen.c,v 1.94 2018-08-16 15:39:07 erouault Exp $") - #ifndef FALSE -# define FALSE 0 -# define TRUE 1 +#define FALSE 0 +#define TRUE 1 #endif /* File header size */ -#define XBASE_FILEHDR_SZ 32 +#define XBASE_FILEHDR_SZ 32 #define HEADER_RECORD_TERMINATOR 0x0D /* See http://www.manmrk.net/tutorials/database/xbase/dbf.html */ -#define END_OF_FILE_CHARACTER 0x1A +#define END_OF_FILE_CHARACTER 0x1A #ifdef USE_CPL -CPL_INLINE static void CPL_IGNORE_RET_VAL_INT(CPL_UNUSED int unused) {} +CPL_INLINE static void CPL_IGNORE_RET_VAL_INT(CPL_UNUSED int unused) +{ +} #else #define CPL_IGNORE_RET_VAL_INT(x) x #endif #ifdef __cplusplus -#define STATIC_CAST(type,x) static_cast(x) -#define REINTERPRET_CAST(type,x) reinterpret_cast(x) -#define CONST_CAST(type,x) const_cast(x) +#define STATIC_CAST(type, x) static_cast(x) +#define REINTERPRET_CAST(type, x) reinterpret_cast(x) +#define CONST_CAST(type, x) const_cast(x) #define SHPLIB_NULLPTR nullptr #else -#define STATIC_CAST(type,x) ((type)(x)) -#define REINTERPRET_CAST(type,x) ((type)(x)) -#define CONST_CAST(type,x) ((type)(x)) +#define STATIC_CAST(type, x) ((type)(x)) +#define REINTERPRET_CAST(type, x) ((type)(x)) +#define CONST_CAST(type, x) ((type)(x)) #define SHPLIB_NULLPTR NULL #endif -/************************************************************************/ -/* SfRealloc() */ -/* */ -/* A realloc cover function that will access a NULL pointer as */ -/* a valid input. */ -/************************************************************************/ - -static void * SfRealloc( void * pMem, int nNewSize ) - -{ - if( pMem == SHPLIB_NULLPTR ) - return malloc(nNewSize); - else - return realloc(pMem,nNewSize); -} - /************************************************************************/ /* DBFWriteHeader() */ /* */ @@ -288,19 +90,18 @@ static void * SfRealloc( void * pMem, int nNewSize ) /************************************************************************/ static void DBFWriteHeader(DBFHandle psDBF) - { - unsigned char abyHeader[XBASE_FILEHDR_SZ] = { 0 }; + unsigned char abyHeader[XBASE_FILEHDR_SZ] = {0}; - if( !psDBF->bNoHeader ) + if (!psDBF->bNoHeader) return; psDBF->bNoHeader = FALSE; -/* -------------------------------------------------------------------- */ -/* Initialize the file header information. */ -/* -------------------------------------------------------------------- */ - abyHeader[0] = 0x03; /* memo field? - just copying */ + /* -------------------------------------------------------------------- */ + /* Initialize the file header information. */ + /* -------------------------------------------------------------------- */ + abyHeader[0] = 0x03; /* memo field? - just copying */ /* write out update date */ abyHeader[1] = STATIC_CAST(unsigned char, psDBF->nUpdateYearSince1900); @@ -317,35 +118,33 @@ static void DBFWriteHeader(DBFHandle psDBF) abyHeader[29] = STATIC_CAST(unsigned char, psDBF->iLanguageDriver); -/* -------------------------------------------------------------------- */ -/* Write the initial 32 byte file header, and all the field */ -/* descriptions. */ -/* -------------------------------------------------------------------- */ - psDBF->sHooks.FSeek( psDBF->fp, 0, 0 ); - psDBF->sHooks.FWrite( abyHeader, XBASE_FILEHDR_SZ, 1, psDBF->fp ); - psDBF->sHooks.FWrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, - psDBF->fp ); - -/* -------------------------------------------------------------------- */ -/* Write out the newline character if there is room for it. */ -/* -------------------------------------------------------------------- */ - if( psDBF->nHeaderLength > XBASE_FLDHDR_SZ*psDBF->nFields + - XBASE_FLDHDR_SZ ) + /* -------------------------------------------------------------------- */ + /* Write the initial 32 byte file header, and all the field */ + /* descriptions. */ + /* -------------------------------------------------------------------- */ + psDBF->sHooks.FSeek(psDBF->fp, 0, 0); + psDBF->sHooks.FWrite(abyHeader, XBASE_FILEHDR_SZ, 1, psDBF->fp); + psDBF->sHooks.FWrite(psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, + psDBF->fp); + + /* -------------------------------------------------------------------- */ + /* Write out the newline character if there is room for it. */ + /* -------------------------------------------------------------------- */ + if (psDBF->nHeaderLength > + XBASE_FLDHDR_SZ * psDBF->nFields + XBASE_FLDHDR_SZ) { - char cNewline; - - cNewline = HEADER_RECORD_TERMINATOR; - psDBF->sHooks.FWrite( &cNewline, 1, 1, psDBF->fp ); + char cNewline = HEADER_RECORD_TERMINATOR; + psDBF->sHooks.FWrite(&cNewline, 1, 1, psDBF->fp); } -/* -------------------------------------------------------------------- */ -/* If the file is new, add a EOF character. */ -/* -------------------------------------------------------------------- */ - if( psDBF->nRecords == 0 && psDBF->bWriteEndOfFileChar ) + /* -------------------------------------------------------------------- */ + /* If the file is new, add a EOF character. */ + /* -------------------------------------------------------------------- */ + if (psDBF->nRecords == 0 && psDBF->bWriteEndOfFileChar) { char ch = END_OF_FILE_CHARACTER; - psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp ); + psDBF->sHooks.FWrite(&ch, 1, 1, psDBF->fp); } } @@ -355,125 +154,149 @@ static void DBFWriteHeader(DBFHandle psDBF) /* Write out the current record if there is one. */ /************************************************************************/ -static int DBFFlushRecord( DBFHandle psDBF ) - +static bool DBFFlushRecord(DBFHandle psDBF) { - SAOffset nRecordOffset; - - if( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 ) + if (psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1) { - psDBF->bCurrentRecordModified = FALSE; - - nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset, psDBF->nCurrentRecord) - + psDBF->nHeaderLength; + psDBF->bCurrentRecordModified = FALSE; + + const SAOffset nRecordOffset = + psDBF->nRecordLength * + STATIC_CAST(SAOffset, psDBF->nCurrentRecord) + + psDBF->nHeaderLength; + + /* -------------------------------------------------------------------- */ + /* Guard FSeek with check for whether we're already at position; */ + /* no-op FSeeks defeat network filesystems' write buffering. */ + /* -------------------------------------------------------------------- */ + if (psDBF->bRequireNextWriteSeek || + psDBF->sHooks.FTell(psDBF->fp) != nRecordOffset) + { + if (psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0) != 0) + { + char szMessage[128]; + snprintf( + szMessage, sizeof(szMessage), + "Failure seeking to position before writing DBF record %d.", + psDBF->nCurrentRecord); + psDBF->sHooks.Error(szMessage); + return false; + } + } - if( psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ) != 0 - || psDBF->sHooks.FWrite( psDBF->pszCurrentRecord, - psDBF->nRecordLength, - 1, psDBF->fp ) != 1 ) + if (psDBF->sHooks.FWrite(psDBF->pszCurrentRecord, psDBF->nRecordLength, + 1, psDBF->fp) != 1) { char szMessage[128]; - snprintf( szMessage, sizeof(szMessage), "Failure writing DBF record %d.", - psDBF->nCurrentRecord ); - psDBF->sHooks.Error( szMessage ); - return FALSE; + snprintf(szMessage, sizeof(szMessage), + "Failure writing DBF record %d.", psDBF->nCurrentRecord); + psDBF->sHooks.Error(szMessage); + return false; } - if( psDBF->nCurrentRecord == psDBF->nRecords - 1 ) + /* -------------------------------------------------------------------- */ + /* If next op is also a write, allow possible skipping of FSeek. */ + /* -------------------------------------------------------------------- */ + psDBF->bRequireNextWriteSeek = FALSE; + + if (psDBF->nCurrentRecord == psDBF->nRecords - 1) { - if( psDBF->bWriteEndOfFileChar ) + if (psDBF->bWriteEndOfFileChar) { char ch = END_OF_FILE_CHARACTER; - psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp ); + psDBF->sHooks.FWrite(&ch, 1, 1, psDBF->fp); } } } - return TRUE; + return true; } /************************************************************************/ /* DBFLoadRecord() */ /************************************************************************/ -static int DBFLoadRecord( DBFHandle psDBF, int iRecord ) - +static bool DBFLoadRecord(DBFHandle psDBF, int iRecord) { - if( psDBF->nCurrentRecord != iRecord ) + if (psDBF->nCurrentRecord != iRecord) { - SAOffset nRecordOffset; + if (!DBFFlushRecord(psDBF)) + return false; - if( !DBFFlushRecord( psDBF ) ) - return FALSE; - - nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,iRecord) + psDBF->nHeaderLength; + const SAOffset nRecordOffset = + psDBF->nRecordLength * STATIC_CAST(SAOffset, iRecord) + + psDBF->nHeaderLength; - if( psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, SEEK_SET ) != 0 ) + if (psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, SEEK_SET) != 0) { char szMessage[128]; - snprintf( szMessage, sizeof(szMessage), "fseek(%ld) failed on DBF file.", - STATIC_CAST(long, nRecordOffset) ); - psDBF->sHooks.Error( szMessage ); - return FALSE; + snprintf(szMessage, sizeof(szMessage), + "fseek(%ld) failed on DBF file.", + STATIC_CAST(long, nRecordOffset)); + psDBF->sHooks.Error(szMessage); + return false; } - if( psDBF->sHooks.FRead( psDBF->pszCurrentRecord, - psDBF->nRecordLength, 1, psDBF->fp ) != 1 ) + if (psDBF->sHooks.FRead(psDBF->pszCurrentRecord, psDBF->nRecordLength, + 1, psDBF->fp) != 1) { char szMessage[128]; - snprintf( szMessage, sizeof(szMessage), "fread(%d) failed on DBF file.", - psDBF->nRecordLength ); - psDBF->sHooks.Error( szMessage ); - return FALSE; + snprintf(szMessage, sizeof(szMessage), + "fread(%d) failed on DBF file.", psDBF->nRecordLength); + psDBF->sHooks.Error(szMessage); + return false; } - psDBF->nCurrentRecord = iRecord; + psDBF->nCurrentRecord = iRecord; + /* -------------------------------------------------------------------- */ + /* Require a seek for next write in case of mixed R/W operations. */ + /* -------------------------------------------------------------------- */ + psDBF->bRequireNextWriteSeek = TRUE; } - return TRUE; + return true; } /************************************************************************/ /* DBFUpdateHeader() */ /************************************************************************/ -void SHPAPI_CALL -DBFUpdateHeader( DBFHandle psDBF ) - +void SHPAPI_CALL DBFUpdateHeader(DBFHandle psDBF) { - unsigned char abyFileHeader[XBASE_FILEHDR_SZ]; - - if( psDBF->bNoHeader ) - DBFWriteHeader( psDBF ); + if (psDBF->bNoHeader) + DBFWriteHeader(psDBF); - if( !DBFFlushRecord( psDBF ) ) + if (!DBFFlushRecord(psDBF)) return; - psDBF->sHooks.FSeek( psDBF->fp, 0, 0 ); - psDBF->sHooks.FRead( abyFileHeader, sizeof(abyFileHeader), 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, 0, 0); + + unsigned char abyFileHeader[XBASE_FILEHDR_SZ] = {0}; + psDBF->sHooks.FRead(abyFileHeader, 1, sizeof(abyFileHeader), psDBF->fp); abyFileHeader[1] = STATIC_CAST(unsigned char, psDBF->nUpdateYearSince1900); abyFileHeader[2] = STATIC_CAST(unsigned char, psDBF->nUpdateMonth); abyFileHeader[3] = STATIC_CAST(unsigned char, psDBF->nUpdateDay); abyFileHeader[4] = STATIC_CAST(unsigned char, psDBF->nRecords & 0xFF); - abyFileHeader[5] = STATIC_CAST(unsigned char, (psDBF->nRecords>>8) & 0xFF); - abyFileHeader[6] = STATIC_CAST(unsigned char, (psDBF->nRecords>>16) & 0xFF); - abyFileHeader[7] = STATIC_CAST(unsigned char, (psDBF->nRecords>>24) & 0xFF); + abyFileHeader[5] = + STATIC_CAST(unsigned char, (psDBF->nRecords >> 8) & 0xFF); + abyFileHeader[6] = + STATIC_CAST(unsigned char, (psDBF->nRecords >> 16) & 0xFF); + abyFileHeader[7] = + STATIC_CAST(unsigned char, (psDBF->nRecords >> 24) & 0xFF); - psDBF->sHooks.FSeek( psDBF->fp, 0, 0 ); - psDBF->sHooks.FWrite( abyFileHeader, sizeof(abyFileHeader), 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, 0, 0); + psDBF->sHooks.FWrite(abyFileHeader, sizeof(abyFileHeader), 1, psDBF->fp); - psDBF->sHooks.FFlush( psDBF->fp ); + psDBF->sHooks.FFlush(psDBF->fp); } /************************************************************************/ /* DBFSetLastModifiedDate() */ /************************************************************************/ -void SHPAPI_CALL -DBFSetLastModifiedDate( DBFHandle psDBF, int nYYSince1900, int nMM, int nDD ) +void SHPAPI_CALL DBFSetLastModifiedDate(DBFHandle psDBF, int nYYSince1900, + int nMM, int nDD) { psDBF->nUpdateYearSince1900 = nYYSince1900; psDBF->nUpdateMonth = nMM; @@ -486,30 +309,27 @@ DBFSetLastModifiedDate( DBFHandle psDBF, int nYYSince1900, int nMM, int nDD ) /* Open a .dbf file. */ /************************************************************************/ -DBFHandle SHPAPI_CALL -DBFOpen( const char * pszFilename, const char * pszAccess ) +DBFHandle SHPAPI_CALL DBFOpen(const char *pszFilename, const char *pszAccess) { SAHooks sHooks; - SASetupDefaultHooks( &sHooks ); + SASetupDefaultHooks(&sHooks); - return DBFOpenLL( pszFilename, pszAccess, &sHooks ); + return DBFOpenLL(pszFilename, pszAccess, &sHooks); } /************************************************************************/ /* DBFGetLenWithoutExtension() */ /************************************************************************/ -static int DBFGetLenWithoutExtension(const char* pszBasename) +static int DBFGetLenWithoutExtension(const char *pszBasename) { - int i; - int nLen = STATIC_CAST(int, strlen(pszBasename)); - for( i = nLen-1; - i > 0 && pszBasename[i] != '/' && pszBasename[i] != '\\'; - i-- ) + const int nLen = STATIC_CAST(int, strlen(pszBasename)); + for (int i = nLen - 1; + i > 0 && pszBasename[i] != '/' && pszBasename[i] != '\\'; i--) { - if( pszBasename[i] == '.' ) + if (pszBasename[i] == '.') { return i; } @@ -523,65 +343,58 @@ static int DBFGetLenWithoutExtension(const char* pszBasename) /* Open a .dbf file. */ /************************************************************************/ -DBFHandle SHPAPI_CALL -DBFOpenLL( const char * pszFilename, const char * pszAccess, SAHooks *psHooks ) - +DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess, + const SAHooks *psHooks) { - DBFHandle psDBF; - SAFile pfCPG; - unsigned char *pabyBuf; - int nFields, nHeadLen, iField; - char *pszFullname; - int nBufSize = 500; - int nLenWithoutExtension; - -/* -------------------------------------------------------------------- */ -/* We only allow the access strings "rb" and "r+". */ -/* -------------------------------------------------------------------- */ - if( strcmp(pszAccess,"r") != 0 && strcmp(pszAccess,"r+") != 0 - && strcmp(pszAccess,"rb") != 0 && strcmp(pszAccess,"rb+") != 0 - && strcmp(pszAccess,"r+b") != 0 ) + /* -------------------------------------------------------------------- */ + /* We only allow the access strings "rb" and "r+". */ + /* -------------------------------------------------------------------- */ + if (strcmp(pszAccess, "r") != 0 && strcmp(pszAccess, "r+") != 0 && + strcmp(pszAccess, "rb") != 0 && strcmp(pszAccess, "rb+") != 0 && + strcmp(pszAccess, "r+b") != 0) return SHPLIB_NULLPTR; - if( strcmp(pszAccess,"r") == 0 ) + if (strcmp(pszAccess, "r") == 0) pszAccess = "rb"; - if( strcmp(pszAccess,"r+") == 0 ) + if (strcmp(pszAccess, "r+") == 0) pszAccess = "rb+"; -/* -------------------------------------------------------------------- */ -/* Compute the base (layer) name. If there is any extension */ -/* on the passed in filename we will strip it off. */ -/* -------------------------------------------------------------------- */ - nLenWithoutExtension = DBFGetLenWithoutExtension(pszFilename); - pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); + /* -------------------------------------------------------------------- */ + /* Compute the base (layer) name. If there is any extension */ + /* on the passed in filename we will strip it off. */ + /* -------------------------------------------------------------------- */ + const int nLenWithoutExtension = DBFGetLenWithoutExtension(pszFilename); + char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); memcpy(pszFullname, pszFilename, nLenWithoutExtension); memcpy(pszFullname + nLenWithoutExtension, ".dbf", 5); - psDBF = STATIC_CAST(DBFHandle, calloc( 1, sizeof(DBFInfo) )); - psDBF->fp = psHooks->FOpen( pszFullname, pszAccess ); - memcpy( &(psDBF->sHooks), psHooks, sizeof(SAHooks) ); + DBFHandle psDBF = STATIC_CAST(DBFHandle, calloc(1, sizeof(DBFInfo))); + psDBF->fp = psHooks->FOpen(pszFullname, pszAccess, psHooks->pvUserData); + memcpy(&(psDBF->sHooks), psHooks, sizeof(SAHooks)); - if( psDBF->fp == SHPLIB_NULLPTR ) + if (psDBF->fp == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".DBF", 5); - psDBF->fp = psDBF->sHooks.FOpen(pszFullname, pszAccess ); + psDBF->fp = + psDBF->sHooks.FOpen(pszFullname, pszAccess, psHooks->pvUserData); } memcpy(pszFullname + nLenWithoutExtension, ".cpg", 5); - pfCPG = psHooks->FOpen( pszFullname, "r" ); - if( pfCPG == SHPLIB_NULLPTR ) + SAFile pfCPG = psHooks->FOpen(pszFullname, "r", psHooks->pvUserData); + if (pfCPG == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".CPG", 5); - pfCPG = psHooks->FOpen( pszFullname, "r" ); + pfCPG = psHooks->FOpen(pszFullname, "r", psHooks->pvUserData); } - free( pszFullname ); + free(pszFullname); - if( psDBF->fp == SHPLIB_NULLPTR ) + if (psDBF->fp == SHPLIB_NULLPTR) { - free( psDBF ); - if( pfCPG ) psHooks->FClose( pfCPG ); + free(psDBF); + if (pfCPG) + psHooks->FClose(pfCPG); return SHPLIB_NULLPTR; } @@ -589,84 +402,88 @@ DBFOpenLL( const char * pszFilename, const char * pszAccess, SAHooks *psHooks ) psDBF->nCurrentRecord = -1; psDBF->bCurrentRecordModified = FALSE; -/* -------------------------------------------------------------------- */ -/* Read Table Header info */ -/* -------------------------------------------------------------------- */ - pabyBuf = STATIC_CAST(unsigned char *, malloc(nBufSize)); - if( psDBF->sHooks.FRead( pabyBuf, XBASE_FILEHDR_SZ, 1, psDBF->fp ) != 1 ) + /* -------------------------------------------------------------------- */ + /* Read Table Header info */ + /* -------------------------------------------------------------------- */ + const int nBufSize = 500; + unsigned char *pabyBuf = STATIC_CAST(unsigned char *, malloc(nBufSize)); + if (psDBF->sHooks.FRead(pabyBuf, XBASE_FILEHDR_SZ, 1, psDBF->fp) != 1) { - psDBF->sHooks.FClose( psDBF->fp ); - if( pfCPG ) psDBF->sHooks.FClose( pfCPG ); - free( pabyBuf ); - free( psDBF ); + psDBF->sHooks.FClose(psDBF->fp); + if (pfCPG) + psDBF->sHooks.FClose(pfCPG); + free(pabyBuf); + free(psDBF); return SHPLIB_NULLPTR; } DBFSetLastModifiedDate(psDBF, pabyBuf[1], pabyBuf[2], pabyBuf[3]); - psDBF->nRecords = - pabyBuf[4]|(pabyBuf[5]<<8)|(pabyBuf[6]<<16)|((pabyBuf[7]&0x7f)<<24); + psDBF->nRecords = pabyBuf[4] | (pabyBuf[5] << 8) | (pabyBuf[6] << 16) | + ((pabyBuf[7] & 0x7f) << 24); - psDBF->nHeaderLength = nHeadLen = pabyBuf[8]|(pabyBuf[9]<<8); - psDBF->nRecordLength = pabyBuf[10]|(pabyBuf[11]<<8); + const int nHeadLen = pabyBuf[8] | (pabyBuf[9] << 8); + psDBF->nHeaderLength = nHeadLen; + psDBF->nRecordLength = pabyBuf[10] | (pabyBuf[11] << 8); psDBF->iLanguageDriver = pabyBuf[29]; if (psDBF->nRecordLength == 0 || nHeadLen < XBASE_FILEHDR_SZ) { - psDBF->sHooks.FClose( psDBF->fp ); - if( pfCPG ) psDBF->sHooks.FClose( pfCPG ); - free( pabyBuf ); - free( psDBF ); + psDBF->sHooks.FClose(psDBF->fp); + if (pfCPG) + psDBF->sHooks.FClose(pfCPG); + free(pabyBuf); + free(psDBF); return SHPLIB_NULLPTR; } - psDBF->nFields = nFields = (nHeadLen - XBASE_FILEHDR_SZ) / XBASE_FLDHDR_SZ; + const int nFields = (nHeadLen - XBASE_FILEHDR_SZ) / XBASE_FLDHDR_SZ; + psDBF->nFields = nFields; /* coverity[tainted_data] */ psDBF->pszCurrentRecord = STATIC_CAST(char *, malloc(psDBF->nRecordLength)); -/* -------------------------------------------------------------------- */ -/* Figure out the code page from the LDID and CPG */ -/* -------------------------------------------------------------------- */ - + /* -------------------------------------------------------------------- */ + /* Figure out the code page from the LDID and CPG */ + /* -------------------------------------------------------------------- */ psDBF->pszCodePage = SHPLIB_NULLPTR; - if( pfCPG ) + if (pfCPG) { - size_t n; - memset( pabyBuf, 0, nBufSize); - psDBF->sHooks.FRead( pabyBuf, nBufSize - 1, 1, pfCPG ); - n = strcspn( REINTERPRET_CAST(char *, pabyBuf), "\n\r" ); - if( n > 0 ) + memset(pabyBuf, 0, nBufSize); + psDBF->sHooks.FRead(pabyBuf, 1, nBufSize - 1, pfCPG); + const size_t n = strcspn(REINTERPRET_CAST(char *, pabyBuf), "\n\r"); + if (n > 0) { pabyBuf[n] = '\0'; psDBF->pszCodePage = STATIC_CAST(char *, malloc(n + 1)); - memcpy( psDBF->pszCodePage, pabyBuf, n + 1 ); + memcpy(psDBF->pszCodePage, pabyBuf, n + 1); } - psDBF->sHooks.FClose( pfCPG ); + psDBF->sHooks.FClose(pfCPG); } - if( psDBF->pszCodePage == SHPLIB_NULLPTR && pabyBuf[29] != 0 ) + if (psDBF->pszCodePage == SHPLIB_NULLPTR && pabyBuf[29] != 0) { - snprintf( REINTERPRET_CAST(char *, pabyBuf), nBufSize, "LDID/%d", psDBF->iLanguageDriver ); - psDBF->pszCodePage = STATIC_CAST(char *, malloc(strlen(REINTERPRET_CAST(char*, pabyBuf)) + 1)); - strcpy( psDBF->pszCodePage, REINTERPRET_CAST(char *, pabyBuf) ); + snprintf(REINTERPRET_CAST(char *, pabyBuf), nBufSize, "LDID/%d", + psDBF->iLanguageDriver); + psDBF->pszCodePage = STATIC_CAST( + char *, malloc(strlen(REINTERPRET_CAST(char *, pabyBuf)) + 1)); + strcpy(psDBF->pszCodePage, REINTERPRET_CAST(char *, pabyBuf)); } -/* -------------------------------------------------------------------- */ -/* Read in Field Definitions */ -/* -------------------------------------------------------------------- */ - - pabyBuf = STATIC_CAST(unsigned char *, SfRealloc(pabyBuf,nHeadLen)); + /* -------------------------------------------------------------------- */ + /* Read in Field Definitions */ + /* -------------------------------------------------------------------- */ + pabyBuf = STATIC_CAST(unsigned char *, realloc(pabyBuf, nHeadLen)); psDBF->pszHeader = REINTERPRET_CAST(char *, pabyBuf); - psDBF->sHooks.FSeek( psDBF->fp, XBASE_FILEHDR_SZ, 0 ); - if( psDBF->sHooks.FRead( pabyBuf, nHeadLen-XBASE_FILEHDR_SZ, 1, - psDBF->fp ) != 1 ) + psDBF->sHooks.FSeek(psDBF->fp, XBASE_FILEHDR_SZ, 0); + if (psDBF->sHooks.FRead(pabyBuf, nHeadLen - XBASE_FILEHDR_SZ, 1, + psDBF->fp) != 1) { - psDBF->sHooks.FClose( psDBF->fp ); - free( pabyBuf ); - free( psDBF->pszCurrentRecord ); - free( psDBF->pszCodePage ); - free( psDBF ); + psDBF->sHooks.FClose(psDBF->fp); + free(pabyBuf); + free(psDBF->pszCurrentRecord); + free(psDBF->pszCodePage); + free(psDBF); return SHPLIB_NULLPTR; } @@ -675,105 +492,107 @@ DBFOpenLL( const char * pszFilename, const char * pszAccess, SAHooks *psHooks ) psDBF->panFieldDecimals = STATIC_CAST(int *, malloc(sizeof(int) * nFields)); psDBF->pachFieldType = STATIC_CAST(char *, malloc(sizeof(char) * nFields)); - for( iField = 0; iField < nFields; iField++ ) + for (int iField = 0; iField < nFields; iField++) { - unsigned char *pabyFInfo; - - pabyFInfo = pabyBuf+iField*XBASE_FLDHDR_SZ; - if( pabyFInfo[0] == HEADER_RECORD_TERMINATOR ) + unsigned char *pabyFInfo = pabyBuf + iField * XBASE_FLDHDR_SZ; + if (pabyFInfo[0] == HEADER_RECORD_TERMINATOR) { psDBF->nFields = iField; break; } - if( pabyFInfo[11] == 'N' || pabyFInfo[11] == 'F' ) - { - psDBF->panFieldSize[iField] = pabyFInfo[16]; - psDBF->panFieldDecimals[iField] = pabyFInfo[17]; - } - else - { - psDBF->panFieldSize[iField] = pabyFInfo[16]; - psDBF->panFieldDecimals[iField] = 0; - -/* -** The following seemed to be used sometimes to handle files with long -** string fields, but in other cases (such as bug 1202) the decimals field -** just seems to indicate some sort of preferred formatting, not very -** wide fields. So I have disabled this code. FrankW. - psDBF->panFieldSize[iField] = pabyFInfo[16] + pabyFInfo[17]*256; - psDBF->panFieldDecimals[iField] = 0; -*/ - } - - psDBF->pachFieldType[iField] = STATIC_CAST(char, pabyFInfo[11]); - if( iField == 0 ) - psDBF->panFieldOffset[iField] = 1; - else - psDBF->panFieldOffset[iField] = - psDBF->panFieldOffset[iField-1] + psDBF->panFieldSize[iField-1]; + if (pabyFInfo[11] == 'N' || pabyFInfo[11] == 'F') + { + psDBF->panFieldSize[iField] = pabyFInfo[16]; + psDBF->panFieldDecimals[iField] = pabyFInfo[17]; + } + else + { + psDBF->panFieldSize[iField] = pabyFInfo[16]; + psDBF->panFieldDecimals[iField] = 0; + + /* + ** The following seemed to be used sometimes to handle files with + long + ** string fields, but in other cases (such as bug 1202) the decimals + field + ** just seems to indicate some sort of preferred formatting, not + very + ** wide fields. So I have disabled this code. FrankW. + psDBF->panFieldSize[iField] = pabyFInfo[16] + + pabyFInfo[17]*256; psDBF->panFieldDecimals[iField] = 0; + */ + } + + psDBF->pachFieldType[iField] = STATIC_CAST(char, pabyFInfo[11]); + if (iField == 0) + psDBF->panFieldOffset[iField] = 1; + else + psDBF->panFieldOffset[iField] = psDBF->panFieldOffset[iField - 1] + + psDBF->panFieldSize[iField - 1]; } /* Check that the total width of fields does not exceed the record width */ - if( psDBF->nFields > 0 && - psDBF->panFieldOffset[psDBF->nFields-1] + - psDBF->panFieldSize[psDBF->nFields-1] > psDBF->nRecordLength ) + if (psDBF->nFields > 0 && psDBF->panFieldOffset[psDBF->nFields - 1] + + psDBF->panFieldSize[psDBF->nFields - 1] > + psDBF->nRecordLength) { - DBFClose( psDBF ); + DBFClose(psDBF); return SHPLIB_NULLPTR; } - DBFSetWriteEndOfFileChar( psDBF, TRUE ); + DBFSetWriteEndOfFileChar(psDBF, TRUE); + + psDBF->bRequireNextWriteSeek = TRUE; - return( psDBF ); + return (psDBF); } /************************************************************************/ /* DBFClose() */ /************************************************************************/ -void SHPAPI_CALL -DBFClose(DBFHandle psDBF) +void SHPAPI_CALL DBFClose(DBFHandle psDBF) { - if( psDBF == SHPLIB_NULLPTR ) + if (psDBF == SHPLIB_NULLPTR) return; -/* -------------------------------------------------------------------- */ -/* Write out header if not already written. */ -/* -------------------------------------------------------------------- */ - if( psDBF->bNoHeader ) - DBFWriteHeader( psDBF ); + /* -------------------------------------------------------------------- */ + /* Write out header if not already written. */ + /* -------------------------------------------------------------------- */ + if (psDBF->bNoHeader) + DBFWriteHeader(psDBF); - CPL_IGNORE_RET_VAL_INT(DBFFlushRecord( psDBF )); + CPL_IGNORE_RET_VAL_INT(DBFFlushRecord(psDBF)); -/* -------------------------------------------------------------------- */ -/* Update last access date, and number of records if we have */ -/* write access. */ -/* -------------------------------------------------------------------- */ - if( psDBF->bUpdated ) - DBFUpdateHeader( psDBF ); + /* -------------------------------------------------------------------- */ + /* Update last access date, and number of records if we have */ + /* write access. */ + /* -------------------------------------------------------------------- */ + if (psDBF->bUpdated) + DBFUpdateHeader(psDBF); -/* -------------------------------------------------------------------- */ -/* Close, and free resources. */ -/* -------------------------------------------------------------------- */ - psDBF->sHooks.FClose( psDBF->fp ); + /* -------------------------------------------------------------------- */ + /* Close, and free resources. */ + /* -------------------------------------------------------------------- */ + psDBF->sHooks.FClose(psDBF->fp); - if( psDBF->panFieldOffset != SHPLIB_NULLPTR ) + if (psDBF->panFieldOffset != SHPLIB_NULLPTR) { - free( psDBF->panFieldOffset ); - free( psDBF->panFieldSize ); - free( psDBF->panFieldDecimals ); - free( psDBF->pachFieldType ); + free(psDBF->panFieldOffset); + free(psDBF->panFieldSize); + free(psDBF->panFieldDecimals); + free(psDBF->pachFieldType); } - if( psDBF->pszWorkField != SHPLIB_NULLPTR ) - free( psDBF->pszWorkField ); + if (psDBF->pszWorkField != SHPLIB_NULLPTR) + free(psDBF->pszWorkField); - free( psDBF->pszHeader ); - free( psDBF->pszCurrentRecord ); - free( psDBF->pszCodePage ); + free(psDBF->pszHeader); + free(psDBF->pszCurrentRecord); + free(psDBF->pszCodePage); - free( psDBF ); + free(psDBF); } /************************************************************************/ @@ -782,11 +601,9 @@ DBFClose(DBFHandle psDBF) /* Create a new .dbf file with default code page LDID/87 (0x57) */ /************************************************************************/ -DBFHandle SHPAPI_CALL -DBFCreate( const char * pszFilename ) - +DBFHandle SHPAPI_CALL DBFCreate(const char *pszFilename) { - return DBFCreateEx( pszFilename, "LDID/87" ); // 0x57 + return DBFCreateEx(pszFilename, "LDID/87"); // 0x57 } /************************************************************************/ @@ -795,15 +612,14 @@ DBFCreate( const char * pszFilename ) /* Create a new .dbf file. */ /************************************************************************/ -DBFHandle SHPAPI_CALL -DBFCreateEx( const char * pszFilename, const char* pszCodePage ) - +DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszFilename, + const char *pszCodePage) { SAHooks sHooks; - SASetupDefaultHooks( &sHooks ); + SASetupDefaultHooks(&sHooks); - return DBFCreateLL( pszFilename, pszCodePage , &sHooks ); + return DBFCreateLL(pszFilename, pszCodePage, &sHooks); } /************************************************************************/ @@ -812,80 +628,69 @@ DBFCreateEx( const char * pszFilename, const char* pszCodePage ) /* Create a new .dbf file. */ /************************************************************************/ -DBFHandle SHPAPI_CALL -DBFCreateLL( const char * pszFilename, const char * pszCodePage, SAHooks *psHooks ) - +DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszFilename, + const char *pszCodePage, + const SAHooks *psHooks) { - DBFHandle psDBF; - SAFile fp; - char *pszFullname; - int ldid = -1; - char chZero = '\0'; - int nLenWithoutExtension; - -/* -------------------------------------------------------------------- */ -/* Compute the base (layer) name. If there is any extension */ -/* on the passed in filename we will strip it off. */ -/* -------------------------------------------------------------------- */ - nLenWithoutExtension = DBFGetLenWithoutExtension(pszFilename); - pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); + /* -------------------------------------------------------------------- */ + /* Compute the base (layer) name. If there is any extension */ + /* on the passed in filename we will strip it off. */ + /* -------------------------------------------------------------------- */ + const int nLenWithoutExtension = DBFGetLenWithoutExtension(pszFilename); + char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); memcpy(pszFullname, pszFilename, nLenWithoutExtension); memcpy(pszFullname + nLenWithoutExtension, ".dbf", 5); -/* -------------------------------------------------------------------- */ -/* Create the file. */ -/* -------------------------------------------------------------------- */ - fp = psHooks->FOpen( pszFullname, "wb" ); - if( fp == SHPLIB_NULLPTR ) - { - free( pszFullname ); - return SHPLIB_NULLPTR; - } - - psHooks->FWrite( &chZero, 1, 1, fp ); - psHooks->FClose( fp ); - - fp = psHooks->FOpen( pszFullname, "rb+" ); - if( fp == SHPLIB_NULLPTR ) + /* -------------------------------------------------------------------- */ + /* Create the file. */ + /* -------------------------------------------------------------------- */ + SAFile fp = psHooks->FOpen(pszFullname, "wb+", psHooks->pvUserData); + if (fp == SHPLIB_NULLPTR) { - free( pszFullname ); + free(pszFullname); return SHPLIB_NULLPTR; } memcpy(pszFullname + nLenWithoutExtension, ".cpg", 5); - if( pszCodePage != SHPLIB_NULLPTR ) + int ldid = -1; + if (pszCodePage != SHPLIB_NULLPTR) { - if( strncmp( pszCodePage, "LDID/", 5 ) == 0 ) + if (strncmp(pszCodePage, "LDID/", 5) == 0) { - ldid = atoi( pszCodePage + 5 ); - if( ldid > 255 ) - ldid = -1; // don't use 0 to indicate out of range as LDID/0 is a valid one + ldid = atoi(pszCodePage + 5); + if (ldid > 255) + ldid = -1; // don't use 0 to indicate out of range as LDID/0 is + // a valid one } - if( ldid < 0 ) + if (ldid < 0) { - SAFile fpCPG = psHooks->FOpen( pszFullname, "w" ); - psHooks->FWrite( CONST_CAST(void*, STATIC_CAST(const void*, pszCodePage)), strlen(pszCodePage), 1, fpCPG ); - psHooks->FClose( fpCPG ); + SAFile fpCPG = + psHooks->FOpen(pszFullname, "w", psHooks->pvUserData); + psHooks->FWrite( + CONST_CAST(void *, STATIC_CAST(const void *, pszCodePage)), + strlen(pszCodePage), 1, fpCPG); + psHooks->FClose(fpCPG); } } - if( pszCodePage == SHPLIB_NULLPTR || ldid >= 0 ) + if (pszCodePage == SHPLIB_NULLPTR || ldid >= 0) { - psHooks->Remove( pszFullname ); + psHooks->Remove(pszFullname, psHooks->pvUserData); } - free( pszFullname ); + free(pszFullname); -/* -------------------------------------------------------------------- */ -/* Create the info structure. */ -/* -------------------------------------------------------------------- */ - psDBF = STATIC_CAST(DBFHandle, calloc(1,sizeof(DBFInfo))); + /* -------------------------------------------------------------------- */ + /* Create the info structure. */ + /* -------------------------------------------------------------------- */ + DBFHandle psDBF = STATIC_CAST(DBFHandle, calloc(1, sizeof(DBFInfo))); - memcpy( &(psDBF->sHooks), psHooks, sizeof(SAHooks) ); + memcpy(&(psDBF->sHooks), psHooks, sizeof(SAHooks)); psDBF->fp = fp; psDBF->nRecords = 0; psDBF->nFields = 0; psDBF->nRecordLength = 1; - psDBF->nHeaderLength = XBASE_FILEHDR_SZ + 1; /* + 1 for HEADER_RECORD_TERMINATOR */ + psDBF->nHeaderLength = + XBASE_FILEHDR_SZ + 1; /* + 1 for HEADER_RECORD_TERMINATOR */ psDBF->panFieldOffset = SHPLIB_NULLPTR; psDBF->panFieldSize = SHPLIB_NULLPTR; @@ -901,16 +706,19 @@ DBFCreateLL( const char * pszFilename, const char * pszCodePage, SAHooks *psHook psDBF->iLanguageDriver = ldid > 0 ? ldid : 0; psDBF->pszCodePage = SHPLIB_NULLPTR; - if( pszCodePage ) + if (pszCodePage) { - psDBF->pszCodePage = STATIC_CAST(char *, malloc( strlen(pszCodePage) + 1 )); - strcpy( psDBF->pszCodePage, pszCodePage ); + psDBF->pszCodePage = + STATIC_CAST(char *, malloc(strlen(pszCodePage) + 1)); + strcpy(psDBF->pszCodePage, pszCodePage); } DBFSetLastModifiedDate(psDBF, 95, 7, 26); /* dummy date */ DBFSetWriteEndOfFileChar(psDBF, TRUE); - return( psDBF ); + psDBF->bRequireNextWriteSeek = TRUE; + + return (psDBF); } /************************************************************************/ @@ -919,24 +727,22 @@ DBFCreateLL( const char * pszFilename, const char * pszCodePage, SAHooks *psHook /* Add a field to a newly created .dbf or to an existing one */ /************************************************************************/ -int SHPAPI_CALL -DBFAddField(DBFHandle psDBF, const char * pszFieldName, - DBFFieldType eType, int nWidth, int nDecimals ) - +int SHPAPI_CALL DBFAddField(DBFHandle psDBF, const char *pszFieldName, + DBFFieldType eType, int nWidth, int nDecimals) { - char chNativeType = 'C'; + char chNativeType; - if( eType == FTLogical ) + if (eType == FTLogical) chNativeType = 'L'; - else if( eType == FTDate ) - chNativeType = 'D'; - else if( eType == FTString ) + else if (eType == FTDate) + chNativeType = 'D'; + else if (eType == FTString) chNativeType = 'C'; else chNativeType = 'N'; - return DBFAddNativeFieldType( psDBF, pszFieldName, chNativeType, - nWidth, nDecimals ); + return DBFAddNativeFieldType(psDBF, pszFieldName, chNativeType, nWidth, + nDecimals); } /************************************************************************/ @@ -947,15 +753,15 @@ static char DBFGetNullCharacter(char chType) { switch (chType) { - case 'N': - case 'F': - return '*'; - case 'D': - return '0'; - case 'L': - return '?'; - default: - return ' '; + case 'N': + case 'F': + return '*'; + case 'D': + return '0'; + case 'L': + return '?'; + default: + return ' '; } } @@ -966,102 +772,93 @@ static char DBFGetNullCharacter(char chType) /* are written. */ /************************************************************************/ -int SHPAPI_CALL -DBFAddNativeFieldType(DBFHandle psDBF, const char * pszFieldName, - char chType, int nWidth, int nDecimals ) - +int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle psDBF, const char *pszFieldName, + char chType, int nWidth, int nDecimals) { - char *pszFInfo; - int i; - int nOldRecordLength, nOldHeaderLength; - char *pszRecord; - char chFieldFill; - SAOffset nRecordOffset; - /* make sure that everything is written in .dbf */ - if( !DBFFlushRecord( psDBF ) ) + if (!DBFFlushRecord(psDBF)) return -1; - if( psDBF->nHeaderLength + XBASE_FLDHDR_SZ > 65535 ) + if (psDBF->nHeaderLength + XBASE_FLDHDR_SZ > 65535) { char szMessage[128]; - snprintf( szMessage, sizeof(szMessage), - "Cannot add field %s. Header length limit reached " - "(max 65535 bytes, 2046 fields).", - pszFieldName ); - psDBF->sHooks.Error( szMessage ); + snprintf(szMessage, sizeof(szMessage), + "Cannot add field %s. Header length limit reached " + "(max 65535 bytes, 2046 fields).", + pszFieldName); + psDBF->sHooks.Error(szMessage); return -1; } -/* -------------------------------------------------------------------- */ -/* Do some checking to ensure we can add records to this file. */ -/* -------------------------------------------------------------------- */ - if( nWidth < 1 ) + /* -------------------------------------------------------------------- */ + /* Do some checking to ensure we can add records to this file. */ + /* -------------------------------------------------------------------- */ + if (nWidth < 1) return -1; - if( nWidth > XBASE_FLD_MAX_WIDTH ) + if (nWidth > XBASE_FLD_MAX_WIDTH) nWidth = XBASE_FLD_MAX_WIDTH; - if( psDBF->nRecordLength + nWidth > 65535 ) + if (psDBF->nRecordLength + nWidth > 65535) { char szMessage[128]; - snprintf( szMessage, sizeof(szMessage), - "Cannot add field %s. Record length limit reached " - "(max 65535 bytes).", - pszFieldName ); - psDBF->sHooks.Error( szMessage ); + snprintf(szMessage, sizeof(szMessage), + "Cannot add field %s. Record length limit reached " + "(max 65535 bytes).", + pszFieldName); + psDBF->sHooks.Error(szMessage); return -1; } - nOldRecordLength = psDBF->nRecordLength; - nOldHeaderLength = psDBF->nHeaderLength; + const int nOldRecordLength = psDBF->nRecordLength; + const int nOldHeaderLength = psDBF->nHeaderLength; -/* -------------------------------------------------------------------- */ -/* SfRealloc all the arrays larger to hold the additional field */ -/* information. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* realloc all the arrays larger to hold the additional field */ + /* information. */ + /* -------------------------------------------------------------------- */ psDBF->nFields++; - psDBF->panFieldOffset = STATIC_CAST(int *, - SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields )); + psDBF->panFieldOffset = STATIC_CAST( + int *, realloc(psDBF->panFieldOffset, sizeof(int) * psDBF->nFields)); - psDBF->panFieldSize = STATIC_CAST(int *, - SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields )); + psDBF->panFieldSize = STATIC_CAST( + int *, realloc(psDBF->panFieldSize, sizeof(int) * psDBF->nFields)); - psDBF->panFieldDecimals = STATIC_CAST(int *, - SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields )); + psDBF->panFieldDecimals = STATIC_CAST( + int *, realloc(psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields)); - psDBF->pachFieldType = STATIC_CAST(char *, - SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields )); + psDBF->pachFieldType = STATIC_CAST( + char *, realloc(psDBF->pachFieldType, sizeof(char) * psDBF->nFields)); -/* -------------------------------------------------------------------- */ -/* Assign the new field information fields. */ -/* -------------------------------------------------------------------- */ - psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength; + /* -------------------------------------------------------------------- */ + /* Assign the new field information fields. */ + /* -------------------------------------------------------------------- */ + psDBF->panFieldOffset[psDBF->nFields - 1] = psDBF->nRecordLength; psDBF->nRecordLength += nWidth; - psDBF->panFieldSize[psDBF->nFields-1] = nWidth; - psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals; - psDBF->pachFieldType[psDBF->nFields-1] = chType; + psDBF->panFieldSize[psDBF->nFields - 1] = nWidth; + psDBF->panFieldDecimals[psDBF->nFields - 1] = nDecimals; + psDBF->pachFieldType[psDBF->nFields - 1] = chType; -/* -------------------------------------------------------------------- */ -/* Extend the required header information. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* Extend the required header information. */ + /* -------------------------------------------------------------------- */ psDBF->nHeaderLength += XBASE_FLDHDR_SZ; psDBF->bUpdated = FALSE; - psDBF->pszHeader = STATIC_CAST(char *, SfRealloc(psDBF->pszHeader, - psDBF->nFields*XBASE_FLDHDR_SZ)); + psDBF->pszHeader = STATIC_CAST( + char *, realloc(psDBF->pszHeader, psDBF->nFields * XBASE_FLDHDR_SZ)); - pszFInfo = psDBF->pszHeader + XBASE_FLDHDR_SZ * (psDBF->nFields-1); + char *pszFInfo = psDBF->pszHeader + XBASE_FLDHDR_SZ * (psDBF->nFields - 1); - for( i = 0; i < XBASE_FLDHDR_SZ; i++ ) + for (int i = 0; i < XBASE_FLDHDR_SZ; i++) pszFInfo[i] = '\0'; - strncpy( pszFInfo, pszFieldName, XBASE_FLDNAME_LEN_WRITE ); + strncpy(pszFInfo, pszFieldName, XBASE_FLDNAME_LEN_WRITE); - pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1]; + pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields - 1]; - if( chType == 'C' ) + if (chType == 'C') { pszFInfo[16] = STATIC_CAST(unsigned char, nWidth % 256); pszFInfo[17] = STATIC_CAST(unsigned char, nWidth / 256); @@ -1072,52 +869,61 @@ DBFAddNativeFieldType(DBFHandle psDBF, const char * pszFieldName, pszFInfo[17] = STATIC_CAST(unsigned char, nDecimals); } -/* -------------------------------------------------------------------- */ -/* Make the current record buffer appropriately larger. */ -/* -------------------------------------------------------------------- */ - psDBF->pszCurrentRecord = STATIC_CAST(char *, SfRealloc(psDBF->pszCurrentRecord, - psDBF->nRecordLength)); + /* -------------------------------------------------------------------- */ + /* Make the current record buffer appropriately larger. */ + /* -------------------------------------------------------------------- */ + psDBF->pszCurrentRecord = STATIC_CAST( + char *, realloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); /* we're done if dealing with new .dbf */ - if( psDBF->bNoHeader ) - return( psDBF->nFields - 1 ); + if (psDBF->bNoHeader) + return (psDBF->nFields - 1); -/* -------------------------------------------------------------------- */ -/* For existing .dbf file, shift records */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* For existing .dbf file, shift records */ + /* -------------------------------------------------------------------- */ /* alloc record */ - pszRecord = STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nRecordLength)); + char *pszRecord = + STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nRecordLength)); - chFieldFill = DBFGetNullCharacter(chType); + const char chFieldFill = DBFGetNullCharacter(chType); - for (i = psDBF->nRecords-1; i >= 0; --i) + SAOffset nRecordOffset; + for (int i = psDBF->nRecords - 1; i >= 0; --i) { - nRecordOffset = nOldRecordLength * STATIC_CAST(SAOffset, i) + nOldHeaderLength; + nRecordOffset = + nOldRecordLength * STATIC_CAST(SAOffset, i) + nOldHeaderLength; /* load record */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + if (psDBF->sHooks.FRead(pszRecord, nOldRecordLength, 1, psDBF->fp) != 1) + { + free(pszRecord); + return -1; + } /* set new field's value to NULL */ memset(pszRecord + nOldRecordLength, chFieldFill, nWidth); - nRecordOffset = psDBF->nRecordLength * STATIC_CAST(SAOffset, i) + psDBF->nHeaderLength; + nRecordOffset = psDBF->nRecordLength * STATIC_CAST(SAOffset, i) + + psDBF->nHeaderLength; /* move record to the new place*/ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + psDBF->sHooks.FWrite(pszRecord, psDBF->nRecordLength, 1, psDBF->fp); } - if( psDBF->bWriteEndOfFileChar ) + if (psDBF->bWriteEndOfFileChar) { char ch = END_OF_FILE_CHARACTER; nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,psDBF->nRecords) + psDBF->nHeaderLength; + psDBF->nRecordLength * STATIC_CAST(SAOffset, psDBF->nRecords) + + psDBF->nHeaderLength; - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + psDBF->sHooks.FWrite(&ch, 1, 1, psDBF->fp); } /* free record */ @@ -1125,13 +931,13 @@ DBFAddNativeFieldType(DBFHandle psDBF, const char * pszFieldName, /* force update of header with new header, record length and new field */ psDBF->bNoHeader = TRUE; - DBFUpdateHeader( psDBF ); + DBFUpdateHeader(psDBF); psDBF->nCurrentRecord = -1; psDBF->bCurrentRecordModified = FALSE; psDBF->bUpdated = TRUE; - return( psDBF->nFields-1 ); + return (psDBF->nFields - 1); } /************************************************************************/ @@ -1141,64 +947,64 @@ DBFAddNativeFieldType(DBFHandle psDBF, const char * pszFieldName, /************************************************************************/ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField, - char chReqType ) - + char chReqType) { - unsigned char *pabyRec; - void *pReturnField = SHPLIB_NULLPTR; - -/* -------------------------------------------------------------------- */ -/* Verify selection. */ -/* -------------------------------------------------------------------- */ - if( hEntity < 0 || hEntity >= psDBF->nRecords ) + /* -------------------------------------------------------------------- */ + /* Verify selection. */ + /* -------------------------------------------------------------------- */ + if (hEntity < 0 || hEntity >= psDBF->nRecords) return SHPLIB_NULLPTR; - if( iField < 0 || iField >= psDBF->nFields ) + if (iField < 0 || iField >= psDBF->nFields) return SHPLIB_NULLPTR; -/* -------------------------------------------------------------------- */ -/* Have we read the record? */ -/* -------------------------------------------------------------------- */ - if( !DBFLoadRecord( psDBF, hEntity ) ) + /* -------------------------------------------------------------------- */ + /* Have we read the record? */ + /* -------------------------------------------------------------------- */ + if (!DBFLoadRecord(psDBF, hEntity)) return SHPLIB_NULLPTR; - pabyRec = REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); + const unsigned char *pabyRec = + REINTERPRET_CAST(const unsigned char *, psDBF->pszCurrentRecord); -/* -------------------------------------------------------------------- */ -/* Ensure we have room to extract the target field. */ -/* -------------------------------------------------------------------- */ - if( psDBF->panFieldSize[iField] >= psDBF->nWorkFieldLength ) + /* -------------------------------------------------------------------- */ + /* Ensure we have room to extract the target field. */ + /* -------------------------------------------------------------------- */ + if (psDBF->panFieldSize[iField] >= psDBF->nWorkFieldLength) { psDBF->nWorkFieldLength = psDBF->panFieldSize[iField] + 100; - if( psDBF->pszWorkField == SHPLIB_NULLPTR ) - psDBF->pszWorkField = STATIC_CAST(char *, malloc(psDBF->nWorkFieldLength)); + if (psDBF->pszWorkField == SHPLIB_NULLPTR) + psDBF->pszWorkField = + STATIC_CAST(char *, malloc(psDBF->nWorkFieldLength)); else - psDBF->pszWorkField = STATIC_CAST(char *, realloc(psDBF->pszWorkField, - psDBF->nWorkFieldLength)); + psDBF->pszWorkField = STATIC_CAST( + char *, realloc(psDBF->pszWorkField, psDBF->nWorkFieldLength)); } -/* -------------------------------------------------------------------- */ -/* Extract the requested field. */ -/* -------------------------------------------------------------------- */ - memcpy( psDBF->pszWorkField, - REINTERPRET_CAST(const char *, pabyRec) + psDBF->panFieldOffset[iField], - psDBF->panFieldSize[iField] ); + /* -------------------------------------------------------------------- */ + /* Extract the requested field. */ + /* -------------------------------------------------------------------- */ + memcpy(psDBF->pszWorkField, + REINTERPRET_CAST(const char *, pabyRec) + + psDBF->panFieldOffset[iField], + psDBF->panFieldSize[iField]); psDBF->pszWorkField[psDBF->panFieldSize[iField]] = '\0'; - pReturnField = psDBF->pszWorkField; + void *pReturnField = psDBF->pszWorkField; -/* -------------------------------------------------------------------- */ -/* Decode the field. */ -/* -------------------------------------------------------------------- */ - if( chReqType == 'I' ) + /* -------------------------------------------------------------------- */ + /* Decode the field. */ + /* -------------------------------------------------------------------- */ + if (chReqType == 'I') { psDBF->fieldValue.nIntField = atoi(psDBF->pszWorkField); pReturnField = &(psDBF->fieldValue.nIntField); } - else if( chReqType == 'N' ) + else if (chReqType == 'N') { - psDBF->fieldValue.dfDoubleField = psDBF->sHooks.Atof(psDBF->pszWorkField); + psDBF->fieldValue.dfDoubleField = + psDBF->sHooks.Atof(psDBF->pszWorkField); pReturnField = &(psDBF->fieldValue.dfDoubleField); } @@ -1209,17 +1015,17 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField, #ifdef TRIM_DBF_WHITESPACE else { - char *pchSrc, *pchDst; + char *pchSrc = psDBF->pszWorkField; + char *pchDst = pchSrc; - pchDst = pchSrc = psDBF->pszWorkField; - while( *pchSrc == ' ' ) + while (*pchSrc == ' ') pchSrc++; - while( *pchSrc != '\0' ) + while (*pchSrc != '\0') *(pchDst++) = *(pchSrc++); *pchDst = '\0'; - while( pchDst != psDBF->pszWorkField && *(--pchDst) == ' ' ) + while (pchDst != psDBF->pszWorkField && *(--pchDst) == ' ') *pchDst = '\0'; } #endif @@ -1233,15 +1039,13 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField, /* Read an integer attribute. */ /************************************************************************/ -int SHPAPI_CALL -DBFReadIntegerAttribute( DBFHandle psDBF, int iRecord, int iField ) - +int SHPAPI_CALL DBFReadIntegerAttribute(DBFHandle psDBF, int iRecord, + int iField) { - int *pnValue; - - pnValue = STATIC_CAST(int *, DBFReadAttribute( psDBF, iRecord, iField, 'I' )); + int *pnValue = + STATIC_CAST(int *, DBFReadAttribute(psDBF, iRecord, iField, 'I')); - if( pnValue == SHPLIB_NULLPTR ) + if (pnValue == SHPLIB_NULLPTR) return 0; else return *pnValue; @@ -1253,18 +1057,16 @@ DBFReadIntegerAttribute( DBFHandle psDBF, int iRecord, int iField ) /* Read a double attribute. */ /************************************************************************/ -double SHPAPI_CALL -DBFReadDoubleAttribute( DBFHandle psDBF, int iRecord, int iField ) - +double SHPAPI_CALL DBFReadDoubleAttribute(DBFHandle psDBF, int iRecord, + int iField) { - double *pdValue; - - pdValue = STATIC_CAST(double *, DBFReadAttribute( psDBF, iRecord, iField, 'N' )); + double *pdValue = + STATIC_CAST(double *, DBFReadAttribute(psDBF, iRecord, iField, 'N')); - if( pdValue == SHPLIB_NULLPTR ) + if (pdValue == SHPLIB_NULLPTR) return 0.0; else - return *pdValue ; + return *pdValue; } /************************************************************************/ @@ -1274,10 +1076,11 @@ DBFReadDoubleAttribute( DBFHandle psDBF, int iRecord, int iField ) /************************************************************************/ const char SHPAPI_CALL1(*) -DBFReadStringAttribute( DBFHandle psDBF, int iRecord, int iField ) + DBFReadStringAttribute(DBFHandle psDBF, int iRecord, int iField) { - return STATIC_CAST(const char *, DBFReadAttribute( psDBF, iRecord, iField, 'C' ) ); + return STATIC_CAST(const char *, + DBFReadAttribute(psDBF, iRecord, iField, 'C')); } /************************************************************************/ @@ -1287,56 +1090,59 @@ DBFReadStringAttribute( DBFHandle psDBF, int iRecord, int iField ) /************************************************************************/ const char SHPAPI_CALL1(*) -DBFReadLogicalAttribute( DBFHandle psDBF, int iRecord, int iField ) + DBFReadLogicalAttribute(DBFHandle psDBF, int iRecord, int iField) { - return STATIC_CAST(const char *, DBFReadAttribute( psDBF, iRecord, iField, 'L' ) ); + return STATIC_CAST(const char *, + DBFReadAttribute(psDBF, iRecord, iField, 'L')); } - /************************************************************************/ /* DBFIsValueNULL() */ /* */ /* Return TRUE if the passed string is NULL. */ /************************************************************************/ -static int DBFIsValueNULL( char chType, const char* pszValue ) +static bool DBFIsValueNULL(char chType, const char *pszValue) { - int i; - - if( pszValue == SHPLIB_NULLPTR ) - return TRUE; + if (pszValue == SHPLIB_NULLPTR) + return true; - switch(chType) + switch (chType) { - case 'N': - case 'F': - /* - ** We accept all asterisks or all blanks as NULL - ** though according to the spec I think it should be all - ** asterisks. - */ - if( pszValue[0] == '*' ) - return TRUE; - - for( i = 0; pszValue[i] != '\0'; i++ ) - { - if( pszValue[i] != ' ' ) - return FALSE; - } - return TRUE; - - case 'D': - /* NULL date fields have value "00000000" */ - return strncmp(pszValue,"00000000",8) == 0; - - case 'L': - /* NULL boolean fields have value "?" */ - return pszValue[0] == '?'; - - default: - /* empty string fields are considered NULL */ - return strlen(pszValue) == 0; + case 'N': + case 'F': + /* + ** We accept all asterisks or all blanks as NULL + ** though according to the spec I think it should be all + ** asterisks. + */ + if (pszValue[0] == '*') + return true; + + for (int i = 0; pszValue[i] != '\0'; i++) + { + if (pszValue[i] != ' ') + return false; + } + return true; + + case 'D': + /* NULL date fields have value "00000000" */ + /* Some DBF files have fields filled with spaces */ + /* (trimmed by DBFReadStringAttribute) to indicate null */ + /* values for dates (#4265). */ + /* And others have ' 0': https://lists.osgeo.org/pipermail/gdal-dev/2023-November/058010.html */ + return strncmp(pszValue, "00000000", 8) == 0 || + strcmp(pszValue, " ") == 0 || strcmp(pszValue, "0") == 0; + + case 'L': + /* NULL boolean fields have value "?" */ + return pszValue[0] == '?'; + + default: + /* empty string fields are considered NULL */ + return strlen(pszValue) == 0; } } @@ -1348,18 +1154,14 @@ static int DBFIsValueNULL( char chType, const char* pszValue ) /* Contributed by Jim Matthews. */ /************************************************************************/ -int SHPAPI_CALL -DBFIsAttributeNULL( DBFHandle psDBF, int iRecord, int iField ) - +int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle psDBF, int iRecord, int iField) { - const char *pszValue; - - pszValue = DBFReadStringAttribute( psDBF, iRecord, iField ); + const char *pszValue = DBFReadStringAttribute(psDBF, iRecord, iField); - if( pszValue == SHPLIB_NULLPTR ) + if (pszValue == SHPLIB_NULLPTR) return TRUE; - return DBFIsValueNULL( psDBF->pachFieldType[iField], pszValue ); + return DBFIsValueNULL(psDBF->pachFieldType[iField], pszValue); } /************************************************************************/ @@ -1368,11 +1170,10 @@ DBFIsAttributeNULL( DBFHandle psDBF, int iRecord, int iField ) /* Return the number of fields in this table. */ /************************************************************************/ -int SHPAPI_CALL -DBFGetFieldCount( DBFHandle psDBF ) +int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF) { - return( psDBF->nFields ); + return (psDBF->nFields); } /************************************************************************/ @@ -1381,11 +1182,10 @@ DBFGetFieldCount( DBFHandle psDBF ) /* Return the number of records in this table. */ /************************************************************************/ -int SHPAPI_CALL -DBFGetRecordCount( DBFHandle psDBF ) +int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF) { - return( psDBF->nRecords ); + return (psDBF->nRecords); } /************************************************************************/ @@ -1396,168 +1196,179 @@ DBFGetRecordCount( DBFHandle psDBF ) /* bytes long. */ /************************************************************************/ -DBFFieldType SHPAPI_CALL -DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName, - int * pnWidth, int * pnDecimals ) +DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, + char *pszFieldName, int *pnWidth, + int *pnDecimals) { - if( iField < 0 || iField >= psDBF->nFields ) - return( FTInvalid ); + if (iField < 0 || iField >= psDBF->nFields) + return (FTInvalid); - if( pnWidth != SHPLIB_NULLPTR ) + if (pnWidth != SHPLIB_NULLPTR) *pnWidth = psDBF->panFieldSize[iField]; - if( pnDecimals != SHPLIB_NULLPTR ) + if (pnDecimals != SHPLIB_NULLPTR) *pnDecimals = psDBF->panFieldDecimals[iField]; - if( pszFieldName != SHPLIB_NULLPTR ) + if (pszFieldName != SHPLIB_NULLPTR) { - int i; - - strncpy( pszFieldName, STATIC_CAST(char *,psDBF->pszHeader)+iField*XBASE_FLDHDR_SZ, - XBASE_FLDNAME_LEN_READ ); - pszFieldName[XBASE_FLDNAME_LEN_READ] = '\0'; - for( i = XBASE_FLDNAME_LEN_READ - 1; i > 0 && pszFieldName[i] == ' '; i-- ) - pszFieldName[i] = '\0'; + strncpy(pszFieldName, + STATIC_CAST(char *, psDBF->pszHeader) + + iField * XBASE_FLDHDR_SZ, + XBASE_FLDNAME_LEN_READ); + pszFieldName[XBASE_FLDNAME_LEN_READ] = '\0'; + for (int i = XBASE_FLDNAME_LEN_READ - 1; + i > 0 && pszFieldName[i] == ' '; i--) + pszFieldName[i] = '\0'; } - if ( psDBF->pachFieldType[iField] == 'L' ) - return( FTLogical ); + if (psDBF->pachFieldType[iField] == 'L') + return (FTLogical); - else if( psDBF->pachFieldType[iField] == 'D' ) - return( FTDate ); + else if (psDBF->pachFieldType[iField] == 'D') + return (FTDate); - else if( psDBF->pachFieldType[iField] == 'N' - || psDBF->pachFieldType[iField] == 'F' ) + else if (psDBF->pachFieldType[iField] == 'N' || + psDBF->pachFieldType[iField] == 'F') { - if( psDBF->panFieldDecimals[iField] > 0 - || psDBF->panFieldSize[iField] >= 10 ) - return( FTDouble ); - else - return( FTInteger ); + if (psDBF->panFieldDecimals[iField] > 0 || + psDBF->panFieldSize[iField] >= 10) + return (FTDouble); + else + return (FTInteger); } else { - return( FTString ); + return (FTString); } } /************************************************************************/ /* DBFWriteAttribute() */ -/* */ -/* Write an attribute record to the file. */ +/* */ +/* Write an attribute record to the file. */ /************************************************************************/ -static int DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, - void * pValue ) - +static bool DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, + void *pValue) { - int i, j, nRetResult = TRUE; - unsigned char *pabyRec; - char szSField[XBASE_FLD_MAX_WIDTH+1], szFormat[20]; - -/* -------------------------------------------------------------------- */ -/* Is this a valid record? */ -/* -------------------------------------------------------------------- */ - if( hEntity < 0 || hEntity > psDBF->nRecords ) - return( FALSE ); + /* -------------------------------------------------------------------- */ + /* Is this a valid record? */ + /* -------------------------------------------------------------------- */ + if (hEntity < 0 || hEntity > psDBF->nRecords) + return false; - if( psDBF->bNoHeader ) + if (psDBF->bNoHeader) DBFWriteHeader(psDBF); -/* -------------------------------------------------------------------- */ -/* Is this a brand new record? */ -/* -------------------------------------------------------------------- */ - if( hEntity == psDBF->nRecords ) + /* -------------------------------------------------------------------- */ + /* Is this a brand new record? */ + /* -------------------------------------------------------------------- */ + if (hEntity == psDBF->nRecords) { - if( !DBFFlushRecord( psDBF ) ) - return FALSE; + if (!DBFFlushRecord(psDBF)) + return false; - psDBF->nRecords++; - for( i = 0; i < psDBF->nRecordLength; i++ ) - psDBF->pszCurrentRecord[i] = ' '; + psDBF->nRecords++; + for (int i = 0; i < psDBF->nRecordLength; i++) + psDBF->pszCurrentRecord[i] = ' '; - psDBF->nCurrentRecord = hEntity; + psDBF->nCurrentRecord = hEntity; } -/* -------------------------------------------------------------------- */ -/* Is this an existing record, but different than the last one */ -/* we accessed? */ -/* -------------------------------------------------------------------- */ - if( !DBFLoadRecord( psDBF, hEntity ) ) - return FALSE; + /* -------------------------------------------------------------------- */ + /* Is this an existing record, but different than the last one */ + /* we accessed? */ + /* -------------------------------------------------------------------- */ + if (!DBFLoadRecord(psDBF, hEntity)) + return false; - pabyRec = REINTERPRET_CAST(unsigned char *,psDBF->pszCurrentRecord); + unsigned char *pabyRec = + REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); psDBF->bCurrentRecordModified = TRUE; psDBF->bUpdated = TRUE; -/* -------------------------------------------------------------------- */ -/* Translate NULL value to valid DBF file representation. */ -/* */ -/* Contributed by Jim Matthews. */ -/* -------------------------------------------------------------------- */ - if( pValue == SHPLIB_NULLPTR ) + /* -------------------------------------------------------------------- */ + /* Translate NULL value to valid DBF file representation. */ + /* */ + /* Contributed by Jim Matthews. */ + /* -------------------------------------------------------------------- */ + if (pValue == SHPLIB_NULLPTR) { - memset( pabyRec+psDBF->panFieldOffset[iField], - DBFGetNullCharacter(psDBF->pachFieldType[iField]), - psDBF->panFieldSize[iField] ); - return TRUE; + memset(pabyRec + psDBF->panFieldOffset[iField], + DBFGetNullCharacter(psDBF->pachFieldType[iField]), + psDBF->panFieldSize[iField]); + return true; } -/* -------------------------------------------------------------------- */ -/* Assign all the record fields. */ -/* -------------------------------------------------------------------- */ - switch( psDBF->pachFieldType[iField] ) + /* -------------------------------------------------------------------- */ + /* Assign all the record fields. */ + /* -------------------------------------------------------------------- */ + bool nRetResult = true; + + switch (psDBF->pachFieldType[iField]) { - case 'D': - case 'N': - case 'F': - { - int nWidth = psDBF->panFieldSize[iField]; - - if( STATIC_CAST(int,sizeof(szSField))-2 < nWidth ) - nWidth = sizeof(szSField)-2; - - snprintf( szFormat, sizeof(szFormat), "%%%d.%df", - nWidth, psDBF->panFieldDecimals[iField] ); - CPLsnprintf(szSField, sizeof(szSField), szFormat, *STATIC_CAST(double *, pValue) ); - szSField[sizeof(szSField)-1] = '\0'; - if( STATIC_CAST(int,strlen(szSField)) > psDBF->panFieldSize[iField] ) + case 'D': + case 'N': + case 'F': { - szSField[psDBF->panFieldSize[iField]] = '\0'; - nRetResult = FALSE; - } - strncpy(REINTERPRET_CAST(char *, pabyRec+psDBF->panFieldOffset[iField]), - szSField, strlen(szSField) ); - break; - } - - case 'L': - if (psDBF->panFieldSize[iField] >= 1 && - (*STATIC_CAST(char*,pValue) == 'F' || *STATIC_CAST(char*,pValue) == 'T')) - *(pabyRec+psDBF->panFieldOffset[iField]) = *STATIC_CAST(char*,pValue); - break; - - default: - if( STATIC_CAST(int, strlen(STATIC_CAST(char *,pValue))) > psDBF->panFieldSize[iField] ) - { - j = psDBF->panFieldSize[iField]; - nRetResult = FALSE; + int nWidth = psDBF->panFieldSize[iField]; + + char szSField[XBASE_FLD_MAX_WIDTH + 1]; + if (STATIC_CAST(int, sizeof(szSField)) - 2 < nWidth) + nWidth = sizeof(szSField) - 2; + + char szFormat[20]; + snprintf(szFormat, sizeof(szFormat), "%%%d.%df", nWidth, + psDBF->panFieldDecimals[iField]); + CPLsnprintf(szSField, sizeof(szSField), szFormat, + *STATIC_CAST(double *, pValue)); + szSField[sizeof(szSField) - 1] = '\0'; + if (STATIC_CAST(int, strlen(szSField)) > + psDBF->panFieldSize[iField]) + { + szSField[psDBF->panFieldSize[iField]] = '\0'; + nRetResult = false; + } + memcpy(REINTERPRET_CAST(char *, + pabyRec + psDBF->panFieldOffset[iField]), + szSField, strlen(szSField)); + break; } - else + + case 'L': + if (psDBF->panFieldSize[iField] >= 1 && + (*STATIC_CAST(char *, pValue) == 'F' || + *STATIC_CAST(char *, pValue) == 'T')) + *(pabyRec + psDBF->panFieldOffset[iField]) = + *STATIC_CAST(char *, pValue); + break; + + default: { - memset( pabyRec+psDBF->panFieldOffset[iField], ' ', - psDBF->panFieldSize[iField] ); - j = STATIC_CAST(int, strlen(STATIC_CAST(char *,pValue))); - } + int j; + if (STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))) > + psDBF->panFieldSize[iField]) + { + j = psDBF->panFieldSize[iField]; + nRetResult = false; + } + else + { + memset(pabyRec + psDBF->panFieldOffset[iField], ' ', + psDBF->panFieldSize[iField]); + j = STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))); + } - strncpy(REINTERPRET_CAST(char *, pabyRec+psDBF->panFieldOffset[iField]), - STATIC_CAST(const char *, pValue), j ); - break; + strncpy(REINTERPRET_CAST(char *, + pabyRec + psDBF->panFieldOffset[iField]), + STATIC_CAST(const char *, pValue), j); + break; + } } - return( nRetResult ); + return nRetResult; } /************************************************************************/ @@ -1568,66 +1379,68 @@ static int DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, /* as is to the field position in the record. */ /************************************************************************/ -int SHPAPI_CALL -DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, - void * pValue ) - +int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, + int iField, const void *pValue) { - int i, j; - unsigned char *pabyRec; + /* -------------------------------------------------------------------- */ + /* Is this a valid record? */ + /* -------------------------------------------------------------------- */ + if (hEntity < 0 || hEntity > psDBF->nRecords) + return (FALSE); -/* -------------------------------------------------------------------- */ -/* Is this a valid record? */ -/* -------------------------------------------------------------------- */ - if( hEntity < 0 || hEntity > psDBF->nRecords ) - return( FALSE ); - - if( psDBF->bNoHeader ) + if (psDBF->bNoHeader) DBFWriteHeader(psDBF); -/* -------------------------------------------------------------------- */ -/* Is this a brand new record? */ -/* -------------------------------------------------------------------- */ - if( hEntity == psDBF->nRecords ) + /* -------------------------------------------------------------------- */ + /* Is this a brand new record? */ + /* -------------------------------------------------------------------- */ + if (hEntity == psDBF->nRecords) { - if( !DBFFlushRecord( psDBF ) ) + if (!DBFFlushRecord(psDBF)) return FALSE; - psDBF->nRecords++; - for( i = 0; i < psDBF->nRecordLength; i++ ) - psDBF->pszCurrentRecord[i] = ' '; + psDBF->nRecords++; + for (int i = 0; i < psDBF->nRecordLength; i++) + psDBF->pszCurrentRecord[i] = ' '; - psDBF->nCurrentRecord = hEntity; + psDBF->nCurrentRecord = hEntity; } -/* -------------------------------------------------------------------- */ -/* Is this an existing record, but different than the last one */ -/* we accessed? */ -/* -------------------------------------------------------------------- */ - if( !DBFLoadRecord( psDBF, hEntity ) ) + /* -------------------------------------------------------------------- */ + /* Is this an existing record, but different than the last one */ + /* we accessed? */ + /* -------------------------------------------------------------------- */ + if (!DBFLoadRecord(psDBF, hEntity)) return FALSE; - pabyRec = REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); - -/* -------------------------------------------------------------------- */ -/* Assign all the record fields. */ -/* -------------------------------------------------------------------- */ - if( STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))) > psDBF->panFieldSize[iField] ) - j = psDBF->panFieldSize[iField]; - else + if (iField >= 0) { - memset( pabyRec+psDBF->panFieldOffset[iField], ' ', - psDBF->panFieldSize[iField] ); - j = STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))); - } + unsigned char *pabyRec = + REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); + + /* -------------------------------------------------------------------- */ + /* Assign all the record fields. */ + /* -------------------------------------------------------------------- */ + int j; + if (STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))) > + psDBF->panFieldSize[iField]) + j = psDBF->panFieldSize[iField]; + else + { + memset(pabyRec + psDBF->panFieldOffset[iField], ' ', + psDBF->panFieldSize[iField]); + j = STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))); + } - strncpy(REINTERPRET_CAST(char *, pabyRec+psDBF->panFieldOffset[iField]), - STATIC_CAST(const char *, pValue), j ); + strncpy( + REINTERPRET_CAST(char *, pabyRec + psDBF->panFieldOffset[iField]), + STATIC_CAST(const char *, pValue), j); + } psDBF->bCurrentRecordModified = TRUE; psDBF->bUpdated = TRUE; - return( TRUE ); + return (TRUE); } /************************************************************************/ @@ -1636,12 +1449,11 @@ DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, /* Write a double attribute. */ /************************************************************************/ -int SHPAPI_CALL -DBFWriteDoubleAttribute( DBFHandle psDBF, int iRecord, int iField, - double dValue ) - +int SHPAPI_CALL DBFWriteDoubleAttribute(DBFHandle psDBF, int iRecord, + int iField, double dValue) { - return( DBFWriteAttribute( psDBF, iRecord, iField, STATIC_CAST(void *, &dValue) ) ); + return (DBFWriteAttribute(psDBF, iRecord, iField, + STATIC_CAST(void *, &dValue))); } /************************************************************************/ @@ -1650,14 +1462,13 @@ DBFWriteDoubleAttribute( DBFHandle psDBF, int iRecord, int iField, /* Write a integer attribute. */ /************************************************************************/ -int SHPAPI_CALL -DBFWriteIntegerAttribute( DBFHandle psDBF, int iRecord, int iField, - int nValue ) - +int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle psDBF, int iRecord, + int iField, int nValue) { - double dValue = nValue; + double dValue = nValue; - return( DBFWriteAttribute( psDBF, iRecord, iField, STATIC_CAST(void *, &dValue) ) ); + return (DBFWriteAttribute(psDBF, iRecord, iField, + STATIC_CAST(void *, &dValue))); } /************************************************************************/ @@ -1666,12 +1477,13 @@ DBFWriteIntegerAttribute( DBFHandle psDBF, int iRecord, int iField, /* Write a string attribute. */ /************************************************************************/ -int SHPAPI_CALL -DBFWriteStringAttribute( DBFHandle psDBF, int iRecord, int iField, - const char * pszValue ) +int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle psDBF, int iRecord, + int iField, const char *pszValue) { - return( DBFWriteAttribute( psDBF, iRecord, iField, STATIC_CAST(void *, CONST_CAST(char*, pszValue))) ); + return ( + DBFWriteAttribute(psDBF, iRecord, iField, + STATIC_CAST(void *, CONST_CAST(char *, pszValue)))); } /************************************************************************/ @@ -1680,11 +1492,10 @@ DBFWriteStringAttribute( DBFHandle psDBF, int iRecord, int iField, /* Write a string attribute. */ /************************************************************************/ -int SHPAPI_CALL -DBFWriteNULLAttribute( DBFHandle psDBF, int iRecord, int iField ) +int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle psDBF, int iRecord, int iField) { - return( DBFWriteAttribute( psDBF, iRecord, iField, SHPLIB_NULLPTR ) ); + return (DBFWriteAttribute(psDBF, iRecord, iField, SHPLIB_NULLPTR)); } /************************************************************************/ @@ -1693,66 +1504,64 @@ DBFWriteNULLAttribute( DBFHandle psDBF, int iRecord, int iField ) /* Write a logical attribute. */ /************************************************************************/ -int SHPAPI_CALL -DBFWriteLogicalAttribute( DBFHandle psDBF, int iRecord, int iField, - const char lValue) +int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle psDBF, int iRecord, + int iField, const char lValue) { - return( DBFWriteAttribute( psDBF, iRecord, iField, STATIC_CAST(void *, CONST_CAST(char*, &lValue)) ) ); + return ( + DBFWriteAttribute(psDBF, iRecord, iField, + STATIC_CAST(void *, CONST_CAST(char *, &lValue)))); } /************************************************************************/ /* DBFWriteTuple() */ -/* */ -/* Write an attribute record to the file. */ +/* */ +/* Write an attribute record to the file. */ /************************************************************************/ -int SHPAPI_CALL -DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple ) - +int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, + const void *pRawTuple) { - int i; - unsigned char *pabyRec; + /* -------------------------------------------------------------------- */ + /* Is this a valid record? */ + /* -------------------------------------------------------------------- */ + if (hEntity < 0 || hEntity > psDBF->nRecords) + return (FALSE); -/* -------------------------------------------------------------------- */ -/* Is this a valid record? */ -/* -------------------------------------------------------------------- */ - if( hEntity < 0 || hEntity > psDBF->nRecords ) - return( FALSE ); - - if( psDBF->bNoHeader ) + if (psDBF->bNoHeader) DBFWriteHeader(psDBF); -/* -------------------------------------------------------------------- */ -/* Is this a brand new record? */ -/* -------------------------------------------------------------------- */ - if( hEntity == psDBF->nRecords ) + /* -------------------------------------------------------------------- */ + /* Is this a brand new record? */ + /* -------------------------------------------------------------------- */ + if (hEntity == psDBF->nRecords) { - if( !DBFFlushRecord( psDBF ) ) + if (!DBFFlushRecord(psDBF)) return FALSE; - psDBF->nRecords++; - for( i = 0; i < psDBF->nRecordLength; i++ ) - psDBF->pszCurrentRecord[i] = ' '; + psDBF->nRecords++; + for (int i = 0; i < psDBF->nRecordLength; i++) + psDBF->pszCurrentRecord[i] = ' '; - psDBF->nCurrentRecord = hEntity; + psDBF->nCurrentRecord = hEntity; } -/* -------------------------------------------------------------------- */ -/* Is this an existing record, but different than the last one */ -/* we accessed? */ -/* -------------------------------------------------------------------- */ - if( !DBFLoadRecord( psDBF, hEntity ) ) + /* -------------------------------------------------------------------- */ + /* Is this an existing record, but different than the last one */ + /* we accessed? */ + /* -------------------------------------------------------------------- */ + if (!DBFLoadRecord(psDBF, hEntity)) return FALSE; - pabyRec = REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); + unsigned char *pabyRec = + REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); - memcpy ( pabyRec, pRawTuple, psDBF->nRecordLength ); + memcpy(pabyRec, pRawTuple, psDBF->nRecordLength); psDBF->bCurrentRecordModified = TRUE; psDBF->bUpdated = TRUE; - return( TRUE ); + return (TRUE); } /************************************************************************/ @@ -1762,63 +1571,70 @@ DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple ) /* till the next record read for any reason. */ /************************************************************************/ -const char SHPAPI_CALL1(*) -DBFReadTuple(DBFHandle psDBF, int hEntity ) +const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity) { - if( hEntity < 0 || hEntity >= psDBF->nRecords ) + if (hEntity < 0 || hEntity >= psDBF->nRecords) return SHPLIB_NULLPTR; - if( !DBFLoadRecord( psDBF, hEntity ) ) + if (!DBFLoadRecord(psDBF, hEntity)) return SHPLIB_NULLPTR; return STATIC_CAST(const char *, psDBF->pszCurrentRecord); } /************************************************************************/ -/* DBFCloneEmpty() */ +/* DBFCloneEmpty() */ /* */ /* Read one of the attribute fields of a record. */ /************************************************************************/ -DBFHandle SHPAPI_CALL -DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename ) +DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename) { - DBFHandle newDBF; - - newDBF = DBFCreateEx ( pszFilename, psDBF->pszCodePage ); - if ( newDBF == SHPLIB_NULLPTR ) return SHPLIB_NULLPTR; - - newDBF->nFields = psDBF->nFields; - newDBF->nRecordLength = psDBF->nRecordLength; - newDBF->nHeaderLength = psDBF->nHeaderLength; - - if( psDBF->pszHeader ) - { - newDBF->pszHeader = STATIC_CAST(char *, malloc ( XBASE_FLDHDR_SZ * psDBF->nFields )); - memcpy ( newDBF->pszHeader, psDBF->pszHeader, XBASE_FLDHDR_SZ * psDBF->nFields ); - } - - newDBF->panFieldOffset = STATIC_CAST(int *, malloc ( sizeof(int) * psDBF->nFields )); - memcpy ( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof(int) * psDBF->nFields ); - newDBF->panFieldSize = STATIC_CAST(int *, malloc ( sizeof(int) * psDBF->nFields )); - memcpy ( newDBF->panFieldSize, psDBF->panFieldSize, sizeof(int) * psDBF->nFields ); - newDBF->panFieldDecimals = STATIC_CAST(int *, malloc ( sizeof(int) * psDBF->nFields )); - memcpy ( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields ); - newDBF->pachFieldType = STATIC_CAST(char *, malloc ( sizeof(char) * psDBF->nFields )); - memcpy ( newDBF->pachFieldType, psDBF->pachFieldType, sizeof(char)*psDBF->nFields ); - - newDBF->bNoHeader = TRUE; - newDBF->bUpdated = TRUE; - newDBF->bWriteEndOfFileChar = psDBF->bWriteEndOfFileChar; + DBFHandle newDBF = DBFCreateEx(pszFilename, psDBF->pszCodePage); + if (newDBF == SHPLIB_NULLPTR) + return SHPLIB_NULLPTR; - DBFWriteHeader ( newDBF ); - DBFClose ( newDBF ); + newDBF->nFields = psDBF->nFields; + newDBF->nRecordLength = psDBF->nRecordLength; + newDBF->nHeaderLength = psDBF->nHeaderLength; - newDBF = DBFOpen ( pszFilename, "rb+" ); - newDBF->bWriteEndOfFileChar = psDBF->bWriteEndOfFileChar; + if (psDBF->pszHeader) + { + newDBF->pszHeader = + STATIC_CAST(char *, malloc(XBASE_FLDHDR_SZ * psDBF->nFields)); + memcpy(newDBF->pszHeader, psDBF->pszHeader, + XBASE_FLDHDR_SZ * psDBF->nFields); + } - return ( newDBF ); + newDBF->panFieldOffset = + STATIC_CAST(int *, malloc(sizeof(int) * psDBF->nFields)); + memcpy(newDBF->panFieldOffset, psDBF->panFieldOffset, + sizeof(int) * psDBF->nFields); + newDBF->panFieldSize = + STATIC_CAST(int *, malloc(sizeof(int) * psDBF->nFields)); + memcpy(newDBF->panFieldSize, psDBF->panFieldSize, + sizeof(int) * psDBF->nFields); + newDBF->panFieldDecimals = + STATIC_CAST(int *, malloc(sizeof(int) * psDBF->nFields)); + memcpy(newDBF->panFieldDecimals, psDBF->panFieldDecimals, + sizeof(int) * psDBF->nFields); + newDBF->pachFieldType = + STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nFields)); + memcpy(newDBF->pachFieldType, psDBF->pachFieldType, + sizeof(char) * psDBF->nFields); + + newDBF->bNoHeader = TRUE; + newDBF->bUpdated = TRUE; + newDBF->bWriteEndOfFileChar = psDBF->bWriteEndOfFileChar; + + DBFWriteHeader(newDBF); + DBFClose(newDBF); + + newDBF = DBFOpen(pszFilename, "rb+"); + newDBF->bWriteEndOfFileChar = psDBF->bWriteEndOfFileChar; + + return (newDBF); } /************************************************************************/ @@ -1832,14 +1648,13 @@ DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename ) /* 'M' (Memo: 10 digits .DBT block ptr) */ /************************************************************************/ -char SHPAPI_CALL -DBFGetNativeFieldType( DBFHandle psDBF, int iField ) +char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle psDBF, int iField) { - if( iField >=0 && iField < psDBF->nFields ) + if (iField >= 0 && iField < psDBF->nFields) return psDBF->pachFieldType[iField]; - return ' '; + return ' '; } /************************************************************************/ @@ -1850,20 +1665,17 @@ DBFGetNativeFieldType( DBFHandle psDBF, int iField ) /* Contributed by Jim Matthews. */ /************************************************************************/ -int SHPAPI_CALL -DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName) - +int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName) { - char name[XBASE_FLDNAME_LEN_READ+1]; - int i; + char name[XBASE_FLDNAME_LEN_READ + 1]; - for( i = 0; i < DBFGetFieldCount(psDBF); i++ ) + for (int i = 0; i < DBFGetFieldCount(psDBF); i++) { - DBFGetFieldInfo( psDBF, i, name, SHPLIB_NULLPTR, SHPLIB_NULLPTR ); - if(!STRCASECMP(pszFieldName,name)) - return(i); + DBFGetFieldInfo(psDBF, i, name, SHPLIB_NULLPTR, SHPLIB_NULLPTR); + if (!STRCASECMP(pszFieldName, name)) + return (i); } - return(-1); + return (-1); } /************************************************************************/ @@ -1873,24 +1685,23 @@ DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName) /* it returns FALSE. */ /************************************************************************/ -int SHPAPI_CALL DBFIsRecordDeleted( DBFHandle psDBF, int iShape ) - +int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape) { -/* -------------------------------------------------------------------- */ -/* Verify selection. */ -/* -------------------------------------------------------------------- */ - if( iShape < 0 || iShape >= psDBF->nRecords ) + /* -------------------------------------------------------------------- */ + /* Verify selection. */ + /* -------------------------------------------------------------------- */ + if (iShape < 0 || iShape >= psDBF->nRecords) return TRUE; -/* -------------------------------------------------------------------- */ -/* Have we read the record? */ -/* -------------------------------------------------------------------- */ - if( !DBFLoadRecord( psDBF, iShape ) ) + /* -------------------------------------------------------------------- */ + /* Have we read the record? */ + /* -------------------------------------------------------------------- */ + if (!DBFLoadRecord(psDBF, iShape)) return FALSE; -/* -------------------------------------------------------------------- */ -/* '*' means deleted. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* '*' means deleted. */ + /* -------------------------------------------------------------------- */ return psDBF->pszCurrentRecord[0] == '*'; } @@ -1898,34 +1709,32 @@ int SHPAPI_CALL DBFIsRecordDeleted( DBFHandle psDBF, int iShape ) /* DBFMarkRecordDeleted() */ /************************************************************************/ -int SHPAPI_CALL DBFMarkRecordDeleted( DBFHandle psDBF, int iShape, - int bIsDeleted ) - +int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape, + int bIsDeleted) { - char chNewFlag; - -/* -------------------------------------------------------------------- */ -/* Verify selection. */ -/* -------------------------------------------------------------------- */ - if( iShape < 0 || iShape >= psDBF->nRecords ) + /* -------------------------------------------------------------------- */ + /* Verify selection. */ + /* -------------------------------------------------------------------- */ + if (iShape < 0 || iShape >= psDBF->nRecords) return FALSE; -/* -------------------------------------------------------------------- */ -/* Is this an existing record, but different than the last one */ -/* we accessed? */ -/* -------------------------------------------------------------------- */ - if( !DBFLoadRecord( psDBF, iShape ) ) + /* -------------------------------------------------------------------- */ + /* Is this an existing record, but different than the last one */ + /* we accessed? */ + /* -------------------------------------------------------------------- */ + if (!DBFLoadRecord(psDBF, iShape)) return FALSE; -/* -------------------------------------------------------------------- */ -/* Assign value, marking record as dirty if it changes. */ -/* -------------------------------------------------------------------- */ - if( bIsDeleted ) + /* -------------------------------------------------------------------- */ + /* Assign value, marking record as dirty if it changes. */ + /* -------------------------------------------------------------------- */ + char chNewFlag; + if (bIsDeleted) chNewFlag = '*'; else chNewFlag = ' '; - if( psDBF->pszCurrentRecord[0] != chNewFlag ) + if (psDBF->pszCurrentRecord[0] != chNewFlag) { psDBF->bCurrentRecordModified = TRUE; psDBF->bUpdated = TRUE; @@ -1939,10 +1748,9 @@ int SHPAPI_CALL DBFMarkRecordDeleted( DBFHandle psDBF, int iShape, /* DBFGetCodePage */ /************************************************************************/ -const char SHPAPI_CALL1(*) -DBFGetCodePage(DBFHandle psDBF ) +const char SHPAPI_CALL1(*) DBFGetCodePage(DBFHandle psDBF) { - if( psDBF == SHPLIB_NULLPTR ) + if (psDBF == SHPLIB_NULLPTR) return SHPLIB_NULLPTR; return psDBF->pszCodePage; } @@ -1953,109 +1761,110 @@ DBFGetCodePage(DBFHandle psDBF ) /* Remove a field from a .dbf file */ /************************************************************************/ -int SHPAPI_CALL -DBFDeleteField(DBFHandle psDBF, int iField) +int SHPAPI_CALL DBFDeleteField(DBFHandle psDBF, int iField) { - int nOldRecordLength, nOldHeaderLength; - int nDeletedFieldOffset, nDeletedFieldSize; - SAOffset nRecordOffset; - char* pszRecord; - int i, iRecord; - if (iField < 0 || iField >= psDBF->nFields) return FALSE; /* make sure that everything is written in .dbf */ - if( !DBFFlushRecord( psDBF ) ) + if (!DBFFlushRecord(psDBF)) return FALSE; /* get information about field to be deleted */ - nOldRecordLength = psDBF->nRecordLength; - nOldHeaderLength = psDBF->nHeaderLength; - nDeletedFieldOffset = psDBF->panFieldOffset[iField]; - nDeletedFieldSize = psDBF->panFieldSize[iField]; + int nOldRecordLength = psDBF->nRecordLength; + int nOldHeaderLength = psDBF->nHeaderLength; + int nDeletedFieldOffset = psDBF->panFieldOffset[iField]; + int nDeletedFieldSize = psDBF->panFieldSize[iField]; /* update fields info */ - for (i = iField + 1; i < psDBF->nFields; i++) + for (int i = iField + 1; i < psDBF->nFields; i++) { - psDBF->panFieldOffset[i-1] = psDBF->panFieldOffset[i] - nDeletedFieldSize; - psDBF->panFieldSize[i-1] = psDBF->panFieldSize[i]; - psDBF->panFieldDecimals[i-1] = psDBF->panFieldDecimals[i]; - psDBF->pachFieldType[i-1] = psDBF->pachFieldType[i]; + psDBF->panFieldOffset[i - 1] = + psDBF->panFieldOffset[i] - nDeletedFieldSize; + psDBF->panFieldSize[i - 1] = psDBF->panFieldSize[i]; + psDBF->panFieldDecimals[i - 1] = psDBF->panFieldDecimals[i]; + psDBF->pachFieldType[i - 1] = psDBF->pachFieldType[i]; } /* resize fields arrays */ psDBF->nFields--; - psDBF->panFieldOffset = STATIC_CAST(int *, - SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields )); + psDBF->panFieldOffset = STATIC_CAST( + int *, realloc(psDBF->panFieldOffset, sizeof(int) * psDBF->nFields)); - psDBF->panFieldSize = STATIC_CAST(int *, - SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields )); + psDBF->panFieldSize = STATIC_CAST( + int *, realloc(psDBF->panFieldSize, sizeof(int) * psDBF->nFields)); - psDBF->panFieldDecimals = STATIC_CAST(int *, - SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields )); + psDBF->panFieldDecimals = STATIC_CAST( + int *, realloc(psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields)); - psDBF->pachFieldType = STATIC_CAST(char *, - SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields )); + psDBF->pachFieldType = STATIC_CAST( + char *, realloc(psDBF->pachFieldType, sizeof(char) * psDBF->nFields)); /* update header information */ psDBF->nHeaderLength -= XBASE_FLDHDR_SZ; psDBF->nRecordLength -= nDeletedFieldSize; /* overwrite field information in header */ - memmove(psDBF->pszHeader + iField*XBASE_FLDHDR_SZ, - psDBF->pszHeader + (iField+1)*XBASE_FLDHDR_SZ, - sizeof(char) * (psDBF->nFields - iField)*XBASE_FLDHDR_SZ); + memmove(psDBF->pszHeader + iField * XBASE_FLDHDR_SZ, + psDBF->pszHeader + (iField + 1) * XBASE_FLDHDR_SZ, + sizeof(char) * (psDBF->nFields - iField) * XBASE_FLDHDR_SZ); - psDBF->pszHeader = STATIC_CAST(char *, SfRealloc(psDBF->pszHeader, - psDBF->nFields*XBASE_FLDHDR_SZ)); + psDBF->pszHeader = STATIC_CAST( + char *, realloc(psDBF->pszHeader, psDBF->nFields * XBASE_FLDHDR_SZ)); /* update size of current record appropriately */ - psDBF->pszCurrentRecord = STATIC_CAST(char *, SfRealloc(psDBF->pszCurrentRecord, - psDBF->nRecordLength)); + psDBF->pszCurrentRecord = STATIC_CAST( + char *, realloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); /* we're done if we're dealing with not yet created .dbf */ - if ( psDBF->bNoHeader && psDBF->nRecords == 0 ) + if (psDBF->bNoHeader && psDBF->nRecords == 0) return TRUE; /* force update of header with new header and record length */ psDBF->bNoHeader = TRUE; - DBFUpdateHeader( psDBF ); + DBFUpdateHeader(psDBF); /* alloc record */ - pszRecord = STATIC_CAST(char *, malloc(sizeof(char) * nOldRecordLength)); + char *pszRecord = + STATIC_CAST(char *, malloc(sizeof(char) * nOldRecordLength)); /* shift records to their new positions */ - for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++) + for (int iRecord = 0; iRecord < psDBF->nRecords; iRecord++) { - nRecordOffset = - nOldRecordLength * STATIC_CAST(SAOffset,iRecord) + nOldHeaderLength; + SAOffset nRecordOffset = + nOldRecordLength * STATIC_CAST(SAOffset, iRecord) + + nOldHeaderLength; /* load record */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + if (psDBF->sHooks.FRead(pszRecord, nOldRecordLength, 1, psDBF->fp) != 1) + { + free(pszRecord); + return FALSE; + } - nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,iRecord) + psDBF->nHeaderLength; + nRecordOffset = psDBF->nRecordLength * STATIC_CAST(SAOffset, iRecord) + + psDBF->nHeaderLength; /* move record in two steps */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FWrite( pszRecord, nDeletedFieldOffset, 1, psDBF->fp ); - psDBF->sHooks.FWrite( pszRecord + nDeletedFieldOffset + nDeletedFieldSize, - nOldRecordLength - nDeletedFieldOffset - nDeletedFieldSize, - 1, psDBF->fp ); - + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + psDBF->sHooks.FWrite(pszRecord, nDeletedFieldOffset, 1, psDBF->fp); + psDBF->sHooks.FWrite( + pszRecord + nDeletedFieldOffset + nDeletedFieldSize, + nOldRecordLength - nDeletedFieldOffset - nDeletedFieldSize, 1, + psDBF->fp); } - if( psDBF->bWriteEndOfFileChar ) + if (psDBF->bWriteEndOfFileChar) { char ch = END_OF_FILE_CHARACTER; SAOffset nEOFOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,psDBF->nRecords) + psDBF->nHeaderLength; + psDBF->nRecordLength * STATIC_CAST(SAOffset, psDBF->nRecords) + + psDBF->nHeaderLength; - psDBF->sHooks.FSeek( psDBF->fp, nEOFOffset, 0 ); - psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nEOFOffset, 0); + psDBF->sHooks.FWrite(&ch, 1, 1, psDBF->fp); } /* TODO: truncate file */ @@ -2080,36 +1889,30 @@ DBFDeleteField(DBFHandle psDBF, int iField) /* code of DBFReorderFields. */ /************************************************************************/ -int SHPAPI_CALL -DBFReorderFields( DBFHandle psDBF, int* panMap ) +int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, const int *panMap) { - SAOffset nRecordOffset; - int i, iRecord; - int *panFieldOffsetNew; - int *panFieldSizeNew; - int *panFieldDecimalsNew; - char *pachFieldTypeNew; - char *pszHeaderNew; - char *pszRecord; - char *pszRecordNew; - - if ( psDBF->nFields == 0 ) + if (psDBF->nFields == 0) return TRUE; /* make sure that everything is written in .dbf */ - if( !DBFFlushRecord( psDBF ) ) + if (!DBFFlushRecord(psDBF)) return FALSE; - /* a simple malloc() would be enough, but calloc() helps clang static analyzer */ - panFieldOffsetNew = STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); - panFieldSizeNew = STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); - panFieldDecimalsNew = STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); - pachFieldTypeNew = STATIC_CAST(char *, calloc(sizeof(char), psDBF->nFields)); - pszHeaderNew = STATIC_CAST(char*, malloc(sizeof(char) * XBASE_FLDHDR_SZ * - psDBF->nFields)); + /* a simple malloc() would be enough, but calloc() helps clang static + * analyzer */ + int *panFieldOffsetNew = + STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); + int *panFieldSizeNew = + STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); + int *panFieldDecimalsNew = + STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); + char *pachFieldTypeNew = + STATIC_CAST(char *, calloc(sizeof(char), psDBF->nFields)); + char *pszHeaderNew = STATIC_CAST( + char *, malloc(sizeof(char) * XBASE_FLDHDR_SZ * psDBF->nFields)); /* shuffle fields definitions */ - for(i=0; i < psDBF->nFields; i++) + for (int i = 0; i < psDBF->nFields; i++) { panFieldSizeNew[i] = psDBF->panFieldSize[panMap[i]]; panFieldDecimalsNew[i] = psDBF->panFieldDecimals[panMap[i]]; @@ -2118,38 +1921,49 @@ DBFReorderFields( DBFHandle psDBF, int* panMap ) psDBF->pszHeader + panMap[i] * XBASE_FLDHDR_SZ, XBASE_FLDHDR_SZ); } panFieldOffsetNew[0] = 1; - for(i=1; i < psDBF->nFields; i++) + for (int i = 1; i < psDBF->nFields; i++) { - panFieldOffsetNew[i] = panFieldOffsetNew[i - 1] + panFieldSizeNew[i - 1]; + panFieldOffsetNew[i] = + panFieldOffsetNew[i - 1] + panFieldSizeNew[i - 1]; } free(psDBF->pszHeader); psDBF->pszHeader = pszHeaderNew; + bool errorAbort = false; + /* we're done if we're dealing with not yet created .dbf */ - if ( !(psDBF->bNoHeader && psDBF->nRecords == 0) ) + if (!(psDBF->bNoHeader && psDBF->nRecords == 0)) { /* force update of header with new header and record length */ psDBF->bNoHeader = TRUE; - DBFUpdateHeader( psDBF ); + DBFUpdateHeader(psDBF); /* alloc record */ - pszRecord = STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nRecordLength)); - pszRecordNew = STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nRecordLength)); + char *pszRecord = + STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nRecordLength)); + char *pszRecordNew = + STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nRecordLength)); /* shuffle fields in records */ - for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++) + for (int iRecord = 0; iRecord < psDBF->nRecords; iRecord++) { - nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,iRecord) + psDBF->nHeaderLength; + const SAOffset nRecordOffset = + psDBF->nRecordLength * STATIC_CAST(SAOffset, iRecord) + + psDBF->nHeaderLength; /* load record */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FRead( pszRecord, psDBF->nRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + if (psDBF->sHooks.FRead(pszRecord, psDBF->nRecordLength, 1, + psDBF->fp) != 1) + { + errorAbort = true; + break; + } pszRecordNew[0] = pszRecord[0]; - for(i=0; i < psDBF->nFields; i++) + for (int i = 0; i < psDBF->nFields; i++) { memcpy(pszRecordNew + panFieldOffsetNew[i], pszRecord + psDBF->panFieldOffset[panMap[i]], @@ -2157,8 +1971,9 @@ DBFReorderFields( DBFHandle psDBF, int* panMap ) } /* write record */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FWrite( pszRecordNew, psDBF->nRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + psDBF->sHooks.FWrite(pszRecordNew, psDBF->nRecordLength, 1, + psDBF->fp); } /* free record */ @@ -2166,6 +1981,18 @@ DBFReorderFields( DBFHandle psDBF, int* panMap ) free(pszRecordNew); } + if (errorAbort) + { + free(panFieldOffsetNew); + free(panFieldSizeNew); + free(panFieldDecimalsNew); + free(pachFieldTypeNew); + psDBF->nCurrentRecord = -1; + psDBF->bCurrentRecordModified = FALSE; + psDBF->bUpdated = FALSE; + return FALSE; + } + free(psDBF->panFieldOffset); free(psDBF->panFieldSize); free(psDBF->panFieldDecimals); @@ -2173,7 +2000,7 @@ DBFReorderFields( DBFHandle psDBF, int* panMap ) psDBF->panFieldOffset = panFieldOffsetNew; psDBF->panFieldSize = panFieldSizeNew; - psDBF->panFieldDecimals =panFieldDecimalsNew; + psDBF->panFieldDecimals = panFieldDecimalsNew; psDBF->pachFieldType = pachFieldTypeNew; psDBF->nCurrentRecord = -1; @@ -2183,71 +2010,59 @@ DBFReorderFields( DBFHandle psDBF, int* panMap ) return TRUE; } - /************************************************************************/ /* DBFAlterFieldDefn() */ /* */ /* Alter a field definition in a .dbf file */ /************************************************************************/ -int SHPAPI_CALL -DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName, - char chType, int nWidth, int nDecimals ) +int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField, + const char *pszFieldName, char chType, + int nWidth, int nDecimals) { - int i; - int iRecord; - int nOffset; - int nOldWidth; - int nOldRecordLength; - SAOffset nRecordOffset; - char* pszFInfo; - char chOldType; - int bIsNULL; - char chFieldFill; - if (iField < 0 || iField >= psDBF->nFields) return FALSE; /* make sure that everything is written in .dbf */ - if( !DBFFlushRecord( psDBF ) ) + if (!DBFFlushRecord(psDBF)) return FALSE; - chFieldFill = DBFGetNullCharacter(chType); + const char chFieldFill = DBFGetNullCharacter(chType); - chOldType = psDBF->pachFieldType[iField]; - nOffset = psDBF->panFieldOffset[iField]; - nOldWidth = psDBF->panFieldSize[iField]; - nOldRecordLength = psDBF->nRecordLength; + const char chOldType = psDBF->pachFieldType[iField]; + const int nOffset = psDBF->panFieldOffset[iField]; + const int nOldWidth = psDBF->panFieldSize[iField]; + const int nOldRecordLength = psDBF->nRecordLength; -/* -------------------------------------------------------------------- */ -/* Do some checking to ensure we can add records to this file. */ -/* -------------------------------------------------------------------- */ - if( nWidth < 1 ) + /* -------------------------------------------------------------------- */ + /* Do some checking to ensure we can add records to this file. */ + /* -------------------------------------------------------------------- */ + if (nWidth < 1) return -1; - if( nWidth > XBASE_FLD_MAX_WIDTH ) + if (nWidth > XBASE_FLD_MAX_WIDTH) nWidth = XBASE_FLD_MAX_WIDTH; -/* -------------------------------------------------------------------- */ -/* Assign the new field information fields. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* Assign the new field information fields. */ + /* -------------------------------------------------------------------- */ psDBF->panFieldSize[iField] = nWidth; psDBF->panFieldDecimals[iField] = nDecimals; psDBF->pachFieldType[iField] = chType; -/* -------------------------------------------------------------------- */ -/* Update the header information. */ -/* -------------------------------------------------------------------- */ - pszFInfo = psDBF->pszHeader + XBASE_FLDHDR_SZ * iField; + /* -------------------------------------------------------------------- */ + /* Update the header information. */ + /* -------------------------------------------------------------------- */ + char *pszFInfo = psDBF->pszHeader + XBASE_FLDHDR_SZ * iField; - for( i = 0; i < XBASE_FLDHDR_SZ; i++ ) + for (int i = 0; i < XBASE_FLDHDR_SZ; i++) pszFInfo[i] = '\0'; - strncpy( pszFInfo, pszFieldName, XBASE_FLDNAME_LEN_WRITE ); + strncpy(pszFInfo, pszFieldName, XBASE_FLDNAME_LEN_WRITE); pszFInfo[11] = psDBF->pachFieldType[iField]; - if( chType == 'C' ) + if (chType == 'C') { pszFInfo[16] = STATIC_CAST(unsigned char, nWidth % 256); pszFInfo[17] = STATIC_CAST(unsigned char, nWidth / 256); @@ -2258,60 +2073,71 @@ DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName, pszFInfo[17] = STATIC_CAST(unsigned char, nDecimals); } -/* -------------------------------------------------------------------- */ -/* Update offsets */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* Update offsets */ + /* -------------------------------------------------------------------- */ if (nWidth != nOldWidth) { - for (i = iField + 1; i < psDBF->nFields; i++) - psDBF->panFieldOffset[i] += nWidth - nOldWidth; + for (int i = iField + 1; i < psDBF->nFields; i++) + psDBF->panFieldOffset[i] += nWidth - nOldWidth; psDBF->nRecordLength += nWidth - nOldWidth; - psDBF->pszCurrentRecord = STATIC_CAST(char *, SfRealloc(psDBF->pszCurrentRecord, - psDBF->nRecordLength)); + psDBF->pszCurrentRecord = STATIC_CAST( + char *, realloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); } /* we're done if we're dealing with not yet created .dbf */ - if ( psDBF->bNoHeader && psDBF->nRecords == 0 ) + if (psDBF->bNoHeader && psDBF->nRecords == 0) return TRUE; /* force update of header with new header and record length */ psDBF->bNoHeader = TRUE; - DBFUpdateHeader( psDBF ); + DBFUpdateHeader(psDBF); + + bool errorAbort = false; if (nWidth < nOldWidth || (nWidth == nOldWidth && chType != chOldType)) { - char* pszRecord = STATIC_CAST(char *, malloc(sizeof(char) * nOldRecordLength)); - char* pszOldField = STATIC_CAST(char *, malloc(sizeof(char) * (nOldWidth + 1))); + char *pszRecord = + STATIC_CAST(char *, malloc(sizeof(char) * nOldRecordLength)); + char *pszOldField = + STATIC_CAST(char *, malloc(sizeof(char) * (nOldWidth + 1))); /* cppcheck-suppress uninitdata */ pszOldField[nOldWidth] = 0; /* move records to their new positions */ - for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++) + for (int iRecord = 0; iRecord < psDBF->nRecords; iRecord++) { - nRecordOffset = - nOldRecordLength * STATIC_CAST(SAOffset,iRecord) + psDBF->nHeaderLength; + SAOffset nRecordOffset = + nOldRecordLength * STATIC_CAST(SAOffset, iRecord) + + psDBF->nHeaderLength; /* load record */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + if (psDBF->sHooks.FRead(pszRecord, nOldRecordLength, 1, + psDBF->fp) != 1) + { + errorAbort = true; + break; + } memcpy(pszOldField, pszRecord + nOffset, nOldWidth); - bIsNULL = DBFIsValueNULL( chOldType, pszOldField ); + const bool bIsNULL = DBFIsValueNULL(chOldType, pszOldField); if (nWidth != nOldWidth) { - if ((chOldType == 'N' || chOldType == 'F' || chOldType == 'D') && pszOldField[0] == ' ') + if ((chOldType == 'N' || chOldType == 'F' || + chOldType == 'D') && + pszOldField[0] == ' ') { /* Strip leading spaces when truncating a numeric field */ - memmove( pszRecord + nOffset, - pszRecord + nOffset + nOldWidth - nWidth, - nWidth ); + memmove(pszRecord + nOffset, + pszRecord + nOffset + nOldWidth - nWidth, nWidth); } if (nOffset + nOldWidth < nOldRecordLength) { - memmove( pszRecord + nOffset + nWidth, + memmove(pszRecord + nOffset + nWidth, pszRecord + nOffset + nOldWidth, nOldRecordLength - (nOffset + nOldWidth)); } @@ -2320,26 +2146,28 @@ DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName, /* Convert null value to the appropriate value of the new type */ if (bIsNULL) { - memset( pszRecord + nOffset, chFieldFill, nWidth); + memset(pszRecord + nOffset, chFieldFill, nWidth); } nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,iRecord) + psDBF->nHeaderLength; + psDBF->nRecordLength * STATIC_CAST(SAOffset, iRecord) + + psDBF->nHeaderLength; /* write record */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + psDBF->sHooks.FWrite(pszRecord, psDBF->nRecordLength, 1, psDBF->fp); } - if( psDBF->bWriteEndOfFileChar ) + if (!errorAbort && psDBF->bWriteEndOfFileChar) { char ch = END_OF_FILE_CHARACTER; - nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,psDBF->nRecords) + psDBF->nHeaderLength; + SAOffset nRecordOffset = + psDBF->nRecordLength * STATIC_CAST(SAOffset, psDBF->nRecords) + + psDBF->nHeaderLength; - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + psDBF->sHooks.FWrite(&ch, 1, 1, psDBF->fp); } /* TODO: truncate file */ @@ -2348,76 +2176,95 @@ DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName, } else if (nWidth > nOldWidth) { - char* pszRecord = STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nRecordLength)); - char* pszOldField = STATIC_CAST(char *, malloc(sizeof(char) * (nOldWidth + 1))); + char *pszRecord = + STATIC_CAST(char *, malloc(sizeof(char) * psDBF->nRecordLength)); + char *pszOldField = + STATIC_CAST(char *, malloc(sizeof(char) * (nOldWidth + 1))); /* cppcheck-suppress uninitdata */ pszOldField[nOldWidth] = 0; /* move records to their new positions */ - for (iRecord = psDBF->nRecords - 1; iRecord >= 0; iRecord--) + for (int iRecord = psDBF->nRecords - 1; iRecord >= 0; iRecord--) { - nRecordOffset = - nOldRecordLength * STATIC_CAST(SAOffset,iRecord) + psDBF->nHeaderLength; + SAOffset nRecordOffset = + nOldRecordLength * STATIC_CAST(SAOffset, iRecord) + + psDBF->nHeaderLength; /* load record */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + if (psDBF->sHooks.FRead(pszRecord, nOldRecordLength, 1, + psDBF->fp) != 1) + { + errorAbort = true; + break; + } memcpy(pszOldField, pszRecord + nOffset, nOldWidth); - bIsNULL = DBFIsValueNULL( chOldType, pszOldField ); + const bool bIsNULL = DBFIsValueNULL(chOldType, pszOldField); if (nOffset + nOldWidth < nOldRecordLength) { - memmove( pszRecord + nOffset + nWidth, - pszRecord + nOffset + nOldWidth, - nOldRecordLength - (nOffset + nOldWidth)); + memmove(pszRecord + nOffset + nWidth, + pszRecord + nOffset + nOldWidth, + nOldRecordLength - (nOffset + nOldWidth)); } /* Convert null value to the appropriate value of the new type */ if (bIsNULL) { - memset( pszRecord + nOffset, chFieldFill, nWidth); + memset(pszRecord + nOffset, chFieldFill, nWidth); } else { if ((chOldType == 'N' || chOldType == 'F')) { /* Add leading spaces when expanding a numeric field */ - memmove( pszRecord + nOffset + nWidth - nOldWidth, - pszRecord + nOffset, nOldWidth ); - memset( pszRecord + nOffset, ' ', nWidth - nOldWidth ); + memmove(pszRecord + nOffset + nWidth - nOldWidth, + pszRecord + nOffset, nOldWidth); + memset(pszRecord + nOffset, ' ', nWidth - nOldWidth); } else { /* Add trailing spaces */ - memset(pszRecord + nOffset + nOldWidth, ' ', nWidth - nOldWidth); + memset(pszRecord + nOffset + nOldWidth, ' ', + nWidth - nOldWidth); } } nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,iRecord) + psDBF->nHeaderLength; + psDBF->nRecordLength * STATIC_CAST(SAOffset, iRecord) + + psDBF->nHeaderLength; /* write record */ - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + psDBF->sHooks.FWrite(pszRecord, psDBF->nRecordLength, 1, psDBF->fp); } - if( psDBF->bWriteEndOfFileChar ) + if (!errorAbort && psDBF->bWriteEndOfFileChar) { char ch = END_OF_FILE_CHARACTER; - nRecordOffset = - psDBF->nRecordLength * STATIC_CAST(SAOffset,psDBF->nRecords) + psDBF->nHeaderLength; + SAOffset nRecordOffset = + psDBF->nRecordLength * STATIC_CAST(SAOffset, psDBF->nRecords) + + psDBF->nHeaderLength; - psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ); - psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp ); + psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0); + psDBF->sHooks.FWrite(&ch, 1, 1, psDBF->fp); } free(pszRecord); free(pszOldField); } + if (errorAbort) + { + psDBF->nCurrentRecord = -1; + psDBF->bCurrentRecordModified = TRUE; + psDBF->bUpdated = FALSE; + + return FALSE; + } psDBF->nCurrentRecord = -1; psDBF->bCurrentRecordModified = FALSE; psDBF->bUpdated = TRUE; @@ -2429,7 +2276,7 @@ DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName, /* DBFSetWriteEndOfFileChar() */ /************************************************************************/ -void SHPAPI_CALL DBFSetWriteEndOfFileChar( DBFHandle psDBF, int bWriteFlag ) +void SHPAPI_CALL DBFSetWriteEndOfFileChar(DBFHandle psDBF, int bWriteFlag) { psDBF->bWriteEndOfFileChar = bWriteFlag; } diff --git a/shapelib/safileio.c b/shapelib/safileio.c index d2c7f581c..b63a3933a 100644 --- a/shapelib/safileio.c +++ b/shapelib/safileio.c @@ -1,5 +1,4 @@ /****************************************************************************** - * $Id: safileio.c,v 1.6 2018-06-15 19:56:32 erouault Exp $ * * Project: Shapelib * Purpose: Default implementation of file io based on stdio. @@ -8,223 +7,122 @@ ****************************************************************************** * Copyright (c) 2007, Frank Warmerdam * - * This software is available under the following "MIT Style" license, - * or at the option of the licensee under the LGPL (see COPYING). This - * option is discussed in more detail in shapelib.html. - * - * -- - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later ****************************************************************************** * - * $Log: safileio.c,v $ - * Revision 1.6 2018-06-15 19:56:32 erouault - * * safileio.c: remove duplicate test. Patch by Jaroslav Fojtik. - * Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2744 - * - * Revision 1.5 2016-12-05 12:44:05 erouault - * * Major overhaul of Makefile build system to use autoconf/automake. - * - * * Warning fixes in contrib/ - * - * Revision 1.4 2008-01-16 20:05:14 bram - * Add file hooks that accept UTF-8 encoded filenames on some platforms. Use SASetupUtf8Hooks - * tosetup the hooks and check SHPAPI_UTF8_HOOKS for its availability. Currently, this - * is only available on the Windows platform that decodes the UTF-8 filenames to wide - * character strings and feeds them to _wfopen and _wremove. - * - * Revision 1.3 2007/12/18 18:28:11 bram - * - create hook for client specific atof (bugzilla ticket 1615) - * - check for NULL handle before closing cpCPG file, and close after reading. - * - * Revision 1.2 2007/12/15 20:25:30 bram - * dbfopen.c now reads the Code Page information from the DBF file, and exports - * this information as a string through the DBFGetCodePage function. This is - * either the number from the LDID header field ("LDID/") or as the - * content of an accompanying .CPG file. When creating a DBF file, the code can - * be set using DBFCreateEx. - * - * Revision 1.1 2007/12/06 06:56:41 fwarmerdam - * new - * */ #include "shapefil.h" +#include #include #include -#include +#include #include #include -#include - -SHP_CVSID("$Id: safileio.c,v 1.6 2018-06-15 19:56:32 erouault Exp $"); #ifdef SHPAPI_UTF8_HOOKS -# ifdef SHPAPI_WINDOWS -# define WIN32_LEAN_AND_MEAN -# define NOMINMAX -# include -# pragma comment(lib, "kernel32.lib") -# endif +#ifdef SHPAPI_WINDOWS +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#include +#pragma comment(lib, "kernel32.lib") +#endif #endif -/************************************************************************/ -/* SADFOpen() */ -/************************************************************************/ - -SAFile SADFOpen( const char *pszFilename, const char *pszAccess ) - +static SAFile SADFOpen(const char *pszFilename, const char *pszAccess, + void *pvUserData) { - return (SAFile) fopen( pszFilename, pszAccess ); + (void)pvUserData; + return (SAFile)fopen(pszFilename, pszAccess); } -/************************************************************************/ -/* SADFRead() */ -/************************************************************************/ - -SAOffset SADFRead( void *p, SAOffset size, SAOffset nmemb, SAFile file ) - +static SAOffset SADFRead(void *p, SAOffset size, SAOffset nmemb, SAFile file) { - return (SAOffset) fread( p, (size_t) size, (size_t) nmemb, - (FILE *) file ); + return (SAOffset)fread(p, (size_t)size, (size_t)nmemb, (FILE *)file); } -/************************************************************************/ -/* SADFWrite() */ -/************************************************************************/ - -SAOffset SADFWrite( void *p, SAOffset size, SAOffset nmemb, SAFile file ) - +static SAOffset SADFWrite(const void *p, SAOffset size, SAOffset nmemb, + SAFile file) { - return (SAOffset) fwrite( p, (size_t) size, (size_t) nmemb, - (FILE *) file ); + return (SAOffset)fwrite(p, (size_t)size, (size_t)nmemb, (FILE *)file); } -/************************************************************************/ -/* SADFSeek() */ -/************************************************************************/ - -SAOffset SADFSeek( SAFile file, SAOffset offset, int whence ) - +static SAOffset SADFSeek(SAFile file, SAOffset offset, int whence) { - return (SAOffset) fseek( (FILE *) file, (long) offset, whence ); +#if defined(_MSC_VER) && _MSC_VER >= 1400 + return (SAOffset)_fseeki64((FILE *)file, (__int64)offset, whence); +#else + return (SAOffset)fseek((FILE *)file, (long)offset, whence); +#endif } -/************************************************************************/ -/* SADFTell() */ -/************************************************************************/ - -SAOffset SADFTell( SAFile file ) - +static SAOffset SADFTell(SAFile file) { - return (SAOffset) ftell( (FILE *) file ); +#if defined(_MSC_VER) && _MSC_VER >= 1400 + return (SAOffset)_ftelli64((FILE *)file); +#else + return (SAOffset)ftell((FILE *)file); +#endif } -/************************************************************************/ -/* SADFFlush() */ -/************************************************************************/ - -int SADFFlush( SAFile file ) - +static int SADFFlush(SAFile file) { - return fflush( (FILE *) file ); + return fflush((FILE *)file); } -/************************************************************************/ -/* SADFClose() */ -/************************************************************************/ - -int SADFClose( SAFile file ) - +static int SADFClose(SAFile file) { - return fclose( (FILE *) file ); + return fclose((FILE *)file); } -/************************************************************************/ -/* SADFClose() */ -/************************************************************************/ - -int SADRemove( const char *filename ) - +static int SADRemove(const char *filename, void *pvUserData) { - return remove( filename ); + (void)pvUserData; + return remove(filename); } -/************************************************************************/ -/* SADError() */ -/************************************************************************/ - -void SADError( const char *message ) - +static void SADError(const char *message) { - fprintf( stderr, "%s\n", message ); + fprintf(stderr, "%s\n", message); } -/************************************************************************/ -/* SASetupDefaultHooks() */ -/************************************************************************/ - -void SASetupDefaultHooks( SAHooks *psHooks ) - +void SASetupDefaultHooks(SAHooks *psHooks) { - psHooks->FOpen = SADFOpen; - psHooks->FRead = SADFRead; - psHooks->FWrite = SADFWrite; - psHooks->FSeek = SADFSeek; - psHooks->FTell = SADFTell; - psHooks->FFlush = SADFFlush; - psHooks->FClose = SADFClose; - psHooks->Remove = SADRemove; - - psHooks->Error = SADError; - psHooks->Atof = atof; + psHooks->FOpen = SADFOpen; + psHooks->FRead = SADFRead; + psHooks->FWrite = SADFWrite; + psHooks->FSeek = SADFSeek; + psHooks->FTell = SADFTell; + psHooks->FFlush = SADFFlush; + psHooks->FClose = SADFClose; + psHooks->Remove = SADRemove; + + psHooks->Error = SADError; + psHooks->Atof = atof; + psHooks->pvUserData = NULL; } - - - #ifdef SHPAPI_WINDOWS -/************************************************************************/ -/* Utf8ToWideChar */ -/************************************************************************/ - -const wchar_t* Utf8ToWideChar( const char *pszFilename ) +static wchar_t *Utf8ToWideChar(const char *pszFilename) { - int nMulti, nWide; - wchar_t *pwszFileName; - - nMulti = strlen(pszFilename) + 1; - nWide = MultiByteToWideChar( CP_UTF8, 0, pszFilename, nMulti, 0, 0); - if( nWide == 0 ) + const int nMulti = (int)strlen(pszFilename) + 1; + const int nWide = + MultiByteToWideChar(CP_UTF8, 0, pszFilename, nMulti, 0, 0); + if (nWide == 0) { return NULL; } - pwszFileName = (wchar_t*) malloc(nWide * sizeof(wchar_t)); - if ( pwszFileName == NULL ) + wchar_t *pwszFileName = (wchar_t *)malloc(nWide * sizeof(wchar_t)); + if (pwszFileName == NULL) { return NULL; } - if( MultiByteToWideChar( CP_UTF8, 0, pszFilename, nMulti, pwszFileName, nWide ) == 0 ) + if (MultiByteToWideChar(CP_UTF8, 0, pszFilename, nMulti, pwszFileName, + nWide) == 0) { - free( pwszFileName ); + free(pwszFileName); return NULL; } return pwszFileName; @@ -234,62 +132,51 @@ const wchar_t* Utf8ToWideChar( const char *pszFilename ) /* SAUtf8WFOpen */ /************************************************************************/ -SAFile SAUtf8WFOpen( const char *pszFilename, const char *pszAccess ) +SAFile SAUtf8WFOpen(const char *pszFilename, const char *pszAccess) { SAFile file = NULL; - const wchar_t *pwszFileName, *pwszAccess; - pwszFileName = Utf8ToWideChar( pszFilename ); - pwszAccess = Utf8ToWideChar( pszAccess ); - if( pwszFileName != NULL && pwszAccess != NULL) + wchar_t *pwszFileName = Utf8ToWideChar(pszFilename); + wchar_t *pwszAccess = Utf8ToWideChar(pszAccess); + if (pwszFileName != NULL && pwszAccess != NULL) { - file = (SAFile) _wfopen( pwszFileName, pwszAccess ); + file = (SAFile)_wfopen(pwszFileName, pwszAccess); } - free ((wchar_t*) pwszFileName); - free ((wchar_t*) pwszAccess); + free(pwszFileName); + free(pwszAccess); return file; } -/************************************************************************/ -/* SAUtf8WRemove() */ -/************************************************************************/ - -int SAUtf8WRemove( const char *pszFilename ) +int SAUtf8WRemove(const char *pszFilename) { - const wchar_t *pwszFileName = Utf8ToWideChar( pszFilename ); - int rc = -1; - if( pwszFileName != NULL ) + wchar_t *pwszFileName = Utf8ToWideChar(pszFilename); + int rc = -1; + if (pwszFileName != NULL) { - rc = _wremove( pwszFileName ); + rc = _wremove(pwszFileName); } - free ((wchar_t*) pwszFileName); + free(pwszFileName); return rc; } #endif #ifdef SHPAPI_UTF8_HOOKS - -/************************************************************************/ -/* SASetupUtf8Hooks() */ -/************************************************************************/ - -void SASetupUtf8Hooks( SAHooks *psHooks ) -{ -#ifdef SHPAPI_WINDOWS - psHooks->FOpen = SAUtf8WFOpen; - psHooks->Remove = SAUtf8WRemove; -#else -# error "no implementations of UTF-8 hooks available for this platform" +#ifndef SHPAPI_WINDOWS +#error "no implementations of UTF-8 hooks available for this platform" #endif - psHooks->FRead = SADFRead; - psHooks->FWrite = SADFWrite; - psHooks->FSeek = SADFSeek; - psHooks->FTell = SADFTell; - psHooks->FFlush = SADFFlush; - psHooks->FClose = SADFClose; - psHooks->Error = SADError; - psHooks->Atof = atof; +void SASetupUtf8Hooks(SAHooks *psHooks) +{ + psHooks->FOpen = SAUtf8WFOpen; + psHooks->Remove = SAUtf8WRemove; + psHooks->FRead = SADFRead; + psHooks->FWrite = SADFWrite; + psHooks->FSeek = SADFSeek; + psHooks->FTell = SADFTell; + psHooks->FFlush = SADFFlush; + psHooks->FClose = SADFClose; + + psHooks->Error = SADError; + psHooks->Atof = atof; } - #endif diff --git a/shapelib/shapefil.h b/shapelib/shapefil.h index 199964d42..2328f15cc 100644 --- a/shapelib/shapefil.h +++ b/shapelib/shapefil.h @@ -2,7 +2,6 @@ #define SHAPEFILE_H_INCLUDED /****************************************************************************** - * $Id: shapefil.h,v 1.56 2018-08-16 15:39:07 erouault Exp $ * * Project: Shapelib * Purpose: Primary include file for Shapelib. @@ -10,185 +9,41 @@ * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam - * Copyright (c) 2012-2016, Even Rouault + * Copyright (c) 2012-2016, Even Rouault * - * This software is available under the following "MIT Style" license, - * or at the option of the licensee under the LGPL (see COPYING). This - * option is discussed in more detail in shapelib.html. - * - * -- - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later ****************************************************************************** * - * $Log: shapefil.h,v $ - * Revision 1.56 2018-08-16 15:39:07 erouault - * * shpopen.c, dbfopen.c, shptree.c, sbnsearch.c: resyc with GDAL - * internal shapelib. Mostly to allow building those files as C++ - * without warning. Also add FTDate entry in DBFFieldType - * (see https://github.com/OSGeo/gdal/pull/308). And some other - * code cleanups - * - * Revision 1.55 2016-12-05 18:44:08 erouault - * * dbfopen.c, shapefil.h: write DBF end-of-file character 0x1A by default. - * This behaviour can be controlled with the DBFSetWriteEndOfFileChar() - * function. - * - * Revision 1.54 2016-12-05 12:44:05 erouault - * * Major overhaul of Makefile build system to use autoconf/automake. - * - * * Warning fixes in contrib/ - * - * Revision 1.53 2016-12-04 15:30:15 erouault - * * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with - * GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo - * structures extended with new members. New functions: - * DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX, - * SHPSetFastModeReadObject - * - * * sbnsearch.c: new file to implement original ESRI .sbn spatial - * index reading. (no write support). New functions: - * SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree, - * SBNSearchDiskTreeInteger, SBNSearchFreeIds - * - * * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates - * with new file and symbols. - * - * * commit: helper script to cvs commit - * - * Revision 1.52 2011-12-11 22:26:46 fwarmerdam - * upgrade .qix access code to use SAHooks (gdal #3365) - * - * Revision 1.51 2011-07-24 05:59:25 fwarmerdam - * minimize use of CPLError in favor of SAHooks.Error() - * - * Revision 1.50 2011-05-13 17:35:17 fwarmerdam - * added DBFReorderFields() and DBFAlterFields() functions (from Even) - * - * Revision 1.49 2011-04-16 14:38:21 fwarmerdam - * avoid warnings with gcc on SHP_CVSID - * - * Revision 1.48 2010-08-27 23:42:52 fwarmerdam - * add SHPAPI_CALL attribute in code - * - * Revision 1.47 2010-01-28 11:34:34 fwarmerdam - * handle the shape file length limits more gracefully (#3236) - * - * Revision 1.46 2008-11-12 14:28:15 fwarmerdam - * DBFCreateField() now works on files with records - * - * Revision 1.45 2008/11/11 17:47:10 fwarmerdam - * added DBFDeleteField() function - * - * Revision 1.44 2008/01/16 20:05:19 bram - * Add file hooks that accept UTF-8 encoded filenames on some platforms. Use SASetupUtf8Hooks - * tosetup the hooks and check SHPAPI_UTF8_HOOKS for its availability. Currently, this - * is only available on the Windows platform that decodes the UTF-8 filenames to wide - * character strings and feeds them to _wfopen and _wremove. - * - * Revision 1.43 2008/01/10 16:35:30 fwarmerdam - * avoid _ prefix on #defined symbols (bug 1840) - * - * Revision 1.42 2007/12/18 18:28:14 bram - * - create hook for client specific atof (bugzilla ticket 1615) - * - check for NULL handle before closing cpCPG file, and close after reading. - * - * Revision 1.41 2007/12/15 20:25:32 bram - * dbfopen.c now reads the Code Page information from the DBF file, and exports - * this information as a string through the DBFGetCodePage function. This is - * either the number from the LDID header field ("LDID/") or as the - * content of an accompanying .CPG file. When creating a DBF file, the code can - * be set using DBFCreateEx. - * - * Revision 1.40 2007/12/06 07:00:25 fwarmerdam - * dbfopen now using SAHooks for fileio - * - * Revision 1.39 2007/12/04 20:37:56 fwarmerdam - * preliminary implementation of hooks api for io and errors - * - * Revision 1.38 2007/11/21 22:39:56 fwarmerdam - * close shx file in readonly mode (GDAL #1956) - * - * Revision 1.37 2007/10/27 03:31:14 fwarmerdam - * limit default depth of tree to 12 levels (gdal ticket #1594) - * - * Revision 1.36 2007/09/10 23:33:15 fwarmerdam - * Upstreamed support for visibility flag in SHPAPI_CALL for the needs - * of GDAL (gdal ticket #1810). - * - * Revision 1.35 2007/09/03 19:48:10 fwarmerdam - * move DBFReadAttribute() static dDoubleField into dbfinfo - * - * Revision 1.34 2006/06/17 15:33:32 fwarmerdam - * added pszWorkField - bug 1202 (rso) - * - * Revision 1.33 2006/02/15 01:14:30 fwarmerdam - * added DBFAddNativeFieldType - * - * Revision 1.32 2006/01/26 15:07:32 fwarmerdam - * add bMeasureIsUsed flag from Craig Bruce: Bug 1249 - * - * Revision 1.31 2006/01/05 01:27:27 fwarmerdam - * added dbf deletion mark/fetch - * - * Revision 1.30 2005/01/03 22:30:13 fwarmerdam - * added support for saved quadtrees - * - * Revision 1.29 2004/09/26 20:09:35 fwarmerdam - * avoid rcsid warnings - * - * Revision 1.28 2003/12/29 06:02:18 fwarmerdam - * added cpl_error.h option - * - * Revision 1.27 2003/04/21 18:30:37 warmerda - * added header write/update public methods - * - * Revision 1.26 2002/09/29 00:00:08 warmerda - * added FTLogical and logical attribute read/write calls - * - * Revision 1.25 2002/05/07 13:46:30 warmerda - * added DBFWriteAttributeDirectly(). - * - * Revision 1.24 2002/04/10 16:59:54 warmerda - * added SHPRewindObject - * - * Revision 1.23 2002/01/15 14:36:07 warmerda - * updated email address - * - * Revision 1.22 2002/01/15 14:32:00 warmerda - * try to improve SHPAPI_CALL docs */ #include -#ifdef USE_DBMALLOC -#include -#endif - #ifdef USE_CPL #include "cpl_conv.h" #endif #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif +/************************************************************************/ +/* Version related macros (added in 1.6.0) */ +/************************************************************************/ + +#define SHAPELIB_VERSION_MAJOR 1 +#define SHAPELIB_VERSION_MINOR 6 +#define SHAPELIB_VERSION_MICRO 0 + +#define SHAPELIB_MAKE_VERSION_NUMBER(major, minor, micro) \ + ((major) * 10000 + (minor) * 100 + (micro)) + +#define SHAPELIB_VERSION_NUMBER \ + SHAPELIB_MAKE_VERSION_NUMBER(SHAPELIB_VERSION_MAJOR, SHAPELIB_VERSION_MINOR, SHAPELIB_VERSION_MICRO) + +#define SHAPELIB_AT_LEAST(major, minor, micro) \ + (SHAPELIB_VERSION_NUMBER >= SHAPELIB_MAKE_VERSION_NUMBER(major, minor, micro)) + /************************************************************************/ /* Configuration options. */ /************************************************************************/ @@ -206,66 +61,51 @@ extern "C" { /* -------------------------------------------------------------------- */ #define DISABLE_MULTIPATCH_MEASURE -/* -------------------------------------------------------------------- */ -/* SHPAPI_CALL */ -/* */ -/* The following two macros are present to allow forcing */ -/* various calling conventions on the Shapelib API. */ -/* */ -/* To force __stdcall conventions (needed to call Shapelib */ -/* from Visual Basic and/or Dephi I believe) the makefile could */ -/* be modified to define: */ -/* */ -/* /DSHPAPI_CALL=__stdcall */ -/* */ -/* If it is desired to force export of the Shapelib API without */ -/* using the shapelib.def file, use the following definition. */ -/* */ -/* /DSHAPELIB_DLLEXPORT */ -/* */ -/* To get both at once it will be necessary to hack this */ -/* include file to define: */ -/* */ -/* #define SHPAPI_CALL __declspec(dllexport) __stdcall */ -/* #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall */ -/* */ -/* The complexity of the situation is partly caused by the */ -/* peculiar requirement of Visual C++ that __stdcall appear */ -/* after any "*"'s in the return value of a function while the */ -/* __declspec(dllexport) must appear before them. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* SHPAPI_CALL */ + /* */ + /* The following two macros are present to allow forcing */ + /* various calling conventions on the Shapelib API. */ + /* */ + /* To force __stdcall conventions (needed to call Shapelib */ + /* from Visual Basic and/or Delphi I believe) the makefile could */ + /* be modified to define: */ + /* */ + /* /DSHPAPI_CALL=__stdcall */ + /* */ + /* If it is desired to force export of the Shapelib API without */ + /* using the shapelib.def file, use the following definition. */ + /* */ + /* /DSHAPELIB_DLLEXPORT */ + /* */ + /* To get both at once it will be necessary to hack this */ + /* include file to define: */ + /* */ + /* #define SHPAPI_CALL __declspec(dllexport) __stdcall */ + /* #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall */ + /* */ + /* The complexity of the situation is partly caused by the */ + /* peculiar requirement of Visual C++ that __stdcall appear */ + /* after any "*"'s in the return value of a function while the */ + /* __declspec(dllexport) must appear before them. */ + /* -------------------------------------------------------------------- */ #ifdef SHAPELIB_DLLEXPORT -# define SHPAPI_CALL __declspec(dllexport) -# define SHPAPI_CALL1(x) __declspec(dllexport) x +#define SHPAPI_CALL __declspec(dllexport) +#define SHPAPI_CALL1(x) __declspec(dllexport) x #endif #ifndef SHPAPI_CALL -# if defined(USE_GCC_VISIBILITY_FLAG) -# define SHPAPI_CALL __attribute__ ((visibility("default"))) -# define SHPAPI_CALL1(x) __attribute__ ((visibility("default"))) x -# else -# define SHPAPI_CALL -# endif +#if defined(USE_GCC_VISIBILITY_FLAG) +#define SHPAPI_CALL __attribute__((visibility("default"))) +#define SHPAPI_CALL1(x) __attribute__((visibility("default"))) x +#else +#define SHPAPI_CALL #endif - -#ifndef SHPAPI_CALL1 -# define SHPAPI_CALL1(x) x SHPAPI_CALL #endif -/* -------------------------------------------------------------------- */ -/* Macros for controlling CVSID and ensuring they don't appear */ -/* as unreferenced variables resulting in lots of warnings. */ -/* -------------------------------------------------------------------- */ -#ifndef DISABLE_CVSID -# if defined(__GNUC__) && __GNUC__ >= 4 -# define SHP_CVSID(string) static const char cpl_cvsid[] __attribute__((used)) = string; -# else -# define SHP_CVSID(string) static const char cpl_cvsid[] = string; \ -static const char *cvsid_aw() { return( cvsid_aw() ? NULL : cpl_cvsid ); } -# endif -#else -# define SHP_CVSID(string) +#ifndef SHPAPI_CALL1 +#define SHPAPI_CALL1(x) x SHPAPI_CALL #endif /* -------------------------------------------------------------------- */ @@ -273,204 +113,201 @@ static const char *cvsid_aw() { return( cvsid_aw() ? NULL : cpl_cvsid ); } /* UTF-8 encoded filenames Unicode filenames */ /* -------------------------------------------------------------------- */ #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -# define SHPAPI_WINDOWS -# define SHPAPI_UTF8_HOOKS +#define SHPAPI_WINDOWS +#define SHPAPI_UTF8_HOOKS #endif -/* -------------------------------------------------------------------- */ -/* IO/Error hook functions. */ -/* -------------------------------------------------------------------- */ -typedef int *SAFile; + /* -------------------------------------------------------------------- */ + /* IO/Error hook functions. */ + /* -------------------------------------------------------------------- */ + typedef int *SAFile; #ifndef SAOffset -typedef unsigned long SAOffset; +#if defined(_MSC_VER) && _MSC_VER >= 1400 + typedef unsigned __int64 SAOffset; +#else + typedef unsigned long SAOffset; +#endif #endif -typedef struct { - SAFile (*FOpen) ( const char *filename, const char *access); - SAOffset (*FRead) ( void *p, SAOffset size, SAOffset nmemb, SAFile file); - SAOffset (*FWrite)( void *p, SAOffset size, SAOffset nmemb, SAFile file); - SAOffset (*FSeek) ( SAFile file, SAOffset offset, int whence ); - SAOffset (*FTell) ( SAFile file ); - int (*FFlush)( SAFile file ); - int (*FClose)( SAFile file ); - int (*Remove) ( const char *filename ); - - void (*Error) ( const char *message ); - double (*Atof) ( const char *str ); -} SAHooks; - -void SHPAPI_CALL SASetupDefaultHooks( SAHooks *psHooks ); + typedef struct + { + SAFile (*FOpen)(const char *filename, const char *access, + void *pvUserData); + SAOffset (*FRead)(void *p, SAOffset size, SAOffset nmemb, SAFile file); + SAOffset (*FWrite)(const void *p, SAOffset size, SAOffset nmemb, + SAFile file); + SAOffset (*FSeek)(SAFile file, SAOffset offset, int whence); + SAOffset (*FTell)(SAFile file); + int (*FFlush)(SAFile file); + int (*FClose)(SAFile file); + int (*Remove)(const char *filename, void *pvUserData); + + void (*Error)(const char *message); + double (*Atof)(const char *str); + void *pvUserData; + } SAHooks; + + void SHPAPI_CALL SASetupDefaultHooks(SAHooks *psHooks); #ifdef SHPAPI_UTF8_HOOKS -void SHPAPI_CALL SASetupUtf8Hooks( SAHooks *psHooks ); + void SHPAPI_CALL SASetupUtf8Hooks(SAHooks *psHooks); #endif -/************************************************************************/ -/* SHP Support. */ -/************************************************************************/ -typedef struct tagSHPObject SHPObject; + /************************************************************************/ + /* SHP Support. */ + /************************************************************************/ + typedef struct tagSHPObject SHPObject; -typedef struct -{ - SAHooks sHooks; + typedef struct + { + SAHooks sHooks; - SAFile fpSHP; - SAFile fpSHX; + SAFile fpSHP; + SAFile fpSHX; - int nShapeType; /* SHPT_* */ + int nShapeType; /* SHPT_* */ - unsigned int nFileSize; /* SHP file */ + unsigned int nFileSize; /* SHP file */ - int nRecords; - int nMaxRecords; - unsigned int*panRecOffset; - unsigned int *panRecSize; + int nRecords; + int nMaxRecords; + unsigned int *panRecOffset; + unsigned int *panRecSize; - double adBoundsMin[4]; - double adBoundsMax[4]; + double adBoundsMin[4]; + double adBoundsMax[4]; - int bUpdated; + int bUpdated; - unsigned char *pabyRec; - int nBufSize; + unsigned char *pabyRec; + int nBufSize; - int bFastModeReadObject; - unsigned char *pabyObjectBuf; - int nObjectBufSize; - SHPObject* psCachedObject; -} SHPInfo; + int bFastModeReadObject; + unsigned char *pabyObjectBuf; + int nObjectBufSize; + SHPObject *psCachedObject; + } SHPInfo; -typedef SHPInfo * SHPHandle; + typedef SHPInfo *SHPHandle; /* -------------------------------------------------------------------- */ /* Shape types (nSHPType) */ /* -------------------------------------------------------------------- */ -#define SHPT_NULL 0 -#define SHPT_POINT 1 -#define SHPT_ARC 3 -#define SHPT_POLYGON 5 +#define SHPT_NULL 0 +#define SHPT_POINT 1 +#define SHPT_ARC 3 +#define SHPT_POLYGON 5 #define SHPT_MULTIPOINT 8 -#define SHPT_POINTZ 11 -#define SHPT_ARCZ 13 -#define SHPT_POLYGONZ 15 +#define SHPT_POINTZ 11 +#define SHPT_ARCZ 13 +#define SHPT_POLYGONZ 15 #define SHPT_MULTIPOINTZ 18 -#define SHPT_POINTM 21 -#define SHPT_ARCM 23 -#define SHPT_POLYGONM 25 +#define SHPT_POINTM 21 +#define SHPT_ARCM 23 +#define SHPT_POLYGONM 25 #define SHPT_MULTIPOINTM 28 #define SHPT_MULTIPATCH 31 -/* -------------------------------------------------------------------- */ -/* Part types - everything but SHPT_MULTIPATCH just uses */ -/* SHPP_RING. */ -/* -------------------------------------------------------------------- */ - -#define SHPP_TRISTRIP 0 -#define SHPP_TRIFAN 1 -#define SHPP_OUTERRING 2 -#define SHPP_INNERRING 3 -#define SHPP_FIRSTRING 4 -#define SHPP_RING 5 - -/* -------------------------------------------------------------------- */ -/* SHPObject - represents on shape (without attributes) read */ -/* from the .shp file. */ -/* -------------------------------------------------------------------- */ -struct tagSHPObject -{ - int nSHPType; - - int nShapeId; /* -1 is unknown/unassigned */ - - int nParts; - int *panPartStart; - int *panPartType; - - int nVertices; - double *padfX; - double *padfY; - double *padfZ; - double *padfM; - - double dfXMin; - double dfYMin; - double dfZMin; - double dfMMin; - - double dfXMax; - double dfYMax; - double dfZMax; - double dfMMax; - - int bMeasureIsUsed; - int bFastModeReadObject; -}; - -/* -------------------------------------------------------------------- */ -/* SHP API Prototypes */ -/* -------------------------------------------------------------------- */ - -/* If pszAccess is read-only, the fpSHX field of the returned structure */ -/* will be NULL as it is not necessary to keep the SHX file open */ -SHPHandle SHPAPI_CALL - SHPOpen( const char * pszShapeFile, const char * pszAccess ); -SHPHandle SHPAPI_CALL - SHPOpenLL( const char *pszShapeFile, const char *pszAccess, - SAHooks *psHooks ); -SHPHandle SHPAPI_CALL - SHPOpenLLEx( const char *pszShapeFile, const char *pszAccess, - SAHooks *psHooks, int bRestoreSHX ); - -int SHPAPI_CALL - SHPRestoreSHX( const char *pszShapeFile, const char *pszAccess, - SAHooks *psHooks ); - -/* If setting bFastMode = TRUE, the content of SHPReadObject() is owned by the SHPHandle. */ -/* So you cannot have 2 valid instances of SHPReadObject() simultaneously. */ -/* The SHPObject padfZ and padfM members may be NULL depending on the geometry */ -/* type. It is illegal to free at hand any of the pointer members of the SHPObject structure */ -void SHPAPI_CALL SHPSetFastModeReadObject( SHPHandle hSHP, int bFastMode ); - -SHPHandle SHPAPI_CALL - SHPCreate( const char * pszShapeFile, int nShapeType ); -SHPHandle SHPAPI_CALL - SHPCreateLL( const char * pszShapeFile, int nShapeType, - SAHooks *psHooks ); -void SHPAPI_CALL - SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType, - double * padfMinBound, double * padfMaxBound ); - -SHPObject SHPAPI_CALL1(*) - SHPReadObject( SHPHandle hSHP, int iShape ); -int SHPAPI_CALL - SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject ); - -void SHPAPI_CALL - SHPDestroyObject( SHPObject * psObject ); -void SHPAPI_CALL - SHPComputeExtents( SHPObject * psObject ); -SHPObject SHPAPI_CALL1(*) - SHPCreateObject( int nSHPType, int nShapeId, int nParts, - const int * panPartStart, const int * panPartType, - int nVertices, - const double * padfX, const double * padfY, - const double * padfZ, const double * padfM ); -SHPObject SHPAPI_CALL1(*) - SHPCreateSimpleObject( int nSHPType, int nVertices, - const double * padfX, - const double * padfY, - const double * padfZ ); - -int SHPAPI_CALL - SHPRewindObject( SHPHandle hSHP, SHPObject * psObject ); - -void SHPAPI_CALL SHPClose( SHPHandle hSHP ); -void SHPAPI_CALL SHPWriteHeader( SHPHandle hSHP ); - -const char SHPAPI_CALL1(*) - SHPTypeName( int nSHPType ); -const char SHPAPI_CALL1(*) - SHPPartTypeName( int nPartType ); + /* -------------------------------------------------------------------- */ + /* Part types - everything but SHPT_MULTIPATCH just uses */ + /* SHPP_RING. */ + /* -------------------------------------------------------------------- */ + +#define SHPP_TRISTRIP 0 +#define SHPP_TRIFAN 1 +#define SHPP_OUTERRING 2 +#define SHPP_INNERRING 3 +#define SHPP_FIRSTRING 4 +#define SHPP_RING 5 + + /* -------------------------------------------------------------------- */ + /* SHPObject - represents on shape (without attributes) read */ + /* from the .shp file. */ + /* -------------------------------------------------------------------- */ + struct tagSHPObject + { + int nSHPType; + + int nShapeId; /* -1 is unknown/unassigned */ + + int nParts; + int *panPartStart; + int *panPartType; + + int nVertices; + double *padfX; + double *padfY; + double *padfZ; + double *padfM; + + double dfXMin; + double dfYMin; + double dfZMin; + double dfMMin; + + double dfXMax; + double dfYMax; + double dfZMax; + double dfMMax; + + int bMeasureIsUsed; + int bFastModeReadObject; + }; + + /* -------------------------------------------------------------------- */ + /* SHP API Prototypes */ + /* -------------------------------------------------------------------- */ + + /* If pszAccess is read-only, the fpSHX field of the returned structure */ + /* will be NULL as it is not necessary to keep the SHX file open */ + SHPHandle SHPAPI_CALL SHPOpen(const char *pszShapeFile, + const char *pszAccess); + SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszShapeFile, + const char *pszAccess, + const SAHooks *psHooks); + SHPHandle SHPAPI_CALL SHPOpenLLEx(const char *pszShapeFile, + const char *pszAccess, + const SAHooks *psHooks, int bRestoreSHX); + + int SHPAPI_CALL SHPRestoreSHX(const char *pszShapeFile, + const char *pszAccess, + const SAHooks *psHooks); + + /* If setting bFastMode = TRUE, the content of SHPReadObject() is owned by the SHPHandle. */ + /* So you cannot have 2 valid instances of SHPReadObject() simultaneously. */ + /* The SHPObject padfZ and padfM members may be NULL depending on the geometry */ + /* type. It is illegal to free at hand any of the pointer members of the SHPObject structure */ + void SHPAPI_CALL SHPSetFastModeReadObject(SHPHandle hSHP, int bFastMode); + + SHPHandle SHPAPI_CALL SHPCreate(const char *pszShapeFile, int nShapeType); + SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszShapeFile, int nShapeType, + const SAHooks *psHooks); + void SHPAPI_CALL SHPGetInfo(SHPHandle hSHP, int *pnEntities, + int *pnShapeType, double *padfMinBound, + double *padfMaxBound); + + SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle hSHP, int iShape); + int SHPAPI_CALL SHPWriteObject(SHPHandle hSHP, int iShape, + SHPObject *psObject); + + void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject); + void SHPAPI_CALL SHPComputeExtents(SHPObject *psObject); + SHPObject SHPAPI_CALL1(*) + SHPCreateObject(int nSHPType, int nShapeId, int nParts, + const int *panPartStart, const int *panPartType, + int nVertices, const double *padfX, const double *padfY, + const double *padfZ, const double *padfM); + SHPObject SHPAPI_CALL1(*) + SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX, + const double *padfY, const double *padfZ); + + int SHPAPI_CALL SHPRewindObject(SHPHandle hSHP, SHPObject *psObject); + + void SHPAPI_CALL SHPClose(SHPHandle hSHP); + void SHPAPI_CALL SHPWriteHeader(SHPHandle hSHP); + + const char SHPAPI_CALL1(*) SHPTypeName(int nSHPType); + const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType); /* -------------------------------------------------------------------- */ /* Shape quadtree indexing API. */ @@ -482,271 +319,244 @@ const char SHPAPI_CALL1(*) /* upper limit of tree levels for automatic estimation */ #define MAX_DEFAULT_TREE_DEPTH 12 -typedef struct shape_tree_node -{ - /* region covered by this node */ - double adfBoundsMin[4]; - double adfBoundsMax[4]; + typedef struct shape_tree_node + { + /* region covered by this node */ + double adfBoundsMin[4]; + double adfBoundsMax[4]; - /* list of shapes stored at this node. The papsShapeObj pointers - or the whole list can be NULL */ - int nShapeCount; - int *panShapeIds; - SHPObject **papsShapeObj; + /* list of shapes stored at this node. The papsShapeObj pointers + or the whole list can be NULL */ + int nShapeCount; + int *panShapeIds; + SHPObject **papsShapeObj; - int nSubNodes; - struct shape_tree_node *apsSubNode[MAX_SUBNODE]; + int nSubNodes; + struct shape_tree_node *apsSubNode[MAX_SUBNODE]; -} SHPTreeNode; + } SHPTreeNode; -typedef struct -{ - SHPHandle hSHP; + typedef struct + { + SHPHandle hSHP; - int nMaxDepth; - int nDimension; - int nTotalCount; + int nMaxDepth; + int nDimension; + int nTotalCount; - SHPTreeNode *psRoot; -} SHPTree; + SHPTreeNode *psRoot; + } SHPTree; -SHPTree SHPAPI_CALL1(*) - SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth, - double *padfBoundsMin, double *padfBoundsMax ); -void SHPAPI_CALL - SHPDestroyTree( SHPTree * hTree ); + SHPTree SHPAPI_CALL1(*) + SHPCreateTree(SHPHandle hSHP, int nDimension, int nMaxDepth, + const double *padfBoundsMin, const double *padfBoundsMax); + void SHPAPI_CALL SHPDestroyTree(SHPTree *hTree); -int SHPAPI_CALL - SHPWriteTree( SHPTree *hTree, const char * pszFilename ); + int SHPAPI_CALL SHPWriteTree(SHPTree *hTree, const char *pszFilename); -int SHPAPI_CALL - SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject ); -int SHPAPI_CALL - SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId ); + int SHPAPI_CALL SHPTreeAddShapeId(SHPTree *hTree, SHPObject *psObject); + int SHPAPI_CALL SHPTreeRemoveShapeId(SHPTree *hTree, int nShapeId); -void SHPAPI_CALL - SHPTreeTrimExtraNodes( SHPTree * hTree ); + void SHPAPI_CALL SHPTreeTrimExtraNodes(SHPTree *hTree); -int SHPAPI_CALL1(*) - SHPTreeFindLikelyShapes( SHPTree * hTree, - double * padfBoundsMin, - double * padfBoundsMax, - int * ); -int SHPAPI_CALL - SHPCheckBoundsOverlap( double *, double *, double *, double *, int ); + int SHPAPI_CALL1(*) + SHPTreeFindLikelyShapes(SHPTree *hTree, double *padfBoundsMin, + double *padfBoundsMax, int *); + int SHPAPI_CALL SHPCheckBoundsOverlap(const double *, const double *, + const double *, const double *, int); -int SHPAPI_CALL1(*) -SHPSearchDiskTree( FILE *fp, - double *padfBoundsMin, double *padfBoundsMax, - int *pnShapeCount ); + int SHPAPI_CALL1(*) + SHPSearchDiskTree(FILE *fp, double *padfBoundsMin, + double *padfBoundsMax, int *pnShapeCount); -typedef struct SHPDiskTreeInfo* SHPTreeDiskHandle; + typedef struct SHPDiskTreeInfo *SHPTreeDiskHandle; -SHPTreeDiskHandle SHPAPI_CALL - SHPOpenDiskTree( const char* pszQIXFilename, - SAHooks *psHooks ); + SHPTreeDiskHandle SHPAPI_CALL SHPOpenDiskTree(const char *pszQIXFilename, + const SAHooks *psHooks); -void SHPAPI_CALL - SHPCloseDiskTree( SHPTreeDiskHandle hDiskTree ); + void SHPAPI_CALL SHPCloseDiskTree(SHPTreeDiskHandle hDiskTree); -int SHPAPI_CALL1(*) -SHPSearchDiskTreeEx( SHPTreeDiskHandle hDiskTree, - double *padfBoundsMin, double *padfBoundsMax, - int *pnShapeCount ); + int SHPAPI_CALL1(*) + SHPSearchDiskTreeEx(SHPTreeDiskHandle hDiskTree, double *padfBoundsMin, + double *padfBoundsMax, int *pnShapeCount); -int SHPAPI_CALL - SHPWriteTreeLL(SHPTree *hTree, const char *pszFilename, SAHooks *psHooks ); + int SHPAPI_CALL SHPWriteTreeLL(SHPTree *hTree, const char *pszFilename, + const SAHooks *psHooks); -/* -------------------------------------------------------------------- */ -/* SBN Search API */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* SBN Search API */ + /* -------------------------------------------------------------------- */ -typedef struct SBNSearchInfo* SBNSearchHandle; + typedef struct SBNSearchInfo *SBNSearchHandle; -SBNSearchHandle SHPAPI_CALL - SBNOpenDiskTree( const char* pszSBNFilename, - SAHooks *psHooks ); + SBNSearchHandle SHPAPI_CALL SBNOpenDiskTree(const char *pszSBNFilename, + const SAHooks *psHooks); -void SHPAPI_CALL - SBNCloseDiskTree( SBNSearchHandle hSBN ); + void SHPAPI_CALL SBNCloseDiskTree(SBNSearchHandle hSBN); -int SHPAPI_CALL1(*) -SBNSearchDiskTree( SBNSearchHandle hSBN, - double *padfBoundsMin, double *padfBoundsMax, - int *pnShapeCount ); + int SHPAPI_CALL1(*) + SBNSearchDiskTree(SBNSearchHandle hSBN, const double *padfBoundsMin, + const double *padfBoundsMax, int *pnShapeCount); -int SHPAPI_CALL1(*) -SBNSearchDiskTreeInteger( SBNSearchHandle hSBN, - int bMinX, int bMinY, int bMaxX, int bMaxY, - int *pnShapeCount ); + int SHPAPI_CALL1(*) + SBNSearchDiskTreeInteger(SBNSearchHandle hSBN, int bMinX, int bMinY, + int bMaxX, int bMaxY, int *pnShapeCount); -void SHPAPI_CALL SBNSearchFreeIds( int* panShapeId ); + void SHPAPI_CALL SBNSearchFreeIds(int *panShapeId); -/************************************************************************/ -/* DBF Support. */ -/************************************************************************/ -typedef struct -{ - SAHooks sHooks; + /************************************************************************/ + /* DBF Support. */ + /************************************************************************/ + typedef struct + { + SAHooks sHooks; - SAFile fp; + SAFile fp; - int nRecords; + int nRecords; - int nRecordLength; /* Must fit on uint16 */ - int nHeaderLength; /* File header length (32) + field - descriptor length + spare space. - Must fit on uint16 */ - int nFields; - int *panFieldOffset; - int *panFieldSize; - int *panFieldDecimals; - char *pachFieldType; + int nRecordLength; /* Must fit on uint16 */ + int nHeaderLength; /* File header length (32) + field + descriptor length + spare space. + Must fit on uint16 */ + int nFields; + int *panFieldOffset; + int *panFieldSize; + int *panFieldDecimals; + char *pachFieldType; - char *pszHeader; /* Field descriptors */ + char *pszHeader; /* Field descriptors */ - int nCurrentRecord; - int bCurrentRecordModified; - char *pszCurrentRecord; + int nCurrentRecord; + int bCurrentRecordModified; + char *pszCurrentRecord; - int nWorkFieldLength; - char *pszWorkField; + int nWorkFieldLength; + char *pszWorkField; - int bNoHeader; - int bUpdated; + int bNoHeader; + int bUpdated; - union - { - double dfDoubleField; - int nIntField; - } fieldValue; + union + { + double dfDoubleField; + int nIntField; + } fieldValue; + + int iLanguageDriver; + char *pszCodePage; - int iLanguageDriver; - char *pszCodePage; + int nUpdateYearSince1900; /* 0-255 */ + int nUpdateMonth; /* 1-12 */ + int nUpdateDay; /* 1-31 */ - int nUpdateYearSince1900; /* 0-255 */ - int nUpdateMonth; /* 1-12 */ - int nUpdateDay; /* 1-31 */ + int bWriteEndOfFileChar; /* defaults to TRUE */ - int bWriteEndOfFileChar; /* defaults to TRUE */ -} DBFInfo; + int bRequireNextWriteSeek; + } DBFInfo; -typedef DBFInfo * DBFHandle; + typedef DBFInfo *DBFHandle; -typedef enum { - FTString, - FTInteger, - FTDouble, - FTLogical, - FTDate, - FTInvalid -} DBFFieldType; + typedef enum + { + FTString, + FTInteger, + FTDouble, + FTLogical, + FTDate, + FTInvalid + } DBFFieldType; /* Field descriptor/header size */ -#define XBASE_FLDHDR_SZ 32 +#define XBASE_FLDHDR_SZ 32 /* Shapelib read up to 11 characters, even if only 10 should normally be used */ -#define XBASE_FLDNAME_LEN_READ 11 +#define XBASE_FLDNAME_LEN_READ 11 /* On writing, we limit to 10 characters */ #define XBASE_FLDNAME_LEN_WRITE 10 /* Normally only 254 characters should be used. We tolerate 255 historically */ -#define XBASE_FLD_MAX_WIDTH 255 - -DBFHandle SHPAPI_CALL - DBFOpen( const char * pszDBFFile, const char * pszAccess ); -DBFHandle SHPAPI_CALL - DBFOpenLL( const char * pszDBFFile, const char * pszAccess, - SAHooks *psHooks ); -DBFHandle SHPAPI_CALL - DBFCreate( const char * pszDBFFile ); -DBFHandle SHPAPI_CALL - DBFCreateEx( const char * pszDBFFile, const char * pszCodePage ); -DBFHandle SHPAPI_CALL - DBFCreateLL( const char * pszDBFFile, const char * pszCodePage, SAHooks *psHooks ); - -int SHPAPI_CALL - DBFGetFieldCount( DBFHandle psDBF ); -int SHPAPI_CALL - DBFGetRecordCount( DBFHandle psDBF ); -int SHPAPI_CALL - DBFAddField( DBFHandle hDBF, const char * pszFieldName, - DBFFieldType eType, int nWidth, int nDecimals ); - -int SHPAPI_CALL - DBFAddNativeFieldType( DBFHandle hDBF, const char * pszFieldName, - char chType, int nWidth, int nDecimals ); - -int SHPAPI_CALL - DBFDeleteField( DBFHandle hDBF, int iField ); - -int SHPAPI_CALL - DBFReorderFields( DBFHandle psDBF, int* panMap ); - -int SHPAPI_CALL - DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName, - char chType, int nWidth, int nDecimals ); - -DBFFieldType SHPAPI_CALL - DBFGetFieldInfo( DBFHandle psDBF, int iField, - char * pszFieldName, int * pnWidth, int * pnDecimals ); - -int SHPAPI_CALL - DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName); - -int SHPAPI_CALL - DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField ); -double SHPAPI_CALL - DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField ); -const char SHPAPI_CALL1(*) - DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField ); -const char SHPAPI_CALL1(*) - DBFReadLogicalAttribute( DBFHandle hDBF, int iShape, int iField ); -int SHPAPI_CALL - DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField ); - -int SHPAPI_CALL - DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField, - int nFieldValue ); -int SHPAPI_CALL - DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField, - double dFieldValue ); -int SHPAPI_CALL - DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField, - const char * pszFieldValue ); -int SHPAPI_CALL - DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField ); - -int SHPAPI_CALL - DBFWriteLogicalAttribute( DBFHandle hDBF, int iShape, int iField, - const char lFieldValue); -int SHPAPI_CALL - DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, - void * pValue ); -const char SHPAPI_CALL1(*) - DBFReadTuple(DBFHandle psDBF, int hEntity ); -int SHPAPI_CALL - DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple ); - -int SHPAPI_CALL DBFIsRecordDeleted( DBFHandle psDBF, int iShape ); -int SHPAPI_CALL DBFMarkRecordDeleted( DBFHandle psDBF, int iShape, - int bIsDeleted ); - -DBFHandle SHPAPI_CALL - DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename ); - -void SHPAPI_CALL - DBFClose( DBFHandle hDBF ); -void SHPAPI_CALL - DBFUpdateHeader( DBFHandle hDBF ); -char SHPAPI_CALL - DBFGetNativeFieldType( DBFHandle hDBF, int iField ); - -const char SHPAPI_CALL1(*) - DBFGetCodePage(DBFHandle psDBF ); - -void SHPAPI_CALL - DBFSetLastModifiedDate( DBFHandle psDBF, int nYYSince1900, int nMM, int nDD ); - -void SHPAPI_CALL DBFSetWriteEndOfFileChar( DBFHandle psDBF, int bWriteFlag ); +#define XBASE_FLD_MAX_WIDTH 255 + + DBFHandle SHPAPI_CALL DBFOpen(const char *pszDBFFile, + const char *pszAccess); + DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszDBFFile, + const char *pszAccess, + const SAHooks *psHooks); + DBFHandle SHPAPI_CALL DBFCreate(const char *pszDBFFile); + DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszDBFFile, + const char *pszCodePage); + DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszDBFFile, + const char *pszCodePage, + const SAHooks *psHooks); + + int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF); + int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF); + int SHPAPI_CALL DBFAddField(DBFHandle hDBF, const char *pszFieldName, + DBFFieldType eType, int nWidth, int nDecimals); + + int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle hDBF, + const char *pszFieldName, char chType, + int nWidth, int nDecimals); + + int SHPAPI_CALL DBFDeleteField(DBFHandle hDBF, int iField); + + int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, const int *panMap); + + int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField, + const char *pszFieldName, char chType, + int nWidth, int nDecimals); + + DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, + char *pszFieldName, int *pnWidth, + int *pnDecimals); + + int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName); + + int SHPAPI_CALL DBFReadIntegerAttribute(DBFHandle hDBF, int iShape, + int iField); + double SHPAPI_CALL DBFReadDoubleAttribute(DBFHandle hDBF, int iShape, + int iField); + const char SHPAPI_CALL1(*) + DBFReadStringAttribute(DBFHandle hDBF, int iShape, int iField); + const char SHPAPI_CALL1(*) + DBFReadLogicalAttribute(DBFHandle hDBF, int iShape, int iField); + int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle hDBF, int iShape, int iField); + + int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle hDBF, int iShape, + int iField, int nFieldValue); + int SHPAPI_CALL DBFWriteDoubleAttribute(DBFHandle hDBF, int iShape, + int iField, double dFieldValue); + int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle hDBF, int iShape, + int iField, + const char *pszFieldValue); + int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle hDBF, int iShape, + int iField); + + int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle hDBF, int iShape, + int iField, + const char lFieldValue); + int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, + int iField, const void *pValue); + const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity); + int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, + const void *pRawTuple); + + int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape); + int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape, + int bIsDeleted); + + DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, + const char *pszFilename); + + void SHPAPI_CALL DBFClose(DBFHandle hDBF); + void SHPAPI_CALL DBFUpdateHeader(DBFHandle hDBF); + char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle hDBF, int iField); + + const char SHPAPI_CALL1(*) DBFGetCodePage(DBFHandle psDBF); + + void SHPAPI_CALL DBFSetLastModifiedDate(DBFHandle psDBF, int nYYSince1900, + int nMM, int nDD); + + void SHPAPI_CALL DBFSetWriteEndOfFileChar(DBFHandle psDBF, int bWriteFlag); #ifdef __cplusplus } diff --git a/shapelib/shapelib.html b/shapelib/shapelib.html index fa81f91aa..b3d72ba5a 100644 --- a/shapelib/shapelib.html +++ b/shapelib/shapelib.html @@ -27,20 +27,19 @@

Supporting Information

What is a Shapefile?

If you don't know, you probably don't need this library. The Shapefile -format is a working and interchange format promulagated by +format is a working and interchange format promulgated by ESRI for simple vector data with attributes.

-An excellent white paper on the shapefile format -is available from ESRI, -but it is .pdf format, so you will need Adobe Acrobat to browse it.

+An excellent white paper +on the shapefile format is available from ESRI.

The file format actually consists of three files.

 XXX.shp - holds the actual vertices.
 XXX.shx - hold index data pointing to the structures in the .shp file.
-XXX.dbf - holds the attributes in xBase (dBase) format.  
+XXX.dbf - holds the attributes in xBase (dBase) format.
 

Download

@@ -48,27 +47,22 @@

Download

Source code, and some other odds and ends can be downloaded from http://download.osgeo.org/shapelib.

-Shapelib is available for anonymous CVS access: - -

-  cvs -d :pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot login
-  Password: (hit enter)
-  cvs -d :pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot co shapelib
-
+Shapelib repository is at +https://github.com/OSGeo/shapelib

Bugs, Maintainance and Support

-This library is maintained by Frank -Warmerdam. Please send me bug reports, patches and suggestions for the +This library is maintained by Frank +Warmerdam. Please send me bug reports, patches and suggestions for the library via the maptools.org Bugzilla. Shapelib bugs can also be queried.

-Shapelib is hosted at +Shapelib is hosted at shapelib.maptools.org. A mailing -list for discussion of how to use shapelib, and announcing new releases -is -available. To get notification of new releases of Shapelib subscribe to +list for discussion of how to use shapelib, and announcing new releases +is +available. To get notification of new releases of Shapelib subscribe to the project mailing list at https://lists.osgeo.org/pipermail/shapelib/.

Credits

@@ -78,7 +72,7 @@

Credits

  • Bill Miller (NY-DOT) for shputils.c -
  • Carl Anderson for the contents of the contrib directory, and +
  • Carl Anderson for the contents of the contrib directory, and the "tuple" additions to dbfopen.c.
  • Andrea Giacomelli for patches for dbfopen.c.
  • Doug Matthews for portability improvements. @@ -96,10 +90,10 @@

    Credits

    In Memorium

    I would like to dedicate Shapelib to the memory of Sol Katz. While I never -met him in person, his generous contributions to the GIS community took +met him in person, his generous contributions to the GIS community took many forms, including free distribution of a variety of GIS translators -with source. The fact that he used this Shapelib in some of his utilities, -and thanked me was a great encouragement to me. I hope I can do his memory +with source. The fact that he used this Shapelib in some of his utilities, +and thanked me was a great encouragement to me. I hope I can do his memory honour by trying to contribute in a similar fashion.

    Portability

    @@ -114,7 +108,7 @@

    Portability

    The shputils.c module is contributed, and may not take the same approach to portability as the rest of the package.

    -On Linux, and most unix systems it should be possible to build and +On Linux, and most unix systems it should be possible to build and install shapefile support as a shared library using the "lib" and "lib_install" targets of the Makefile. Note that this Makefile doesn't use autoconf mechanisms and will generally require some hand tailoring for your environment. @@ -123,11 +117,11 @@

    Limitations

      -
    • You can't modify the vertices of existing structures (though you - can update the attributes of existing structures, and create new +
    • You can't modify the vertices of existing structures (though you + can update the attributes of existing structures, and create new structures).

      -

    • Not written in such a way as to be particularly fast. This is +
    • Not written in such a way as to be particularly fast. This is particularly true of the 1.2 API. For applications more concerned with speed it may be worth using the V1.1 API.

      @@ -159,32 +153,32 @@

      Other Shapefile Resources

    • Language ID / Code Page mappings

      -

    • Shapelib is used within the multiformat -OGR library. If you are looking for a +
    • Shapelib is used within the multiformat +OGR library. If you are looking for a high level C++ library with support for many geospatial vector formats you might want to check it out.

      -

    • Ari Jolma has produced an initial perl binding on top of shapelib, -which can be found at CPAN as Geo::ShapeFile under the +
    • Ari Jolma has produced an initial perl binding on top of shapelib, +which can be found at CPAN as Geo::ShapeFile under the Geo module.

      -

    • Bernhard Herzog has produced python bindings for Shapelib with -SWIG, available at http://ftp.intevation.de/users/bh/pyshapelib. A new version not using swig is +
    • Bernhard Herzog has produced python bindings for Shapelib with +SWIG, available at http://ftp.intevation.de/users/bh/pyshapelib. A new version not using swig is available as part of Thuban.

    • Delphi bindings for Shapelib courtesy of Alexander Weidauer.

      -

    • Miguel Filgueiras has implemented +
    • Miguel Filgueiras has implemented Tcl bindings for Shapelib as part of GPSMan.

    • David Gancarz has implemented a Microsoft .NET wrapper for -Shapelib. An example of using shapelib with VB6 is also icluded in the .NET wrapper project file.

      +Shapelib. An example of using shapelib with VB6 is also included in the .NET wrapper project file.

      -

    • Andrey Hristov (php at hristov dot com) has developed a PHP extension +
    • Andrey Hristov (php at hristov dot com) has developed a PHP extension based on Shapelib. It can be found in CVS at http://cvs.php.net/pecl/shp.

    • Toyoda Eizi has developed Ruby bindings found at @@ -200,11 +194,11 @@

      Other Shapefile Resources

    • Tom Russo has implemented a shpcs2cs program, which reprojects shapefiles using arguments similar to the PROJ.4 cs2cs program including datum conversion. -Use as an alternate to the contrib/shpproj which doesn't do datums. It is +Use as an alternate to the contrib/shpproj which doesn't do datums. It is available at the bottom of Tom's Xastir Shapefile Resources page.

      -

    • -Andrew Williamson's +
    • +Andrew Williamson's Useful Scripts and Stuff page for ArcView, which includes ShapeChecker.

      @@ -216,13 +210,13 @@

      Other Shapefile Resources

    • The ShapeFile Read/Write OCX is another option for Visual Basic programmers.

      -

    • Isovist Analyst is a sort-of-free isovist generating extension for +
    • Isovist Analyst is a sort-of-free isovist generating extension for ArcView using shapelib.

      -

    • shpdiff utility +
    • shpdiff utility by Bryce Nesbitt.

      -

    • Aequometer: a program for +
    • Aequometer: a program for MS Excel to calculate the area of polygons and export as shapefiles.

    diff --git a/shapelib/shp_api.html b/shapelib/shp_api.html index d773e3e56..55900bd6f 100644 --- a/shapelib/shp_api.html +++ b/shapelib/shp_api.html @@ -31,7 +31,7 @@

    Shape Types

    3D Shape Types (may include "measure" values for vertices): - #define SHPT_POINTZ 11 + #define SHPT_POINTZ 11 #define SHPT_ARCZ 13 #define SHPT_POLYGONZ 15 #define SHPT_MULTIPOINTZ 18 @@ -66,9 +66,9 @@

    SHPObject

    int nParts; # of Parts (0 implies single part with no info) int *panPartStart; Start Vertex of part int *panPartType; Part Type (SHPP_RING if not SHPT_MULTIPATCH) - - int nVertices; Vertex list - double *padfX; + + int nVertices; Vertex list + double *padfX; double *padfY; double *padfZ; (all zero if not provided) double *padfM; (all zero if not provided) @@ -97,15 +97,15 @@

    SHPOpen()

    just be the path plus the basename of the pair. pszAccess: The fopen() style access string. At this time only - "rb" (read-only binary) and "rb+" (read/write binary) + "rb" (read-only binary) and "rb+" (read/write binary) should be used.
The SHPOpen() function should be used to establish access to the two files - for accessing vertices (.shp and .shx). Note that both files have to + for accessing vertices (.shp and .shx). Note that both files have to be in the indicated directory, and must have the expected extensions in - lower case. The returned SHPHandle is passed to other access functions, - and SHPClose() should be invoked to recover resources, and flush changes + lower case. The returned SHPHandle is passed to other access functions, + and SHPClose() should be invoked to recover resources, and flush changes to disk when complete.

@@ -116,7 +116,7 @@

SHPGetInfo()

void SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType, double * padfMinBound, double * padfMaxBound ); - hSHP: The handle previously returned by SHPOpen() + hSHP: The handle previously returned by SHPOpen() or SHPCreate(). pnEntities: A pointer to an integer into which the number of @@ -124,20 +124,20 @@

SHPGetInfo()

pnShapetype: A pointer to an integer into which the shapetype of this file should be placed. Shapefiles may contain - either SHPT_POINT, SHPT_ARC, SHPT_POLYGON or + either SHPT_POINT, SHPT_ARC, SHPT_POLYGON or SHPT_MULTIPOINT entities. This may be NULL. padfMinBound: The X, Y, Z and M minimum values will be placed into this four entry array. This may be NULL. - + padfMaxBound: The X, Y, Z and M maximum values will be placed into this four entry array. This may be NULL.
The SHPGetInfo() function retrieves various information about shapefile - as a whole. The bounds are read from the file header, and may be + as a whole. The bounds are read from the file header, and may be inaccurate if the file was improperly generated.

- +

SHPReadObject()

@@ -145,10 +145,10 @@

SHPReadObject()

 SHPObject *SHPReadObject( SHPHandle hSHP, int iShape );
 
-  hSHP:			The handle previously returned by SHPOpen() 
+  hSHP:			The handle previously returned by SHPOpen()
 			or SHPCreate().
 
-  iShape:		The entity number of the shape to read.  Entity 
+  iShape:		The entity number of the shape to read.  Entity
 			numbers are between 0 and nEntities-1 (as returned
 			by SHPGetInfo()).
 
@@ -156,7 +156,7 @@

SHPReadObject()

The SHPReadObject() call is used to read a single structure, or entity from the shapefile. See the definition of the SHPObject structure for detailed information on fields of a SHPObject. SHPObject's returned from - SHPReadObject() should be deallocated with SHPDestroyShape(). + SHPReadObject() should be deallocated with SHPDestroyShape(). SHPReadObject() will return NULL if an illegal iShape value is requested.

Note that the bounds placed into the SHPObject are those read from the @@ -175,7 +175,7 @@

SHPClose()

 void	SHPClose( SHPHandle hSHP );
 
-  hSHP:			The handle previously returned by SHPOpen() 
+  hSHP:			The handle previously returned by SHPOpen()
 			or SHPCreate().
 
@@ -196,7 +196,7 @@

SHPCreate()

just be the path plus the basename of the pair. nShapeType: The type of shapes to be stored in the newly created - file. It may be either SHPT_POINT, SHPT_ARC, + file. It may be either SHPT_POINT, SHPT_ARC, SHPT_POLYGON or SHPT_MULTIPOINT. @@ -208,15 +208,15 @@

SHPCreate()

SHPCreateSimpleObject()

-SHPObject * 
-     SHPCreateSimpleObject( int nSHPType, int nVertices, 
+SHPObject *
+     SHPCreateSimpleObject( int nSHPType, int nVertices,
 			    double *padfX, double * padfY, double *padfZ, );
 
   nSHPType:		The SHPT_ type of the object to be created, such
                         as SHPT_POINT, or SHPT_POLYGON.
-  
-  nVertices:		The number of vertices being passed in padfX,    
-                        padfY, and padfZ. 
+
+  nVertices:		The number of vertices being passed in padfX,
+                        padfY, and padfZ.
 
   padfX:		An array of nVertices X coordinates of the vertices
                         for this object.
@@ -229,7 +229,7 @@ 

SHPCreateSimpleObject()

they are all assumed to be zero.
- The SHPCreateSimpleObject() allows for the convenient creation of + The SHPCreateSimpleObject() allows for the convenient creation of simple objects. This is normally used so that the SHPObject can be passed to SHPWriteObject() to write it to the file. The simple object creation API assumes an M (measure) value of zero for each vertex. For @@ -240,7 +240,7 @@

SHPCreateSimpleObject()

SHPDestroyObject() function should be used to free resources associated with an object allocated with SHPCreateSimpleObject().

- This function computes a bounding box for the SHPObject from the given + This function computes a bounding box for the SHPObject from the given vertices.

@@ -248,10 +248,10 @@

SHPCreateSimpleObject()

SHPCreateObject()

-SHPObject * 
+SHPObject *
      SHPCreateObject( int nSHPType, int iShape,
                       int nParts, int * panPartStart, int * panPartType,
-                      int nVertices, double *padfX, double * padfY, 
+                      int nVertices, double *padfX, double * padfY,
                       double *padfZ, double *padfM );
 
   nSHPType:		The SHPT_ type of the object to be created, such
@@ -260,19 +260,19 @@ 

SHPCreateObject()

iShape: The shapeid to be recorded with this shape. nParts: The number of parts for this object. If this is - zero for ARC, or POLYGON type objects, a single + zero for ARC, or POLYGON type objects, a single zero valued part will be created internally. - + panPartStart: The list of zero based start vertices for the rings (parts) in this object. The first should always be zero. This may be NULL if nParts is 0. - + panPartType: The type of each of the parts. This is only meaningful for MULTIPATCH files. For all other cases this may be NULL, and will be assumed to be SHPP_RING. - - nVertices: The number of vertices being passed in padfX, - padfY, and padfZ. + + nVertices: The number of vertices being passed in padfX, + padfY, and padfZ. padfX: An array of nVertices X coordinates of the vertices for this object. @@ -284,19 +284,19 @@

SHPCreateObject()

for this object. This may be NULL in which case they are all assumed to be zero. - padfM: An array of nVertices M (measure values) of the - vertices for this object. This may be NULL in which + padfM: An array of nVertices M (measure values) of the + vertices for this object. This may be NULL in which case they are all assumed to be zero.
- The SHPCreateSimpleObject() allows for the creation of objects (shapes). - This is normally used so that the SHPObject can be passed to + The SHPCreateSimpleObject() allows for the creation of objects (shapes). + This is normally used so that the SHPObject can be passed to SHPWriteObject() to write it to the file.

- The SHPDestroyObject() function should be used to free resources associated + The SHPDestroyObject() function should be used to free resources associated with an object allocated with SHPCreateObject().

- This function computes a bounding box for the SHPObject from the given + This function computes a bounding box for the SHPObject from the given vertices.

@@ -308,9 +308,9 @@

SHPComputeExtents()

psObject: An existing shape object to be updated in place. - + This function will recompute the extents of this shape, replacing the - existing values of the dfXMin, dfYMin, dfZMin, dfMMin, dfXMax, dfYMax, + existing values of the dfXMin, dfYMin, dfZMin, dfMMin, dfXMax, dfYMax, dfZMax, and dfMMax values based on the current set of vertices for the shape. This function is automatically called by SHPCreateObject() but if the vertices of an existing object are altered it should be called again @@ -323,14 +323,14 @@

SHPWriteObject()

 int SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject *psObject );
 
-  hSHP:			The handle previously returned by SHPOpen("r+") 
+  hSHP:			The handle previously returned by SHPOpen("r+")
 			or SHPCreate().
 
   iShape:		The entity number of the shape to write.  A value of
-		        -1 should be used for new shapes.  
+		        -1 should be used for new shapes.
 
   psObject:		The shape to write to the file. This should have
-                        been created with SHPCreateObject(), or 
+                        been created with SHPCreateObject(), or
                         SHPCreateSimpleObject().
 
@@ -368,7 +368,7 @@

SHPRewindObject()

This function will reverse any rings necessary in order to enforce the shapefile restrictions on the required order of inner and outer rings in the Shapefile specification. It returns TRUE if a change is made and FALSE - if no change is made. Only polygon objects will be affected though any + if no change is made. Only polygon objects will be affected though any object may be passed.

diff --git a/shapelib/shpopen.c b/shapelib/shpopen.c index 2fcff96da..2cf982ddf 100644 --- a/shapelib/shpopen.c +++ b/shapelib/shpopen.c @@ -1,5 +1,4 @@ /****************************************************************************** - * $Id: shpopen.c,v 1.78 2019-02-28 15:55:23 erouault Exp $ * * Project: Shapelib * Purpose: Implementation of core Shapefile read/write functions. @@ -7,367 +6,72 @@ * ****************************************************************************** * Copyright (c) 1999, 2001, Frank Warmerdam - * Copyright (c) 2011-2013, Even Rouault + * Copyright (c) 2011-2019, Even Rouault * - * This software is available under the following "MIT Style" license, - * or at the option of the licensee under the LGPL (see COPYING). This - * option is discussed in more detail in shapelib.html. - * - * -- - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - ****************************************************************************** - * - * $Log: shpopen.c,v $ - * Revision 1.78 2019-02-28 15:55:23 erouault - * * shpopen.c: resync with GDAL internal shapelib to avoid being dependent - * on correctness of file size field in .shp. Fixes - * https://lists.osgeo.org/pipermail/gdal-dev/2018-October/049218.html - * - * Revision 1.77 2018-08-16 15:39:07 erouault - * * shpopen.c, dbfopen.c, shptree.c, sbnsearch.c: resyc with GDAL - * internal shapelib. Mostly to allow building those files as C++ - * without warning. Also add FTDate entry in DBFFieldType - * (see https://github.com/OSGeo/gdal/pull/308). And some other - * code cleanups - * - * Revision 1.76 2017-09-10 10:11:36 erouault - * * shpopen.c: resync with GDAL copy. Make sure to zero terminate all - * error messages. And fix regression regarding re-writing the last shape - * of a file (https://trac.osgeo.org/gdal/ticket/7031) - * - * Revision 1.75 2016-12-05 12:44:05 erouault - * * Major overhaul of Makefile build system to use autoconf/automake. - * - * * Warning fixes in contrib/ - * - * Revision 1.74 2016-12-04 15:30:15 erouault - * * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with - * GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo - * structures extended with new members. New functions: - * DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX, - * SHPSetFastModeReadObject - * - * * sbnsearch.c: new file to implement original ESRI .sbn spatial - * index reading. (no write support). New functions: - * SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree, - * SBNSearchDiskTreeInteger, SBNSearchFreeIds - * - * * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates - * with new file and symbols. - * - * * commit: helper script to cvs commit - * - * Revision 1.73 2012-01-24 22:33:01 fwarmerdam - * fix memory leak on failure to open .shp (gdal #4410) - * - * Revision 1.72 2011-12-11 22:45:28 fwarmerdam - * fix failure return from SHPOpenLL. - * - * Revision 1.71 2011-09-15 03:33:58 fwarmerdam - * fix missing cast (#2344) - * - * Revision 1.70 2011-07-24 05:59:25 fwarmerdam - * minimize use of CPLError in favor of SAHooks.Error() - * - * Revision 1.69 2011-07-24 03:24:22 fwarmerdam - * fix memory leaks in error cases creating shapefiles (#2061) - * - * Revision 1.68 2010-08-27 23:42:52 fwarmerdam - * add SHPAPI_CALL attribute in code - * - * Revision 1.67 2010-07-01 08:15:48 fwarmerdam - * do not error out on an object with zero vertices - * - * Revision 1.66 2010-07-01 07:58:57 fwarmerdam - * minor cleanup of error handling - * - * Revision 1.65 2010-07-01 07:27:13 fwarmerdam - * white space formatting adjustments - * - * Revision 1.64 2010-01-28 11:34:34 fwarmerdam - * handle the shape file length limits more gracefully (#3236) - * - * Revision 1.63 2010-01-28 04:04:40 fwarmerdam - * improve numerical accuracy of SHPRewind() algs (gdal #3363) - * - * Revision 1.62 2010-01-17 05:34:13 fwarmerdam - * Remove asserts on x/y being null (#2148). - * - * Revision 1.61 2010-01-16 05:07:42 fwarmerdam - * allow 0/nulls in shpcreateobject (#2148) - * - * Revision 1.60 2009-09-17 20:50:02 bram - * on Win32, define snprintf as alias to _snprintf - * - * Revision 1.59 2008-03-14 05:25:31 fwarmerdam - * Correct crash on buggy geometries (gdal #2218) - * - * Revision 1.58 2008/01/08 23:28:26 bram - * on line 2095, use a float instead of a double to avoid a compiler warning - * - * Revision 1.57 2007/12/06 07:00:25 fwarmerdam - * dbfopen now using SAHooks for fileio - * - * Revision 1.56 2007/12/04 20:37:56 fwarmerdam - * preliminary implementation of hooks api for io and errors - * - * Revision 1.55 2007/11/21 22:39:56 fwarmerdam - * close shx file in readonly mode (GDAL #1956) - * - * Revision 1.54 2007/11/15 00:12:47 mloskot - * Backported recent changes from GDAL (Ticket #1415) to Shapelib. - * - * Revision 1.53 2007/11/14 22:31:08 fwarmerdam - * checks after mallocs to detect for corrupted/voluntary broken shapefiles. - * http://trac.osgeo.org/gdal/ticket/1991 - * - * Revision 1.52 2007/06/21 15:58:33 fwarmerdam - * fix for SHPRewindObject when rings touch at one vertex (gdal #976) - * - * Revision 1.51 2006/09/04 15:24:01 fwarmerdam - * Fixed up log message for 1.49. - * - * Revision 1.50 2006/09/04 15:21:39 fwarmerdam - * fix of last fix - * - * Revision 1.49 2006/09/04 15:21:00 fwarmerdam - * MLoskot: Added stronger test of Shapefile reading failures, e.g. truncated - * files. The problem was discovered by Tim Sutton and reported here - * https://svn.qgis.org/trac/ticket/200 - * - * Revision 1.48 2006/01/26 15:07:32 fwarmerdam - * add bMeasureIsUsed flag from Craig Bruce: Bug 1249 - * - * Revision 1.47 2006/01/04 20:07:23 fwarmerdam - * In SHPWriteObject() make sure that the record length is updated - * when rewriting an existing record. - * - * Revision 1.46 2005/02/11 17:17:46 fwarmerdam - * added panPartStart[0] validation - * - * Revision 1.45 2004/09/26 20:09:48 fwarmerdam - * const correctness changes - * - * Revision 1.44 2003/12/29 00:18:39 fwarmerdam - * added error checking for failed IO and optional CPL error reporting - * - * Revision 1.43 2003/12/01 16:20:08 warmerda - * be careful of zero vertex shapes - * - * Revision 1.42 2003/12/01 14:58:27 warmerda - * added degenerate object check in SHPRewindObject() - * - * Revision 1.41 2003/07/08 15:22:43 warmerda - * avoid warning - * - * Revision 1.40 2003/04/21 18:30:37 warmerda - * added header write/update public methods - * - * Revision 1.39 2002/08/26 06:46:56 warmerda - * avoid c++ comments - * - * Revision 1.38 2002/05/07 16:43:39 warmerda - * Removed debugging printf() - * - * Revision 1.37 2002/04/10 17:35:22 warmerda - * fixed bug in ring reversal code - * - * Revision 1.36 2002/04/10 16:59:54 warmerda - * added SHPRewindObject - * - * Revision 1.35 2001/12/07 15:10:44 warmerda - * fix if .shx fails to open - * - * Revision 1.34 2001/11/01 16:29:55 warmerda - * move pabyRec into SHPInfo for thread safety - * - * Revision 1.33 2001/07/03 12:18:15 warmerda - * Improved cleanup if SHX not found, provided by Riccardo Cohen. - * - * Revision 1.32 2001/06/22 01:58:07 warmerda - * be more careful about establishing initial bounds in face of NULL shapes - * - * Revision 1.31 2001/05/31 19:35:29 warmerda - * added support for writing null shapes - * - * Revision 1.30 2001/05/28 12:46:29 warmerda - * Add some checking on reasonableness of record count when opening. - * - * Revision 1.29 2001/05/23 13:36:52 warmerda - * added use of SHPAPI_CALL - * - * Revision 1.28 2001/02/06 22:25:06 warmerda - * fixed memory leaks when SHPOpen() fails - * - * Revision 1.27 2000/07/18 15:21:33 warmerda - * added better enforcement of -1 for append in SHPWriteObject - * - * Revision 1.26 2000/02/16 16:03:51 warmerda - * added null shape support - * - * Revision 1.25 1999/12/15 13:47:07 warmerda - * Fixed record size settings in .shp file (was 4 words too long) - * Added stdlib.h. - * - * Revision 1.24 1999/11/05 14:12:04 warmerda - * updated license terms - * - * Revision 1.23 1999/07/27 00:53:46 warmerda - * added support for rewriting shapes - * - * Revision 1.22 1999/06/11 19:19:11 warmerda - * Cleanup pabyRec static buffer on SHPClose(). - * - * Revision 1.21 1999/06/02 14:57:56 kshih - * Remove unused variables - * - * Revision 1.20 1999/04/19 21:04:17 warmerda - * Fixed syntax error. - * - * Revision 1.19 1999/04/19 21:01:57 warmerda - * Force access string to binary in SHPOpen(). - * - * Revision 1.18 1999/04/01 18:48:07 warmerda - * Try upper case extensions if lower case doesn't work. - * - * Revision 1.17 1998/12/31 15:29:39 warmerda - * Disable writing measure values to multipatch objects if - * DISABLE_MULTIPATCH_MEASURE is defined. - * - * Revision 1.16 1998/12/16 05:14:33 warmerda - * Added support to write MULTIPATCH. Fixed reading Z coordinate of - * MULTIPATCH. Fixed record size written for all feature types. - * - * Revision 1.15 1998/12/03 16:35:29 warmerda - * r+b is proper binary access string, not rb+. - * - * Revision 1.14 1998/12/03 15:47:56 warmerda - * Fixed setting of nVertices in SHPCreateObject(). - * - * Revision 1.13 1998/12/03 15:33:54 warmerda - * Made SHPCalculateExtents() separately callable. - * - * Revision 1.12 1998/11/11 20:01:50 warmerda - * Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines. - * - * Revision 1.11 1998/11/09 20:56:44 warmerda - * Fixed up handling of file wide bounds. - * - * Revision 1.10 1998/11/09 20:18:51 warmerda - * Converted to support 3D shapefiles, and use of SHPObject. - * - * Revision 1.9 1998/02/24 15:09:05 warmerda - * Fixed memory leak. - * - * Revision 1.8 1997/12/04 15:40:29 warmerda - * Fixed byte swapping of record number, and record length fields in the - * .shp file. - * - * Revision 1.7 1995/10/21 03:15:58 warmerda - * Added support for binary file access, the magic cookie 9997 - * and tried to improve the int32 selection logic for 16bit systems. - * - * Revision 1.6 1995/09/04 04:19:41 warmerda - * Added fix for file bounds. - * - * Revision 1.5 1995/08/25 15:16:44 warmerda - * Fixed a couple of problems with big endian systems ... one with bounds - * and the other with multipart polygons. - * - * Revision 1.4 1995/08/24 18:10:17 warmerda - * Switch to use SfRealloc() to avoid problems with pre-ANSI realloc() - * functions (such as on the Sun). - * - * Revision 1.3 1995/08/23 02:23:15 warmerda - * Added support for reading bounds, and fixed up problems in setting the - * file wide bounds. - * - * Revision 1.2 1995/08/04 03:16:57 warmerda - * Added header. - * - */ + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later + ******************************************************************************/ #include "shapefil.h" -#include -#include #include +#include +#include +#include +#include +#include +#include #include #include -#include -#include - -SHP_CVSID("$Id: shpopen.c,v 1.78 2019-02-28 15:55:23 erouault Exp $") - -typedef unsigned char uchar; - -#if UINT_MAX == 65535 -typedef unsigned long int32; -#else -typedef unsigned int int32; -#endif #ifndef FALSE -# define FALSE 0 -# define TRUE 1 +#define FALSE 0 +#define TRUE 1 #endif -#define ByteCopy( a, b, c ) memcpy( b, a, c ) +#define ByteCopy(a, b, c) memcpy(b, a, c) #ifndef MAX -# define MIN(a,b) ((ab) ? a : b) +#define MIN(a, b) ((a < b) ? a : b) +#define MAX(a, b) ((a > b) ? a : b) #endif #ifndef USE_CPL #if defined(_MSC_VER) -# if _MSC_VER < 1900 -# define snprintf _snprintf -# endif +#if _MSC_VER < 1900 +#define snprintf _snprintf +#endif #elif defined(WIN32) || defined(_WIN32) -# ifndef snprintf -# define snprintf _snprintf -# endif +#ifndef snprintf +#define snprintf _snprintf +#endif #endif #endif #ifndef CPL_UNUSED #if defined(__GNUC__) && __GNUC__ >= 4 -# define CPL_UNUSED __attribute((__unused__)) +#define CPL_UNUSED __attribute((__unused__)) #else -# define CPL_UNUSED +#define CPL_UNUSED +#endif #endif -#endif +#ifndef bBigEndian #if defined(CPL_LSB) -#define bBigEndian FALSE +#define bBigEndian false #elif defined(CPL_MSB) -#define bBigEndian TRUE +#define bBigEndian true #else -static int bBigEndian; +#ifndef static_var_bBigEndian_defined +#define static_var_bBigEndian_defined +static bool bBigEndian = false; +#endif +#endif #endif #ifdef __cplusplus -#define STATIC_CAST(type,x) static_cast(x) +#define STATIC_CAST(type, x) static_cast(x) #define SHPLIB_NULLPTR nullptr #else -#define STATIC_CAST(type,x) ((type)(x)) +#define STATIC_CAST(type, x) ((type)(x)) #define SHPLIB_NULLPTR NULL #endif @@ -377,210 +81,200 @@ static int bBigEndian; /* Swap a 2, 4 or 8 byte word. */ /************************************************************************/ -static void SwapWord( int length, void * wordP ) - +#ifndef SwapWord_defined +#define SwapWord_defined +static void SwapWord(int length, void *wordP) { - int i; - uchar temp; - - for( i=0; i < length/2; i++ ) + for (int i = 0; i < length / 2; i++) { - temp = STATIC_CAST(uchar*, wordP)[i]; - STATIC_CAST(uchar*, wordP)[i] = STATIC_CAST(uchar*, wordP)[length-i-1]; - STATIC_CAST(uchar*, wordP)[length-i-1] = temp; + const unsigned char temp = STATIC_CAST(unsigned char *, wordP)[i]; + STATIC_CAST(unsigned char *, wordP) + [i] = STATIC_CAST(unsigned char *, wordP)[length - i - 1]; + STATIC_CAST(unsigned char *, wordP)[length - i - 1] = temp; } } - -/************************************************************************/ -/* SfRealloc() */ -/* */ -/* A realloc cover function that will access a NULL pointer as */ -/* a valid input. */ -/************************************************************************/ - -static void * SfRealloc( void * pMem, int nNewSize ) - -{ - if( pMem == SHPLIB_NULLPTR ) - return malloc(nNewSize); - else - return realloc(pMem,nNewSize); -} +#endif /************************************************************************/ /* SHPWriteHeader() */ /* */ -/* Write out a header for the .shp and .shx files as well as the */ -/* contents of the index (.shx) file. */ +/* Write out a header for the .shp and .shx files as well as the */ +/* contents of the index (.shx) file. */ /************************************************************************/ -void SHPAPI_CALL SHPWriteHeader( SHPHandle psSHP ) - +void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP) { - uchar abyHeader[100] = { 0 }; - int i; - int32 i32; - double dValue; - int32 *panSHX; - if (psSHP->fpSHX == SHPLIB_NULLPTR) { - psSHP->sHooks.Error( "SHPWriteHeader failed : SHX file is closed"); + psSHP->sHooks.Error("SHPWriteHeader failed : SHX file is closed"); return; } -/* -------------------------------------------------------------------- */ -/* Prepare header block for .shp file. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* Prepare header block for .shp file. */ + /* -------------------------------------------------------------------- */ - abyHeader[2] = 0x27; /* magic cookie */ + unsigned char abyHeader[100] = {0}; + abyHeader[2] = 0x27; /* magic cookie */ abyHeader[3] = 0x0a; - i32 = psSHP->nFileSize/2; /* file size */ - ByteCopy( &i32, abyHeader+24, 4 ); - if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); + uint32_t i32 = psSHP->nFileSize / 2; /* file size */ + ByteCopy(&i32, abyHeader + 24, 4); + if (!bBigEndian) + SwapWord(4, abyHeader + 24); - i32 = 1000; /* version */ - ByteCopy( &i32, abyHeader+28, 4 ); - if( bBigEndian ) SwapWord( 4, abyHeader+28 ); + i32 = 1000; /* version */ + ByteCopy(&i32, abyHeader + 28, 4); + if (bBigEndian) + SwapWord(4, abyHeader + 28); - i32 = psSHP->nShapeType; /* shape type */ - ByteCopy( &i32, abyHeader+32, 4 ); - if( bBigEndian ) SwapWord( 4, abyHeader+32 ); + i32 = psSHP->nShapeType; /* shape type */ + ByteCopy(&i32, abyHeader + 32, 4); + if (bBigEndian) + SwapWord(4, abyHeader + 32); - dValue = psSHP->adBoundsMin[0]; /* set bounds */ - ByteCopy( &dValue, abyHeader+36, 8 ); - if( bBigEndian ) SwapWord( 8, abyHeader+36 ); + double dValue = psSHP->adBoundsMin[0]; /* set bounds */ + ByteCopy(&dValue, abyHeader + 36, 8); + if (bBigEndian) + SwapWord(8, abyHeader + 36); dValue = psSHP->adBoundsMin[1]; - ByteCopy( &dValue, abyHeader+44, 8 ); - if( bBigEndian ) SwapWord( 8, abyHeader+44 ); + ByteCopy(&dValue, abyHeader + 44, 8); + if (bBigEndian) + SwapWord(8, abyHeader + 44); dValue = psSHP->adBoundsMax[0]; - ByteCopy( &dValue, abyHeader+52, 8 ); - if( bBigEndian ) SwapWord( 8, abyHeader+52 ); + ByteCopy(&dValue, abyHeader + 52, 8); + if (bBigEndian) + SwapWord(8, abyHeader + 52); dValue = psSHP->adBoundsMax[1]; - ByteCopy( &dValue, abyHeader+60, 8 ); - if( bBigEndian ) SwapWord( 8, abyHeader+60 ); + ByteCopy(&dValue, abyHeader + 60, 8); + if (bBigEndian) + SwapWord(8, abyHeader + 60); - dValue = psSHP->adBoundsMin[2]; /* z */ - ByteCopy( &dValue, abyHeader+68, 8 ); - if( bBigEndian ) SwapWord( 8, abyHeader+68 ); + dValue = psSHP->adBoundsMin[2]; /* z */ + ByteCopy(&dValue, abyHeader + 68, 8); + if (bBigEndian) + SwapWord(8, abyHeader + 68); dValue = psSHP->adBoundsMax[2]; - ByteCopy( &dValue, abyHeader+76, 8 ); - if( bBigEndian ) SwapWord( 8, abyHeader+76 ); + ByteCopy(&dValue, abyHeader + 76, 8); + if (bBigEndian) + SwapWord(8, abyHeader + 76); - dValue = psSHP->adBoundsMin[3]; /* m */ - ByteCopy( &dValue, abyHeader+84, 8 ); - if( bBigEndian ) SwapWord( 8, abyHeader+84 ); + dValue = psSHP->adBoundsMin[3]; /* m */ + ByteCopy(&dValue, abyHeader + 84, 8); + if (bBigEndian) + SwapWord(8, abyHeader + 84); dValue = psSHP->adBoundsMax[3]; - ByteCopy( &dValue, abyHeader+92, 8 ); - if( bBigEndian ) SwapWord( 8, abyHeader+92 ); + ByteCopy(&dValue, abyHeader + 92, 8); + if (bBigEndian) + SwapWord(8, abyHeader + 92); -/* -------------------------------------------------------------------- */ -/* Write .shp file header. */ -/* -------------------------------------------------------------------- */ - if( psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 0 ) != 0 - || psSHP->sHooks.FWrite( abyHeader, 100, 1, psSHP->fpSHP ) != 1 ) + /* -------------------------------------------------------------------- */ + /* Write .shp file header. */ + /* -------------------------------------------------------------------- */ + if (psSHP->sHooks.FSeek(psSHP->fpSHP, 0, 0) != 0 || + psSHP->sHooks.FWrite(abyHeader, 100, 1, psSHP->fpSHP) != 1) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Failure writing .shp header: %s", strerror(errno) ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Failure writing .shp header: %s", strerror(errno)); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); return; } -/* -------------------------------------------------------------------- */ -/* Prepare, and write .shx file header. */ -/* -------------------------------------------------------------------- */ - i32 = (psSHP->nRecords * 2 * sizeof(int32) + 100)/2; /* file size */ - ByteCopy( &i32, abyHeader+24, 4 ); - if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); + /* -------------------------------------------------------------------- */ + /* Prepare, and write .shx file header. */ + /* -------------------------------------------------------------------- */ + i32 = (psSHP->nRecords * 2 * sizeof(uint32_t) + 100) / 2; /* file size */ + ByteCopy(&i32, abyHeader + 24, 4); + if (!bBigEndian) + SwapWord(4, abyHeader + 24); - if( psSHP->sHooks.FSeek( psSHP->fpSHX, 0, 0 ) != 0 - || psSHP->sHooks.FWrite( abyHeader, 100, 1, psSHP->fpSHX ) != 1 ) + if (psSHP->sHooks.FSeek(psSHP->fpSHX, 0, 0) != 0 || + psSHP->sHooks.FWrite(abyHeader, 100, 1, psSHP->fpSHX) != 1) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Failure writing .shx header: %s", strerror(errno) ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Failure writing .shx header: %s", strerror(errno)); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); return; } -/* -------------------------------------------------------------------- */ -/* Write out the .shx contents. */ -/* -------------------------------------------------------------------- */ - panSHX = STATIC_CAST(int32 *, malloc(sizeof(int32) * 2 * psSHP->nRecords)); - if( panSHX == SHPLIB_NULLPTR ) + /* -------------------------------------------------------------------- */ + /* Write out the .shx contents. */ + /* -------------------------------------------------------------------- */ + uint32_t *panSHX = + STATIC_CAST(uint32_t *, malloc(sizeof(uint32_t) * 2 * psSHP->nRecords)); + if (panSHX == SHPLIB_NULLPTR) { - psSHP->sHooks.Error( "Failure allocatin panSHX" ); + psSHP->sHooks.Error("Failure allocatin panSHX"); return; } - for( i = 0; i < psSHP->nRecords; i++ ) + for (int i = 0; i < psSHP->nRecords; i++) { - panSHX[i*2 ] = psSHP->panRecOffset[i]/2; - panSHX[i*2+1] = psSHP->panRecSize[i]/2; - if( !bBigEndian ) SwapWord( 4, panSHX+i*2 ); - if( !bBigEndian ) SwapWord( 4, panSHX+i*2+1 ); + panSHX[i * 2] = psSHP->panRecOffset[i] / 2; + panSHX[i * 2 + 1] = psSHP->panRecSize[i] / 2; + if (!bBigEndian) + SwapWord(4, panSHX + i * 2); + if (!bBigEndian) + SwapWord(4, panSHX + i * 2 + 1); } - if( STATIC_CAST(int, psSHP->sHooks.FWrite( panSHX, sizeof(int32)*2, psSHP->nRecords, psSHP->fpSHX )) - != psSHP->nRecords ) + if (STATIC_CAST(int, psSHP->sHooks.FWrite(panSHX, sizeof(uint32_t) * 2, + psSHP->nRecords, psSHP->fpSHX)) != + psSHP->nRecords) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Failure writing .shx contents: %s", strerror(errno) ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Failure writing .shx contents: %s", strerror(errno)); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); } - free( panSHX ); + free(panSHX); -/* -------------------------------------------------------------------- */ -/* Flush to disk. */ -/* -------------------------------------------------------------------- */ - psSHP->sHooks.FFlush( psSHP->fpSHP ); - psSHP->sHooks.FFlush( psSHP->fpSHX ); + /* -------------------------------------------------------------------- */ + /* Flush to disk. */ + /* -------------------------------------------------------------------- */ + psSHP->sHooks.FFlush(psSHP->fpSHP); + psSHP->sHooks.FFlush(psSHP->fpSHX); } /************************************************************************/ /* SHPOpen() */ /************************************************************************/ -SHPHandle SHPAPI_CALL -SHPOpen( const char * pszLayer, const char * pszAccess ) - +SHPHandle SHPAPI_CALL SHPOpen(const char *pszLayer, const char *pszAccess) { SAHooks sHooks; - SASetupDefaultHooks( &sHooks ); + SASetupDefaultHooks(&sHooks); - return SHPOpenLL( pszLayer, pszAccess, &sHooks ); + return SHPOpenLL(pszLayer, pszAccess, &sHooks); } /************************************************************************/ /* SHPGetLenWithoutExtension() */ /************************************************************************/ -static int SHPGetLenWithoutExtension(const char* pszBasename) +static int SHPGetLenWithoutExtension(const char *pszBasename) { - int i; - int nLen = STATIC_CAST(int, strlen(pszBasename)); - for( i = nLen-1; - i > 0 && pszBasename[i] != '/' && pszBasename[i] != '\\'; - i-- ) + const int nLen = STATIC_CAST(int, strlen(pszBasename)); + for (int i = nLen - 1; + i > 0 && pszBasename[i] != '/' && pszBasename[i] != '\\'; i--) { - if( pszBasename[i] == '.' ) + if (pszBasename[i] == '.') { return i; } @@ -595,27 +289,20 @@ static int SHPGetLenWithoutExtension(const char* pszBasename) /* files or either file name. */ /************************************************************************/ -SHPHandle SHPAPI_CALL -SHPOpenLL( const char * pszLayer, const char * pszAccess, SAHooks *psHooks ) - +SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, + const SAHooks *psHooks) { - char *pszFullname; - SHPHandle psSHP; - - uchar *pabyBuf; - int i; - double dValue; - int bLazySHXLoading = FALSE; - int nLenWithoutExtension; - -/* -------------------------------------------------------------------- */ -/* Ensure the access string is one of the legal ones. We */ -/* ensure the result string indicates binary to avoid common */ -/* problems on Windows. */ -/* -------------------------------------------------------------------- */ - if( strcmp(pszAccess,"rb+") == 0 || strcmp(pszAccess,"r+b") == 0 - || strcmp(pszAccess,"r+") == 0 ) + /* -------------------------------------------------------------------- */ + /* Ensure the access string is one of the legal ones. We */ + /* ensure the result string indicates binary to avoid common */ + /* problems on Windows. */ + /* -------------------------------------------------------------------- */ + bool bLazySHXLoading = false; + if (strcmp(pszAccess, "rb+") == 0 || strcmp(pszAccess, "r+b") == 0 || + strcmp(pszAccess, "r+") == 0) + { pszAccess = "r+b"; + } else { bLazySHXLoading = strchr(pszAccess, 'l') != SHPLIB_NULLPTR; @@ -626,138 +313,145 @@ SHPOpenLL( const char * pszLayer, const char * pszAccess, SAHooks *psHooks ) /* Establish the byte order on this machine. */ /* -------------------------------------------------------------------- */ #if !defined(bBigEndian) - i = 1; - if( *((uchar *) &i) == 1 ) - bBigEndian = FALSE; - else - bBigEndian = TRUE; + { + int i = 1; + if (*((unsigned char *)&i) == 1) + bBigEndian = false; + else + bBigEndian = true; + } #endif -/* -------------------------------------------------------------------- */ -/* Initialize the info structure. */ -/* -------------------------------------------------------------------- */ - psSHP = STATIC_CAST(SHPHandle, calloc(sizeof(SHPInfo),1)); + /* -------------------------------------------------------------------- */ + /* Initialize the info structure. */ + /* -------------------------------------------------------------------- */ + SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(sizeof(SHPInfo), 1)); psSHP->bUpdated = FALSE; - memcpy( &(psSHP->sHooks), psHooks, sizeof(SAHooks) ); - -/* -------------------------------------------------------------------- */ -/* Open the .shp and .shx files. Note that files pulled from */ -/* a PC to Unix with upper case filenames won't work! */ -/* -------------------------------------------------------------------- */ - nLenWithoutExtension = SHPGetLenWithoutExtension(pszLayer); - pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); + memcpy(&(psSHP->sHooks), psHooks, sizeof(SAHooks)); + + /* -------------------------------------------------------------------- */ + /* Open the .shp and .shx files. Note that files pulled from */ + /* a PC to Unix with upper case filenames won't work! */ + /* -------------------------------------------------------------------- */ + const int nLenWithoutExtension = SHPGetLenWithoutExtension(pszLayer); + char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); memcpy(pszFullname, pszLayer, nLenWithoutExtension); memcpy(pszFullname + nLenWithoutExtension, ".shp", 5); - psSHP->fpSHP = psSHP->sHooks.FOpen(pszFullname, pszAccess ); - if( psSHP->fpSHP == SHPLIB_NULLPTR ) + psSHP->fpSHP = + psSHP->sHooks.FOpen(pszFullname, pszAccess, psSHP->sHooks.pvUserData); + if (psSHP->fpSHP == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".SHP", 5); - psSHP->fpSHP = psSHP->sHooks.FOpen(pszFullname, pszAccess ); + psSHP->fpSHP = psSHP->sHooks.FOpen(pszFullname, pszAccess, + psSHP->sHooks.pvUserData); } - if( psSHP->fpSHP == SHPLIB_NULLPTR ) + if (psSHP->fpSHP == SHPLIB_NULLPTR) { - size_t nMessageLen = strlen(pszFullname)*2+256; + const size_t nMessageLen = strlen(pszFullname) * 2 + 256; char *pszMessage = STATIC_CAST(char *, malloc(nMessageLen)); pszFullname[nLenWithoutExtension] = 0; - snprintf( pszMessage, nMessageLen, "Unable to open %s.shp or %s.SHP.", - pszFullname, pszFullname ); - psHooks->Error( pszMessage ); - free( pszMessage ); + snprintf(pszMessage, nMessageLen, + "Unable to open %s.shp or %s.SHP in %s mode.", pszFullname, + pszFullname, pszAccess); + psHooks->Error(pszMessage); + free(pszMessage); - free( psSHP ); - free( pszFullname ); + free(psSHP); + free(pszFullname); return SHPLIB_NULLPTR; } memcpy(pszFullname + nLenWithoutExtension, ".shx", 5); - psSHP->fpSHX = psSHP->sHooks.FOpen(pszFullname, pszAccess ); - if( psSHP->fpSHX == SHPLIB_NULLPTR ) + psSHP->fpSHX = + psSHP->sHooks.FOpen(pszFullname, pszAccess, psSHP->sHooks.pvUserData); + if (psSHP->fpSHX == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".SHX", 5); - psSHP->fpSHX = psSHP->sHooks.FOpen(pszFullname, pszAccess ); + psSHP->fpSHX = psSHP->sHooks.FOpen(pszFullname, pszAccess, + psSHP->sHooks.pvUserData); } - if( psSHP->fpSHX == SHPLIB_NULLPTR ) + if (psSHP->fpSHX == SHPLIB_NULLPTR) { - size_t nMessageLen = strlen(pszFullname)*2+256; + const size_t nMessageLen = strlen(pszFullname) * 2 + 256; char *pszMessage = STATIC_CAST(char *, malloc(nMessageLen)); pszFullname[nLenWithoutExtension] = 0; - snprintf( pszMessage, nMessageLen, "Unable to open %s.shx or %s.SHX. " - "Set SHAPE_RESTORE_SHX config option to YES to restore or " - "create it.", pszFullname, pszFullname ); - psHooks->Error( pszMessage ); - free( pszMessage ); - - psSHP->sHooks.FClose( psSHP->fpSHP ); - free( psSHP ); - free( pszFullname ); - return SHPLIB_NULLPTR ; + snprintf(pszMessage, nMessageLen, + "Unable to open %s.shx or %s.SHX. " + "Set SHAPE_RESTORE_SHX config option to YES to restore or " + "create it.", + pszFullname, pszFullname); + psHooks->Error(pszMessage); + free(pszMessage); + + psSHP->sHooks.FClose(psSHP->fpSHP); + free(psSHP); + free(pszFullname); + return SHPLIB_NULLPTR; } - free( pszFullname ); + free(pszFullname); -/* -------------------------------------------------------------------- */ -/* Read the file size from the SHP file. */ -/* -------------------------------------------------------------------- */ - pabyBuf = STATIC_CAST(uchar *, malloc(100)); - if( psSHP->sHooks.FRead( pabyBuf, 100, 1, psSHP->fpSHP ) != 1 ) + /* -------------------------------------------------------------------- */ + /* Read the file size from the SHP file. */ + /* -------------------------------------------------------------------- */ + unsigned char *pabyBuf = STATIC_CAST(unsigned char *, malloc(100)); + if (psSHP->sHooks.FRead(pabyBuf, 100, 1, psSHP->fpSHP) != 1) { - psSHP->sHooks.Error( ".shp file is unreadable, or corrupt." ); - psSHP->sHooks.FClose( psSHP->fpSHP ); - psSHP->sHooks.FClose( psSHP->fpSHX ); - free( pabyBuf ); - free( psSHP ); + psSHP->sHooks.Error(".shp file is unreadable, or corrupt."); + psSHP->sHooks.FClose(psSHP->fpSHP); + psSHP->sHooks.FClose(psSHP->fpSHX); + free(pabyBuf); + free(psSHP); - return SHPLIB_NULLPTR ; + return SHPLIB_NULLPTR; } - psSHP->nFileSize = (STATIC_CAST(unsigned int, pabyBuf[24])<<24)|(pabyBuf[25]<<16)| - (pabyBuf[26]<<8)|pabyBuf[27]; - if( psSHP->nFileSize < UINT_MAX / 2 ) + psSHP->nFileSize = (STATIC_CAST(unsigned int, pabyBuf[24]) << 24) | + (pabyBuf[25] << 16) | (pabyBuf[26] << 8) | pabyBuf[27]; + if (psSHP->nFileSize < UINT_MAX / 2) psSHP->nFileSize *= 2; else psSHP->nFileSize = (UINT_MAX / 2) * 2; -/* -------------------------------------------------------------------- */ -/* Read SHX file Header info */ -/* -------------------------------------------------------------------- */ - if( psSHP->sHooks.FRead( pabyBuf, 100, 1, psSHP->fpSHX ) != 1 - || pabyBuf[0] != 0 - || pabyBuf[1] != 0 - || pabyBuf[2] != 0x27 - || (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d) ) - { - psSHP->sHooks.Error( ".shx file is unreadable, or corrupt." ); - psSHP->sHooks.FClose( psSHP->fpSHP ); - psSHP->sHooks.FClose( psSHP->fpSHX ); - free( pabyBuf ); - free( psSHP ); + /* -------------------------------------------------------------------- */ + /* Read SHX file Header info */ + /* -------------------------------------------------------------------- */ + if (psSHP->sHooks.FRead(pabyBuf, 100, 1, psSHP->fpSHX) != 1 || + pabyBuf[0] != 0 || pabyBuf[1] != 0 || pabyBuf[2] != 0x27 || + (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d)) + { + psSHP->sHooks.Error(".shx file is unreadable, or corrupt."); + psSHP->sHooks.FClose(psSHP->fpSHP); + psSHP->sHooks.FClose(psSHP->fpSHX); + free(pabyBuf); + free(psSHP); return SHPLIB_NULLPTR; } - psSHP->nRecords = pabyBuf[27]|(pabyBuf[26]<<8)|(pabyBuf[25]<<16)| - ((pabyBuf[24] & 0x7F)<<24); + psSHP->nRecords = pabyBuf[27] | (pabyBuf[26] << 8) | (pabyBuf[25] << 16) | + ((pabyBuf[24] & 0x7F) << 24); psSHP->nRecords = (psSHP->nRecords - 50) / 4; psSHP->nShapeType = pabyBuf[32]; - if( psSHP->nRecords < 0 || psSHP->nRecords > 256000000 ) + if (psSHP->nRecords < 0 || psSHP->nRecords > 256000000) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Record count in .shp header is %d, which seems\n" + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Record count in .shx header is %d, which seems\n" "unreasonable. Assuming header is corrupt.", - psSHP->nRecords ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); - psSHP->sHooks.FClose( psSHP->fpSHP ); - psSHP->sHooks.FClose( psSHP->fpSHX ); - free( psSHP ); + psSHP->nRecords); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); + psSHP->sHooks.FClose(psSHP->fpSHP); + psSHP->sHooks.FClose(psSHP->fpSHX); + free(psSHP); free(pabyBuf); return SHPLIB_NULLPTR; @@ -765,70 +459,82 @@ SHPOpenLL( const char * pszLayer, const char * pszAccess, SAHooks *psHooks ) /* If a lot of records are advertized, check that the file is big enough */ /* to hold them */ - if( psSHP->nRecords >= 1024 * 1024 ) + if (psSHP->nRecords >= 1024 * 1024) { - SAOffset nFileSize; - psSHP->sHooks.FSeek( psSHP->fpSHX, 0, 2 ); - nFileSize = psSHP->sHooks.FTell( psSHP->fpSHX ); - if( nFileSize > 100 && - nFileSize/2 < STATIC_CAST(SAOffset, psSHP->nRecords * 4 + 50) ) + psSHP->sHooks.FSeek(psSHP->fpSHX, 0, 2); + const SAOffset nFileSize = psSHP->sHooks.FTell(psSHP->fpSHX); + if (nFileSize > 100 && + nFileSize / 2 < STATIC_CAST(SAOffset, psSHP->nRecords * 4 + 50)) { psSHP->nRecords = STATIC_CAST(int, (nFileSize - 100) / 8); } - psSHP->sHooks.FSeek( psSHP->fpSHX, 100, 0 ); + psSHP->sHooks.FSeek(psSHP->fpSHX, 100, 0); } -/* -------------------------------------------------------------------- */ -/* Read the bounds. */ -/* -------------------------------------------------------------------- */ - if( bBigEndian ) SwapWord( 8, pabyBuf+36 ); - memcpy( &dValue, pabyBuf+36, 8 ); + /* -------------------------------------------------------------------- */ + /* Read the bounds. */ + /* -------------------------------------------------------------------- */ + double dValue; + + if (bBigEndian) + SwapWord(8, pabyBuf + 36); + memcpy(&dValue, pabyBuf + 36, 8); psSHP->adBoundsMin[0] = dValue; - if( bBigEndian ) SwapWord( 8, pabyBuf+44 ); - memcpy( &dValue, pabyBuf+44, 8 ); + if (bBigEndian) + SwapWord(8, pabyBuf + 44); + memcpy(&dValue, pabyBuf + 44, 8); psSHP->adBoundsMin[1] = dValue; - if( bBigEndian ) SwapWord( 8, pabyBuf+52 ); - memcpy( &dValue, pabyBuf+52, 8 ); + if (bBigEndian) + SwapWord(8, pabyBuf + 52); + memcpy(&dValue, pabyBuf + 52, 8); psSHP->adBoundsMax[0] = dValue; - if( bBigEndian ) SwapWord( 8, pabyBuf+60 ); - memcpy( &dValue, pabyBuf+60, 8 ); + if (bBigEndian) + SwapWord(8, pabyBuf + 60); + memcpy(&dValue, pabyBuf + 60, 8); psSHP->adBoundsMax[1] = dValue; - if( bBigEndian ) SwapWord( 8, pabyBuf+68 ); /* z */ - memcpy( &dValue, pabyBuf+68, 8 ); + if (bBigEndian) + SwapWord(8, pabyBuf + 68); /* z */ + memcpy(&dValue, pabyBuf + 68, 8); psSHP->adBoundsMin[2] = dValue; - if( bBigEndian ) SwapWord( 8, pabyBuf+76 ); - memcpy( &dValue, pabyBuf+76, 8 ); + if (bBigEndian) + SwapWord(8, pabyBuf + 76); + memcpy(&dValue, pabyBuf + 76, 8); psSHP->adBoundsMax[2] = dValue; - if( bBigEndian ) SwapWord( 8, pabyBuf+84 ); /* z */ - memcpy( &dValue, pabyBuf+84, 8 ); + if (bBigEndian) + SwapWord(8, pabyBuf + 84); /* z */ + memcpy(&dValue, pabyBuf + 84, 8); psSHP->adBoundsMin[3] = dValue; - if( bBigEndian ) SwapWord( 8, pabyBuf+92 ); - memcpy( &dValue, pabyBuf+92, 8 ); + if (bBigEndian) + SwapWord(8, pabyBuf + 92); + memcpy(&dValue, pabyBuf + 92, 8); psSHP->adBoundsMax[3] = dValue; - free( pabyBuf ); + free(pabyBuf); -/* -------------------------------------------------------------------- */ -/* Read the .shx file to get the offsets to each record in */ -/* the .shp file. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* Read the .shx file to get the offsets to each record in */ + /* the .shp file. */ + /* -------------------------------------------------------------------- */ psSHP->nMaxRecords = psSHP->nRecords; - psSHP->panRecOffset = STATIC_CAST(unsigned int *, - malloc(sizeof(unsigned int) * MAX(1,psSHP->nMaxRecords) )); - psSHP->panRecSize = STATIC_CAST(unsigned int *, - malloc(sizeof(unsigned int) * MAX(1,psSHP->nMaxRecords) )); - if( bLazySHXLoading ) + psSHP->panRecOffset = + STATIC_CAST(unsigned int *, + malloc(sizeof(unsigned int) * MAX(1, psSHP->nMaxRecords))); + psSHP->panRecSize = + STATIC_CAST(unsigned int *, + malloc(sizeof(unsigned int) * MAX(1, psSHP->nMaxRecords))); + if (bLazySHXLoading) pabyBuf = SHPLIB_NULLPTR; else - pabyBuf = STATIC_CAST(uchar *, malloc(8 * MAX(1,psSHP->nRecords) )); + pabyBuf = + STATIC_CAST(unsigned char *, malloc(8 * MAX(1, psSHP->nRecords))); if (psSHP->panRecOffset == SHPLIB_NULLPTR || psSHP->panRecSize == SHPLIB_NULLPTR || @@ -836,47 +542,53 @@ SHPOpenLL( const char * pszLayer, const char * pszAccess, SAHooks *psHooks ) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Not enough memory to allocate requested memory (nRecords=%d).\n" - "Probably broken SHP file", - psSHP->nRecords ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); - psSHP->sHooks.FClose( psSHP->fpSHP ); - psSHP->sHooks.FClose( psSHP->fpSHX ); - if (psSHP->panRecOffset) free( psSHP->panRecOffset ); - if (psSHP->panRecSize) free( psSHP->panRecSize ); - if (pabyBuf) free( pabyBuf ); - free( psSHP ); + snprintf( + szErrorMsg, sizeof(szErrorMsg), + "Not enough memory to allocate requested memory (nRecords=%d).\n" + "Probably broken SHP file", + psSHP->nRecords); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); + psSHP->sHooks.FClose(psSHP->fpSHP); + psSHP->sHooks.FClose(psSHP->fpSHX); + if (psSHP->panRecOffset) + free(psSHP->panRecOffset); + if (psSHP->panRecSize) + free(psSHP->panRecSize); + if (pabyBuf) + free(pabyBuf); + free(psSHP); return SHPLIB_NULLPTR; } - if( bLazySHXLoading ) + if (bLazySHXLoading) { - memset(psSHP->panRecOffset, 0, sizeof(unsigned int) * MAX(1,psSHP->nMaxRecords) ); - memset(psSHP->panRecSize, 0, sizeof(unsigned int) * MAX(1,psSHP->nMaxRecords) ); - free( pabyBuf ); // sometimes make cppcheck happy, but - return( psSHP ); + memset(psSHP->panRecOffset, 0, + sizeof(unsigned int) * MAX(1, psSHP->nMaxRecords)); + memset(psSHP->panRecSize, 0, + sizeof(unsigned int) * MAX(1, psSHP->nMaxRecords)); + free(pabyBuf); // sometimes make cppcheck happy, but + return (psSHP); } - if( STATIC_CAST(int, psSHP->sHooks.FRead( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX )) - != psSHP->nRecords ) + if (STATIC_CAST(int, psSHP->sHooks.FRead(pabyBuf, 8, psSHP->nRecords, + psSHP->fpSHX)) != psSHP->nRecords) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), + snprintf(szErrorMsg, sizeof(szErrorMsg), "Failed to read all values for %d records in .shx file: %s.", - psSHP->nRecords, strerror(errno) ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + psSHP->nRecords, strerror(errno)); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); /* SHX is short or unreadable for some reason. */ - psSHP->sHooks.FClose( psSHP->fpSHP ); - psSHP->sHooks.FClose( psSHP->fpSHX ); - free( psSHP->panRecOffset ); - free( psSHP->panRecSize ); - free( pabyBuf ); - free( psSHP ); + psSHP->sHooks.FClose(psSHP->fpSHP); + psSHP->sHooks.FClose(psSHP->fpSHX); + free(psSHP->panRecOffset); + free(psSHP->panRecSize); + free(pabyBuf); + free(psSHP); return SHPLIB_NULLPTR; } @@ -884,50 +596,50 @@ SHPOpenLL( const char * pszLayer, const char * pszAccess, SAHooks *psHooks ) /* In read-only mode, we can close the SHX now */ if (strcmp(pszAccess, "rb") == 0) { - psSHP->sHooks.FClose( psSHP->fpSHX ); + psSHP->sHooks.FClose(psSHP->fpSHX); psSHP->fpSHX = SHPLIB_NULLPTR; } - for( i = 0; i < psSHP->nRecords; i++ ) + for (int i = 0; i < psSHP->nRecords; i++) { - unsigned int nOffset, nLength; - - memcpy( &nOffset, pabyBuf + i * 8, 4 ); - if( !bBigEndian ) SwapWord( 4, &nOffset ); + unsigned int nOffset; + memcpy(&nOffset, pabyBuf + i * 8, 4); + if (!bBigEndian) + SwapWord(4, &nOffset); - memcpy( &nLength, pabyBuf + i * 8 + 4, 4 ); - if( !bBigEndian ) SwapWord( 4, &nLength ); + unsigned int nLength; + memcpy(&nLength, pabyBuf + i * 8 + 4, 4); + if (!bBigEndian) + SwapWord(4, &nLength); - if( nOffset > STATIC_CAST(unsigned int, INT_MAX) ) + if (nOffset > STATIC_CAST(unsigned int, INT_MAX)) { char str[128]; - snprintf( str, sizeof(str), - "Invalid offset for entity %d", i); - str[sizeof(str)-1] = '\0'; + snprintf(str, sizeof(str), "Invalid offset for entity %d", i); + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); SHPClose(psSHP); - free( pabyBuf ); + free(pabyBuf); return SHPLIB_NULLPTR; } - if( nLength > STATIC_CAST(unsigned int, INT_MAX / 2 - 4) ) + if (nLength > STATIC_CAST(unsigned int, INT_MAX / 2 - 4)) { char str[128]; - snprintf( str, sizeof(str), - "Invalid length for entity %d", i); - str[sizeof(str)-1] = '\0'; + snprintf(str, sizeof(str), "Invalid length for entity %d", i); + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); SHPClose(psSHP); - free( pabyBuf ); + free(pabyBuf); return SHPLIB_NULLPTR; } - psSHP->panRecOffset[i] = nOffset*2; - psSHP->panRecSize[i] = nLength*2; + psSHP->panRecOffset[i] = nOffset * 2; + psSHP->panRecSize[i] = nLength * 2; } - free( pabyBuf ); + free(pabyBuf); - return( psSHP ); + return (psSHP); } /************************************************************************/ @@ -938,17 +650,16 @@ SHPOpenLL( const char * pszLayer, const char * pszAccess, SAHooks *psHooks ) /* in case when bRestoreSHX equals true. */ /************************************************************************/ -SHPHandle SHPAPI_CALL -SHPOpenLLEx( const char * pszLayer, const char * pszAccess, SAHooks *psHooks, - int bRestoreSHX ) - +SHPHandle SHPAPI_CALL SHPOpenLLEx(const char *pszLayer, const char *pszAccess, + const SAHooks *psHooks, int bRestoreSHX) { - if ( !bRestoreSHX ) return SHPOpenLL ( pszLayer, pszAccess, psHooks ); + if (!bRestoreSHX) + return SHPOpenLL(pszLayer, pszAccess, psHooks); else { - if ( SHPRestoreSHX ( pszLayer, pszAccess, psHooks ) ) + if (SHPRestoreSHX(pszLayer, pszAccess, psHooks)) { - return SHPOpenLL ( pszLayer, pszAccess, psHooks ); + return SHPOpenLL(pszLayer, pszAccess, psHooks); } } @@ -962,37 +673,19 @@ SHPOpenLLEx( const char * pszLayer, const char * pszAccess, SAHooks *psHooks, /* */ /************************************************************************/ -int SHPAPI_CALL -SHPRestoreSHX ( const char * pszLayer, const char * pszAccess, SAHooks *psHooks ) - +int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, + const SAHooks *psHooks) { - char *pszFullname; - SAFile fpSHP, fpSHX; - - - uchar *pabyBuf; - int nLenWithoutExtension; - unsigned int nSHPFilesize; - - unsigned int nCurrentRecordOffset = 0; - unsigned int nCurrentSHPOffset = 100; - size_t nRealSHXContentSize = 100; - - const char pszSHXAccess[] = "w+b"; - char *pabySHXHeader; - char abyReadedRecord[8]; - unsigned int niRecord = 0; - unsigned int nRecordLength = 0; - unsigned int nRecordOffset = 50; - -/* -------------------------------------------------------------------- */ -/* Ensure the access string is one of the legal ones. We */ -/* ensure the result string indicates binary to avoid common */ -/* problems on Windows. */ -/* -------------------------------------------------------------------- */ - if( strcmp(pszAccess,"rb+") == 0 || strcmp(pszAccess,"r+b") == 0 - || strcmp(pszAccess,"r+") == 0 ) + /* -------------------------------------------------------------------- */ + /* Ensure the access string is one of the legal ones. We */ + /* ensure the result string indicates binary to avoid common */ + /* problems on Windows. */ + /* -------------------------------------------------------------------- */ + if (strcmp(pszAccess, "rb+") == 0 || strcmp(pszAccess, "r+b") == 0 || + strcmp(pszAccess, "r+") == 0) + { pszAccess = "r+b"; + } else { pszAccess = "rb"; @@ -1004,185 +697,253 @@ SHPRestoreSHX ( const char * pszLayer, const char * pszAccess, SAHooks *psHooks #if !defined(bBigEndian) { int i = 1; - if( *((uchar *) &i) == 1 ) - bBigEndian = FALSE; + if (*((unsigned char *)&i) == 1) + bBigEndian = false; else - bBigEndian = TRUE; + bBigEndian = true; } #endif -/* -------------------------------------------------------------------- */ -/* Open the .shp file. Note that files pulled from */ -/* a PC to Unix with upper case filenames won't work! */ -/* -------------------------------------------------------------------- */ - nLenWithoutExtension = SHPGetLenWithoutExtension(pszLayer); - pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); + /* -------------------------------------------------------------------- */ + /* Open the .shp file. Note that files pulled from */ + /* a PC to Unix with upper case filenames won't work! */ + /* -------------------------------------------------------------------- */ + const int nLenWithoutExtension = SHPGetLenWithoutExtension(pszLayer); + char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); memcpy(pszFullname, pszLayer, nLenWithoutExtension); memcpy(pszFullname + nLenWithoutExtension, ".shp", 5); - fpSHP = psHooks->FOpen(pszFullname, pszAccess ); - if( fpSHP == SHPLIB_NULLPTR ) + SAFile fpSHP = psHooks->FOpen(pszFullname, pszAccess, psHooks->pvUserData); + if (fpSHP == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".SHP", 5); - fpSHP = psHooks->FOpen(pszFullname, pszAccess ); + fpSHP = psHooks->FOpen(pszFullname, pszAccess, psHooks->pvUserData); } - if( fpSHP == SHPLIB_NULLPTR ) + if (fpSHP == SHPLIB_NULLPTR) { - size_t nMessageLen = strlen( pszFullname ) * 2 + 256; - char* pszMessage = STATIC_CAST(char *, malloc( nMessageLen )); + const size_t nMessageLen = strlen(pszFullname) * 2 + 256; + char *pszMessage = STATIC_CAST(char *, malloc(nMessageLen)); pszFullname[nLenWithoutExtension] = 0; - snprintf( pszMessage, nMessageLen, "Unable to open %s.shp or %s.SHP.", - pszFullname, pszFullname ); - psHooks->Error( pszMessage ); - free( pszMessage ); + snprintf(pszMessage, nMessageLen, "Unable to open %s.shp or %s.SHP.", + pszFullname, pszFullname); + psHooks->Error(pszMessage); + free(pszMessage); - free( pszFullname ); + free(pszFullname); - return( 0 ); + return (0); } -/* -------------------------------------------------------------------- */ -/* Read the file size from the SHP file. */ -/* -------------------------------------------------------------------- */ - pabyBuf = STATIC_CAST(uchar *, malloc(100)); - psHooks->FRead( pabyBuf, 100, 1, fpSHP ); + /* -------------------------------------------------------------------- */ + /* Read the file size from the SHP file. */ + /* -------------------------------------------------------------------- */ + unsigned char *pabyBuf = STATIC_CAST(unsigned char *, malloc(100)); + if (psHooks->FRead(pabyBuf, 100, 1, fpSHP) != 1) + { + psHooks->Error(".shp file is unreadable, or corrupt."); + psHooks->FClose(fpSHP); - nSHPFilesize = (STATIC_CAST(unsigned int, pabyBuf[24])<<24)|(pabyBuf[25]<<16)| - (pabyBuf[26]<<8)|pabyBuf[27]; - if( nSHPFilesize < UINT_MAX / 2 ) + free(pabyBuf); + free(pszFullname); + + return (0); + } + + unsigned int nSHPFilesize = (STATIC_CAST(unsigned int, pabyBuf[24]) << 24) | + (pabyBuf[25] << 16) | (pabyBuf[26] << 8) | + pabyBuf[27]; + if (nSHPFilesize < UINT_MAX / 2) nSHPFilesize *= 2; else nSHPFilesize = (UINT_MAX / 2) * 2; memcpy(pszFullname + nLenWithoutExtension, ".shx", 5); - fpSHX = psHooks->FOpen( pszFullname, pszSHXAccess ); - if( fpSHX == SHPLIB_NULLPTR ) - { - memcpy(pszFullname + nLenWithoutExtension, ".SHX", 5); - fpSHP = psHooks->FOpen(pszFullname, pszAccess ); - } - - if( fpSHX == SHPLIB_NULLPTR ) + const char pszSHXAccess[] = "w+b"; + SAFile fpSHX = + psHooks->FOpen(pszFullname, pszSHXAccess, psHooks->pvUserData); + if (fpSHX == SHPLIB_NULLPTR) { - size_t nMessageLen = strlen( pszFullname ) * 2 + 256; - char* pszMessage = STATIC_CAST(char *, malloc( nMessageLen )); + size_t nMessageLen = strlen(pszFullname) * 2 + 256; + char *pszMessage = STATIC_CAST(char *, malloc(nMessageLen)); pszFullname[nLenWithoutExtension] = 0; - snprintf( pszMessage, nMessageLen, - "Error opening file %s.shx or %s.SHX for writing", - pszFullname, pszFullname ); - psHooks->Error( pszMessage ); - free( pszMessage ); + snprintf(pszMessage, nMessageLen, + "Error opening file %s.shx for writing", pszFullname); + psHooks->Error(pszMessage); + free(pszMessage); - psHooks->FClose( fpSHX ); + psHooks->FClose(fpSHP); - free( pabyBuf ); - free( pszFullname ); + free(pabyBuf); + free(pszFullname); - return( 0 ); + return (0); } -/* -------------------------------------------------------------------- */ -/* Open SHX and create it using SHP file content. */ -/* -------------------------------------------------------------------- */ - psHooks->FSeek( fpSHP, 100, 0 ); - pabySHXHeader = STATIC_CAST(char *, malloc ( 100 )); - memcpy( pabySHXHeader, pabyBuf, 100 ); - psHooks->FWrite( pabySHXHeader, 100, 1, fpSHX ); + /* -------------------------------------------------------------------- */ + /* Open SHX and create it using SHP file content. */ + /* -------------------------------------------------------------------- */ + psHooks->FSeek(fpSHP, 100, 0); + char *pabySHXHeader = STATIC_CAST(char *, malloc(100)); + memcpy(pabySHXHeader, pabyBuf, 100); + psHooks->FWrite(pabySHXHeader, 100, 1, fpSHX); + free(pabyBuf); + + // unsigned int nCurrentRecordOffset = 0; + unsigned int nCurrentSHPOffset = 100; + unsigned int nRealSHXContentSize = 100; + int nRetCode = TRUE; + unsigned int nRecordOffset = 50; - while( nCurrentSHPOffset < nSHPFilesize ) + while (nCurrentSHPOffset < nSHPFilesize) { - if( psHooks->FRead( &niRecord, 4, 1, fpSHP ) == 1 && - psHooks->FRead( &nRecordLength, 4, 1, fpSHP ) == 1) + unsigned int niRecord = 0; + unsigned int nRecordLength = 0; + int nSHPType; + + if (psHooks->FRead(&niRecord, 4, 1, fpSHP) == 1 && + psHooks->FRead(&nRecordLength, 4, 1, fpSHP) == 1 && + psHooks->FRead(&nSHPType, 4, 1, fpSHP) == 1) { - if( !bBigEndian ) SwapWord( 4, &nRecordOffset ); - memcpy( abyReadedRecord, &nRecordOffset, 4 ); - memcpy( abyReadedRecord + 4, &nRecordLength, 4 ); + char abyReadRecord[8]; + unsigned int nRecordOffsetBE = nRecordOffset; - psHooks->FWrite( abyReadedRecord, 8, 1, fpSHX ); + if (!bBigEndian) + SwapWord(4, &nRecordOffsetBE); + memcpy(abyReadRecord, &nRecordOffsetBE, 4); + memcpy(abyReadRecord + 4, &nRecordLength, 4); + + if (!bBigEndian) + SwapWord(4, &nRecordLength); + + if (bBigEndian) + SwapWord(4, &nSHPType); + + // Sanity check on record length + if (nRecordLength < 1 || + nRecordLength > (nSHPFilesize - (nCurrentSHPOffset + 8)) / 2) + { + char szErrorMsg[200]; + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Error parsing .shp to restore .shx. " + "Invalid record length = %u at record starting at " + "offset %u", + nSHPType, nCurrentSHPOffset); + psHooks->Error(szErrorMsg); + + nRetCode = FALSE; + break; + } + + // Sanity check on record type + if (nSHPType != SHPT_NULL && nSHPType != SHPT_POINT && + nSHPType != SHPT_ARC && nSHPType != SHPT_POLYGON && + nSHPType != SHPT_MULTIPOINT && nSHPType != SHPT_POINTZ && + nSHPType != SHPT_ARCZ && nSHPType != SHPT_POLYGONZ && + nSHPType != SHPT_MULTIPOINTZ && nSHPType != SHPT_POINTM && + nSHPType != SHPT_ARCM && nSHPType != SHPT_POLYGONM && + nSHPType != SHPT_MULTIPOINTM && nSHPType != SHPT_MULTIPATCH) + { + char szErrorMsg[200]; + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Error parsing .shp to restore .shx. " + "Invalid shape type = %d at record starting at " + "offset %u", + nSHPType, nCurrentSHPOffset); + psHooks->Error(szErrorMsg); + + nRetCode = FALSE; + break; + } + + psHooks->FWrite(abyReadRecord, 8, 1, fpSHX); - if ( !bBigEndian ) SwapWord( 4, &nRecordOffset ); - if ( !bBigEndian ) SwapWord( 4, &nRecordLength ); nRecordOffset += nRecordLength + 4; - nCurrentRecordOffset += 8; + // nCurrentRecordOffset += 8; nCurrentSHPOffset += 8 + nRecordLength * 2; - psHooks->FSeek( fpSHP, nCurrentSHPOffset, 0 ); + psHooks->FSeek(fpSHP, nCurrentSHPOffset, 0); nRealSHXContentSize += 8; } else { - psHooks->Error( "Error parsing .shp to restore .shx" ); - - psHooks->FClose( fpSHX ); - psHooks->FClose( fpSHP ); - - free( pabySHXHeader ); - free( pszFullname ); + char szErrorMsg[200]; + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Error parsing .shp to restore .shx. " + "Cannot read first bytes of record starting at " + "offset %u", + nCurrentSHPOffset); + psHooks->Error(szErrorMsg); - return( 0 ); + nRetCode = FALSE; + break; } } + if (nRetCode && nCurrentSHPOffset != nSHPFilesize) + { + psHooks->Error("Error parsing .shp to restore .shx. " + "Not expected number of bytes"); + + nRetCode = FALSE; + } - nRealSHXContentSize /= 2; // Bytes counted -> WORDs - if( !bBigEndian ) SwapWord( 4, &nRealSHXContentSize ); - psHooks->FSeek( fpSHX, 24, 0 ); - psHooks->FWrite( &nRealSHXContentSize, 4, 1, fpSHX ); + nRealSHXContentSize /= 2; // Bytes counted -> WORDs + if (!bBigEndian) + SwapWord(4, &nRealSHXContentSize); + psHooks->FSeek(fpSHX, 24, 0); + psHooks->FWrite(&nRealSHXContentSize, 4, 1, fpSHX); - psHooks->FClose( fpSHP ); - psHooks->FClose( fpSHX ); + psHooks->FClose(fpSHP); + psHooks->FClose(fpSHX); - free ( pabyBuf ); - free ( pszFullname ); - free ( pabySHXHeader ); + free(pszFullname); + free(pabySHXHeader); - return( 1 ); + return nRetCode; } /************************************************************************/ /* SHPClose() */ -/* */ -/* Close the .shp and .shx files. */ +/* */ +/* Close the .shp and .shx files. */ /************************************************************************/ -void SHPAPI_CALL -SHPClose(SHPHandle psSHP ) - +void SHPAPI_CALL SHPClose(SHPHandle psSHP) { - if( psSHP == SHPLIB_NULLPTR ) + if (psSHP == SHPLIB_NULLPTR) return; -/* -------------------------------------------------------------------- */ -/* Update the header if we have modified anything. */ -/* -------------------------------------------------------------------- */ - if( psSHP->bUpdated ) - SHPWriteHeader( psSHP ); + /* -------------------------------------------------------------------- */ + /* Update the header if we have modified anything. */ + /* -------------------------------------------------------------------- */ + if (psSHP->bUpdated) + SHPWriteHeader(psSHP); -/* -------------------------------------------------------------------- */ -/* Free all resources, and close files. */ -/* -------------------------------------------------------------------- */ - free( psSHP->panRecOffset ); - free( psSHP->panRecSize ); + /* -------------------------------------------------------------------- */ + /* Free all resources, and close files. */ + /* -------------------------------------------------------------------- */ + free(psSHP->panRecOffset); + free(psSHP->panRecSize); - if ( psSHP->fpSHX != SHPLIB_NULLPTR) - psSHP->sHooks.FClose( psSHP->fpSHX ); - psSHP->sHooks.FClose( psSHP->fpSHP ); + if (psSHP->fpSHX != SHPLIB_NULLPTR) + psSHP->sHooks.FClose(psSHP->fpSHX); + psSHP->sHooks.FClose(psSHP->fpSHP); - if( psSHP->pabyRec != SHPLIB_NULLPTR ) + if (psSHP->pabyRec != SHPLIB_NULLPTR) { - free( psSHP->pabyRec ); + free(psSHP->pabyRec); } - if( psSHP->pabyObjectBuf != SHPLIB_NULLPTR ) + if (psSHP->pabyObjectBuf != SHPLIB_NULLPTR) { - free( psSHP->pabyObjectBuf ); + free(psSHP->pabyObjectBuf); } - if( psSHP->psCachedObject != SHPLIB_NULLPTR ) + if (psSHP->psCachedObject != SHPLIB_NULLPTR) { - free( psSHP->psCachedObject ); + free(psSHP->psCachedObject); } - free( psSHP ); + free(psSHP); } /************************************************************************/ @@ -1193,14 +954,15 @@ SHPClose(SHPHandle psSHP ) /* So you cannot have 2 valid instances of SHPReadObject() simultaneously. */ /* The SHPObject padfZ and padfM members may be NULL depending on the geometry */ /* type. It is illegal to free at hand any of the pointer members of the SHPObject structure */ -void SHPAPI_CALL SHPSetFastModeReadObject( SHPHandle hSHP, int bFastMode ) +void SHPAPI_CALL SHPSetFastModeReadObject(SHPHandle hSHP, int bFastMode) { - if( bFastMode ) + if (bFastMode) { - if( hSHP->psCachedObject == SHPLIB_NULLPTR ) + if (hSHP->psCachedObject == SHPLIB_NULLPTR) { - hSHP->psCachedObject = STATIC_CAST(SHPObject*, calloc(1, sizeof(SHPObject))); - assert( hSHP->psCachedObject != SHPLIB_NULLPTR ); + hSHP->psCachedObject = + STATIC_CAST(SHPObject *, calloc(1, sizeof(SHPObject))); + assert(hSHP->psCachedObject != SHPLIB_NULLPTR); } } @@ -1213,27 +975,23 @@ void SHPAPI_CALL SHPSetFastModeReadObject( SHPHandle hSHP, int bFastMode ) /* Fetch general information about the shape file. */ /************************************************************************/ -void SHPAPI_CALL -SHPGetInfo(SHPHandle psSHP, int * pnEntities, int * pnShapeType, - double * padfMinBound, double * padfMaxBound ) - +void SHPAPI_CALL SHPGetInfo(SHPHandle psSHP, int *pnEntities, int *pnShapeType, + double *padfMinBound, double *padfMaxBound) { - int i; - - if( psSHP == SHPLIB_NULLPTR ) + if (psSHP == SHPLIB_NULLPTR) return; - if( pnEntities != SHPLIB_NULLPTR ) + if (pnEntities != SHPLIB_NULLPTR) *pnEntities = psSHP->nRecords; - if( pnShapeType != SHPLIB_NULLPTR ) + if (pnShapeType != SHPLIB_NULLPTR) *pnShapeType = psSHP->nShapeType; - for( i = 0; i < 4; i++ ) + for (int i = 0; i < 4; i++) { - if( padfMinBound != SHPLIB_NULLPTR ) + if (padfMinBound != SHPLIB_NULLPTR) padfMinBound[i] = psSHP->adBoundsMin[i]; - if( padfMaxBound != SHPLIB_NULLPTR ) + if (padfMaxBound != SHPLIB_NULLPTR) padfMaxBound[i] = psSHP->adBoundsMax[i]; } } @@ -1245,15 +1003,13 @@ SHPGetInfo(SHPHandle psSHP, int * pnEntities, int * pnShapeType, /* shape file with read/write access. */ /************************************************************************/ -SHPHandle SHPAPI_CALL -SHPCreate( const char * pszLayer, int nShapeType ) - +SHPHandle SHPAPI_CALL SHPCreate(const char *pszLayer, int nShapeType) { SAHooks sHooks; - SASetupDefaultHooks( &sHooks ); + SASetupDefaultHooks(&sHooks); - return SHPCreateLL( pszLayer, nShapeType, &sHooks ); + return SHPCreateLL(pszLayer, nShapeType, &sHooks); } /************************************************************************/ @@ -1263,137 +1019,158 @@ SHPCreate( const char * pszLayer, int nShapeType ) /* shape file with read/write access. */ /************************************************************************/ -SHPHandle SHPAPI_CALL -SHPCreateLL( const char * pszLayer, int nShapeType, SAHooks *psHooks ) - +SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, + const SAHooks *psHooks) { - char *pszFullname; - SAFile fpSHP; - SAFile fpSHX = SHPLIB_NULLPTR; - uchar abyHeader[100]; - int32 i32; - double dValue; - int nLenWithoutExtension; - /* -------------------------------------------------------------------- */ /* Establish the byte order on this system. */ /* -------------------------------------------------------------------- */ #if !defined(bBigEndian) { int i = 1; - if( *((uchar *) &i) == 1 ) - bBigEndian = FALSE; + if (*((unsigned char *)&i) == 1) + bBigEndian = false; else - bBigEndian = TRUE; + bBigEndian = true; } #endif -/* -------------------------------------------------------------------- */ -/* Open the two files so we can write their headers. */ -/* -------------------------------------------------------------------- */ - nLenWithoutExtension = SHPGetLenWithoutExtension(pszLayer); - pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); + /* -------------------------------------------------------------------- */ + /* Open the two files so we can write their headers. */ + /* -------------------------------------------------------------------- */ + const int nLenWithoutExtension = SHPGetLenWithoutExtension(pszLayer); + char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); memcpy(pszFullname, pszLayer, nLenWithoutExtension); memcpy(pszFullname + nLenWithoutExtension, ".shp", 5); - fpSHP = psHooks->FOpen(pszFullname, "wb" ); - if( fpSHP == SHPLIB_NULLPTR ) + SAFile fpSHP = psHooks->FOpen(pszFullname, "w+b", psHooks->pvUserData); + if (fpSHP == SHPLIB_NULLPTR) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Failed to create file %s: %s", - pszFullname, strerror(errno) ); - psHooks->Error( szErrorMsg ); + snprintf(szErrorMsg, sizeof(szErrorMsg), "Failed to create file %s: %s", + pszFullname, strerror(errno)); + psHooks->Error(szErrorMsg); - goto error; + free(pszFullname); + return NULL; } memcpy(pszFullname + nLenWithoutExtension, ".shx", 5); - fpSHX = psHooks->FOpen(pszFullname, "wb" ); - if( fpSHX == SHPLIB_NULLPTR ) + SAFile fpSHX = psHooks->FOpen(pszFullname, "w+b", psHooks->pvUserData); + if (fpSHX == SHPLIB_NULLPTR) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Failed to create file %s: %s", - pszFullname, strerror(errno) ); - psHooks->Error( szErrorMsg ); - goto error; + snprintf(szErrorMsg, sizeof(szErrorMsg), "Failed to create file %s: %s", + pszFullname, strerror(errno)); + psHooks->Error(szErrorMsg); + + free(pszFullname); + psHooks->FClose(fpSHP); + return NULL; } - free( pszFullname ); pszFullname = SHPLIB_NULLPTR; + free(pszFullname); + pszFullname = SHPLIB_NULLPTR; -/* -------------------------------------------------------------------- */ -/* Prepare header block for .shp file. */ -/* -------------------------------------------------------------------- */ - memset( abyHeader, 0, sizeof(abyHeader) ); + /* -------------------------------------------------------------------- */ + /* Prepare header block for .shp file. */ + /* -------------------------------------------------------------------- */ + unsigned char abyHeader[100]; + memset(abyHeader, 0, sizeof(abyHeader)); - abyHeader[2] = 0x27; /* magic cookie */ + abyHeader[2] = 0x27; /* magic cookie */ abyHeader[3] = 0x0a; - i32 = 50; /* file size */ - ByteCopy( &i32, abyHeader+24, 4 ); - if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); + uint32_t i32 = 50; /* file size */ + ByteCopy(&i32, abyHeader + 24, 4); + if (!bBigEndian) + SwapWord(4, abyHeader + 24); - i32 = 1000; /* version */ - ByteCopy( &i32, abyHeader+28, 4 ); - if( bBigEndian ) SwapWord( 4, abyHeader+28 ); + i32 = 1000; /* version */ + ByteCopy(&i32, abyHeader + 28, 4); + if (bBigEndian) + SwapWord(4, abyHeader + 28); - i32 = nShapeType; /* shape type */ - ByteCopy( &i32, abyHeader+32, 4 ); - if( bBigEndian ) SwapWord( 4, abyHeader+32 ); + i32 = nShapeType; /* shape type */ + ByteCopy(&i32, abyHeader + 32, 4); + if (bBigEndian) + SwapWord(4, abyHeader + 32); - dValue = 0.0; /* set bounds */ - ByteCopy( &dValue, abyHeader+36, 8 ); - ByteCopy( &dValue, abyHeader+44, 8 ); - ByteCopy( &dValue, abyHeader+52, 8 ); - ByteCopy( &dValue, abyHeader+60, 8 ); + double dValue = 0.0; /* set bounds */ + ByteCopy(&dValue, abyHeader + 36, 8); + ByteCopy(&dValue, abyHeader + 44, 8); + ByteCopy(&dValue, abyHeader + 52, 8); + ByteCopy(&dValue, abyHeader + 60, 8); -/* -------------------------------------------------------------------- */ -/* Write .shp file header. */ -/* -------------------------------------------------------------------- */ - if( psHooks->FWrite( abyHeader, 100, 1, fpSHP ) != 1 ) + /* -------------------------------------------------------------------- */ + /* Write .shp file header. */ + /* -------------------------------------------------------------------- */ + if (psHooks->FWrite(abyHeader, 100, 1, fpSHP) != 1) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Failed to write .shp header: %s", strerror(errno) ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psHooks->Error( szErrorMsg ); + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Failed to write .shp header: %s", strerror(errno)); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psHooks->Error(szErrorMsg); - goto error; + free(pszFullname); + psHooks->FClose(fpSHP); + psHooks->FClose(fpSHX); + return NULL; } -/* -------------------------------------------------------------------- */ -/* Prepare, and write .shx file header. */ -/* -------------------------------------------------------------------- */ - i32 = 50; /* file size */ - ByteCopy( &i32, abyHeader+24, 4 ); - if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); + /* -------------------------------------------------------------------- */ + /* Prepare, and write .shx file header. */ + /* -------------------------------------------------------------------- */ + i32 = 50; /* file size */ + ByteCopy(&i32, abyHeader + 24, 4); + if (!bBigEndian) + SwapWord(4, abyHeader + 24); - if( psHooks->FWrite( abyHeader, 100, 1, fpSHX ) != 1 ) + if (psHooks->FWrite(abyHeader, 100, 1, fpSHX) != 1) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Failure writing .shx header: %s", strerror(errno) ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psHooks->Error( szErrorMsg ); + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Failure writing .shx header: %s", strerror(errno)); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psHooks->Error(szErrorMsg); - goto error; + free(pszFullname); + psHooks->FClose(fpSHP); + psHooks->FClose(fpSHX); + return NULL; } -/* -------------------------------------------------------------------- */ -/* Close the files, and then open them as regular existing files. */ -/* -------------------------------------------------------------------- */ - psHooks->FClose( fpSHP ); - psHooks->FClose( fpSHX ); + SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(sizeof(SHPInfo), 1)); + + psSHP->bUpdated = FALSE; + memcpy(&(psSHP->sHooks), psHooks, sizeof(SAHooks)); - return( SHPOpenLL( pszLayer, "r+b", psHooks ) ); + psSHP->fpSHP = fpSHP; + psSHP->fpSHX = fpSHX; + psSHP->nShapeType = nShapeType; + psSHP->nFileSize = 100; + psSHP->panRecOffset = + STATIC_CAST(unsigned int *, malloc(sizeof(unsigned int))); + psSHP->panRecSize = + STATIC_CAST(unsigned int *, malloc(sizeof(unsigned int))); -error: - if (pszFullname) free(pszFullname); - if (fpSHP) psHooks->FClose( fpSHP ); - if (fpSHX) psHooks->FClose( fpSHX ); - return SHPLIB_NULLPTR; + if (psSHP->panRecOffset == SHPLIB_NULLPTR || + psSHP->panRecSize == SHPLIB_NULLPTR) + { + psSHP->sHooks.Error("Not enough memory to allocate requested memory"); + psSHP->sHooks.FClose(psSHP->fpSHP); + psSHP->sHooks.FClose(psSHP->fpSHX); + if (psSHP->panRecOffset) + free(psSHP->panRecOffset); + if (psSHP->panRecSize) + free(psSHP->panRecSize); + free(psSHP); + return SHPLIB_NULLPTR; + } + + return psSHP; } /************************************************************************/ @@ -1403,20 +1180,19 @@ SHPCreateLL( const char * pszLayer, int nShapeType, SAHooks *psHooks ) /* indicated location in the record. */ /************************************************************************/ -static void _SHPSetBounds( uchar * pabyRec, SHPObject * psShape ) - +static void _SHPSetBounds(unsigned char *pabyRec, const SHPObject *psShape) { - ByteCopy( &(psShape->dfXMin), pabyRec + 0, 8 ); - ByteCopy( &(psShape->dfYMin), pabyRec + 8, 8 ); - ByteCopy( &(psShape->dfXMax), pabyRec + 16, 8 ); - ByteCopy( &(psShape->dfYMax), pabyRec + 24, 8 ); + ByteCopy(&(psShape->dfXMin), pabyRec + 0, 8); + ByteCopy(&(psShape->dfYMin), pabyRec + 8, 8); + ByteCopy(&(psShape->dfXMax), pabyRec + 16, 8); + ByteCopy(&(psShape->dfYMax), pabyRec + 24, 8); - if( bBigEndian ) + if (bBigEndian) { - SwapWord( 8, pabyRec + 0 ); - SwapWord( 8, pabyRec + 8 ); - SwapWord( 8, pabyRec + 16 ); - SwapWord( 8, pabyRec + 24 ); + SwapWord(8, pabyRec + 0); + SwapWord(8, pabyRec + 8); + SwapWord(8, pabyRec + 16); + SwapWord(8, pabyRec + 24); } } @@ -1427,16 +1203,12 @@ static void _SHPSetBounds( uchar * pabyRec, SHPObject * psShape ) /* SHPCreateObject(). */ /************************************************************************/ -void SHPAPI_CALL -SHPComputeExtents( SHPObject * psObject ) - +void SHPAPI_CALL SHPComputeExtents(SHPObject *psObject) { - int i; - -/* -------------------------------------------------------------------- */ -/* Build extents for this object. */ -/* -------------------------------------------------------------------- */ - if( psObject->nVertices > 0 ) + /* -------------------------------------------------------------------- */ + /* Build extents for this object. */ + /* -------------------------------------------------------------------- */ + if (psObject->nVertices > 0) { psObject->dfXMin = psObject->dfXMax = psObject->padfX[0]; psObject->dfYMin = psObject->dfYMax = psObject->padfY[0]; @@ -1444,7 +1216,7 @@ SHPComputeExtents( SHPObject * psObject ) psObject->dfMMin = psObject->dfMMax = psObject->padfM[0]; } - for( i = 0; i < psObject->nVertices; i++ ) + for (int i = 0; i < psObject->nVertices; i++) { psObject->dfXMin = MIN(psObject->dfXMin, psObject->padfX[i]); psObject->dfYMin = MIN(psObject->dfYMin, psObject->padfY[i]); @@ -1466,114 +1238,114 @@ SHPComputeExtents( SHPObject * psObject ) /************************************************************************/ SHPObject SHPAPI_CALL1(*) -SHPCreateObject( int nSHPType, int nShapeId, int nParts, - const int * panPartStart, const int * panPartType, - int nVertices, const double *padfX, const double *padfY, - const double * padfZ, const double * padfM ) - + SHPCreateObject(int nSHPType, int nShapeId, int nParts, + const int *panPartStart, const int *panPartType, + int nVertices, const double *padfX, const double *padfY, + const double *padfZ, const double *padfM) { - SHPObject *psObject; - int i, bHasM, bHasZ; - - psObject = STATIC_CAST(SHPObject *, calloc(1,sizeof(SHPObject))); + SHPObject *psObject = + STATIC_CAST(SHPObject *, calloc(1, sizeof(SHPObject))); psObject->nSHPType = nSHPType; psObject->nShapeId = nShapeId; psObject->bMeasureIsUsed = FALSE; -/* -------------------------------------------------------------------- */ -/* Establish whether this shape type has M, and Z values. */ -/* -------------------------------------------------------------------- */ - if( nSHPType == SHPT_ARCM - || nSHPType == SHPT_POINTM - || nSHPType == SHPT_POLYGONM - || nSHPType == SHPT_MULTIPOINTM ) + /* -------------------------------------------------------------------- */ + /* Establish whether this shape type has M, and Z values. */ + /* -------------------------------------------------------------------- */ + bool bHasM; + bool bHasZ; + + if (nSHPType == SHPT_ARCM || nSHPType == SHPT_POINTM || + nSHPType == SHPT_POLYGONM || nSHPType == SHPT_MULTIPOINTM) { - bHasM = TRUE; - bHasZ = FALSE; + bHasM = true; + bHasZ = false; } - else if( nSHPType == SHPT_ARCZ - || nSHPType == SHPT_POINTZ - || nSHPType == SHPT_POLYGONZ - || nSHPType == SHPT_MULTIPOINTZ - || nSHPType == SHPT_MULTIPATCH ) + else if (nSHPType == SHPT_ARCZ || nSHPType == SHPT_POINTZ || + nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_MULTIPOINTZ || + nSHPType == SHPT_MULTIPATCH) { - bHasM = TRUE; - bHasZ = TRUE; + bHasM = true; + bHasZ = true; } else { - bHasM = FALSE; - bHasZ = FALSE; + bHasM = false; + bHasZ = false; } -/* -------------------------------------------------------------------- */ -/* Capture parts. Note that part type is optional, and */ -/* defaults to ring. */ -/* -------------------------------------------------------------------- */ - if( nSHPType == SHPT_ARC || nSHPType == SHPT_POLYGON - || nSHPType == SHPT_ARCM || nSHPType == SHPT_POLYGONM - || nSHPType == SHPT_ARCZ || nSHPType == SHPT_POLYGONZ - || nSHPType == SHPT_MULTIPATCH ) + /* -------------------------------------------------------------------- */ + /* Capture parts. Note that part type is optional, and */ + /* defaults to ring. */ + /* -------------------------------------------------------------------- */ + if (nSHPType == SHPT_ARC || nSHPType == SHPT_POLYGON || + nSHPType == SHPT_ARCM || nSHPType == SHPT_POLYGONM || + nSHPType == SHPT_ARCZ || nSHPType == SHPT_POLYGONZ || + nSHPType == SHPT_MULTIPATCH) { - psObject->nParts = MAX(1,nParts); + psObject->nParts = MAX(1, nParts); - psObject->panPartStart = STATIC_CAST(int *, - calloc(sizeof(int), psObject->nParts)); - psObject->panPartType = STATIC_CAST(int *, - malloc(sizeof(int) * psObject->nParts)); + psObject->panPartStart = + STATIC_CAST(int *, calloc(sizeof(int), psObject->nParts)); + psObject->panPartType = + STATIC_CAST(int *, malloc(sizeof(int) * psObject->nParts)); psObject->panPartStart[0] = 0; psObject->panPartType[0] = SHPP_RING; - for( i = 0; i < nParts; i++ ) + for (int i = 0; i < nParts; i++) { - if( panPartStart != SHPLIB_NULLPTR ) + if (panPartStart != SHPLIB_NULLPTR) psObject->panPartStart[i] = panPartStart[i]; - if( panPartType != SHPLIB_NULLPTR ) + if (panPartType != SHPLIB_NULLPTR) psObject->panPartType[i] = panPartType[i]; else psObject->panPartType[i] = SHPP_RING; } - if( psObject->panPartStart[0] != 0 ) + if (psObject->panPartStart[0] != 0) psObject->panPartStart[0] = 0; } -/* -------------------------------------------------------------------- */ -/* Capture vertices. Note that X, Y, Z and M are optional. */ -/* -------------------------------------------------------------------- */ - if( nVertices > 0 ) - { - size_t nSize = sizeof(double) * nVertices; - psObject->padfX = STATIC_CAST(double *, padfX ? malloc(nSize) : - calloc(sizeof(double),nVertices)); - psObject->padfY = STATIC_CAST(double *, padfY ? malloc(nSize) : - calloc(sizeof(double),nVertices)); - psObject->padfZ = STATIC_CAST(double *, padfZ && bHasZ ? malloc(nSize) : - calloc(sizeof(double),nVertices)); - psObject->padfM = STATIC_CAST(double *, padfM && bHasM ? malloc(nSize) : - calloc(sizeof(double),nVertices)); - if( padfX != SHPLIB_NULLPTR ) + /* -------------------------------------------------------------------- */ + /* Capture vertices. Note that X, Y, Z and M are optional. */ + /* -------------------------------------------------------------------- */ + if (nVertices > 0) + { + const size_t nSize = sizeof(double) * nVertices; + psObject->padfX = + STATIC_CAST(double *, padfX ? malloc(nSize) + : calloc(sizeof(double), nVertices)); + psObject->padfY = + STATIC_CAST(double *, padfY ? malloc(nSize) + : calloc(sizeof(double), nVertices)); + psObject->padfZ = STATIC_CAST( + double *, + padfZ &&bHasZ ? malloc(nSize) : calloc(sizeof(double), nVertices)); + psObject->padfM = STATIC_CAST( + double *, + padfM &&bHasM ? malloc(nSize) : calloc(sizeof(double), nVertices)); + if (padfX != SHPLIB_NULLPTR) memcpy(psObject->padfX, padfX, nSize); - if( padfY != SHPLIB_NULLPTR ) + if (padfY != SHPLIB_NULLPTR) memcpy(psObject->padfY, padfY, nSize); - if( padfZ != SHPLIB_NULLPTR && bHasZ ) + if (padfZ != SHPLIB_NULLPTR && bHasZ) memcpy(psObject->padfZ, padfZ, nSize); - if( padfM != SHPLIB_NULLPTR && bHasM ) + if (padfM != SHPLIB_NULLPTR && bHasM) { memcpy(psObject->padfM, padfM, nSize); psObject->bMeasureIsUsed = TRUE; } } -/* -------------------------------------------------------------------- */ -/* Compute the extents. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* Compute the extents. */ + /* -------------------------------------------------------------------- */ psObject->nVertices = nVertices; - SHPComputeExtents( psObject ); + SHPComputeExtents(psObject); - return( psObject ); + return (psObject); } /************************************************************************/ @@ -1584,13 +1356,11 @@ SHPCreateObject( int nSHPType, int nShapeId, int nParts, /************************************************************************/ SHPObject SHPAPI_CALL1(*) -SHPCreateSimpleObject( int nSHPType, int nVertices, - const double * padfX, const double * padfY, - const double * padfZ ) - + SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX, + const double *padfY, const double *padfZ) { - return( SHPCreateObject( nSHPType, -1, 0, SHPLIB_NULLPTR, SHPLIB_NULLPTR, - nVertices, padfX, padfY, padfZ, SHPLIB_NULLPTR ) ); + return (SHPCreateObject(nSHPType, -1, 0, SHPLIB_NULLPTR, SHPLIB_NULLPTR, + nVertices, padfX, padfY, padfZ, SHPLIB_NULLPTR)); } /************************************************************************/ @@ -1600,116 +1370,141 @@ SHPCreateSimpleObject( int nSHPType, int nVertices, /* only possible to write vertices at the end of the file. */ /************************************************************************/ -int SHPAPI_CALL -SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject ) - +int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, + SHPObject *psObject) { - unsigned int nRecordOffset, nRecordSize=0; - int i; - uchar *pabyRec; - int32 i32; - int bAppendToLastRecord = FALSE; - int bAppendToFile = FALSE; - psSHP->bUpdated = TRUE; -/* -------------------------------------------------------------------- */ -/* Ensure that shape object matches the type of the file it is */ -/* being written to. */ -/* -------------------------------------------------------------------- */ - assert( psObject->nSHPType == psSHP->nShapeType - || psObject->nSHPType == SHPT_NULL ); - -/* -------------------------------------------------------------------- */ -/* Ensure that -1 is used for appends. Either blow an */ -/* assertion, or if they are disabled, set the shapeid to -1 */ -/* for appends. */ -/* -------------------------------------------------------------------- */ - assert( nShapeId == -1 - || (nShapeId >= 0 && nShapeId < psSHP->nRecords) ); - - if( nShapeId != -1 && nShapeId >= psSHP->nRecords ) + /* -------------------------------------------------------------------- */ + /* Ensure that shape object matches the type of the file it is */ + /* being written to. */ + /* -------------------------------------------------------------------- */ + assert(psObject->nSHPType == psSHP->nShapeType || + psObject->nSHPType == SHPT_NULL); + + /* -------------------------------------------------------------------- */ + /* Ensure that -1 is used for appends. Either blow an */ + /* assertion, or if they are disabled, set the shapeid to -1 */ + /* for appends. */ + /* -------------------------------------------------------------------- */ + assert(nShapeId == -1 || (nShapeId >= 0 && nShapeId < psSHP->nRecords)); + + if (nShapeId != -1 && nShapeId >= psSHP->nRecords) nShapeId = -1; -/* -------------------------------------------------------------------- */ -/* Add the new entity to the in memory index. */ -/* -------------------------------------------------------------------- */ - if( nShapeId == -1 && psSHP->nRecords+1 > psSHP->nMaxRecords ) + /* -------------------------------------------------------------------- */ + /* Add the new entity to the in memory index. */ + /* -------------------------------------------------------------------- */ + if (nShapeId == -1 && psSHP->nRecords + 1 > psSHP->nMaxRecords) { + /* This cannot overflow given that we check that the file size does + * not grow over 4 GB, and the minimum size of a record is 12 bytes, + * hence the maximm value for nMaxRecords is 357,913,941 + */ int nNewMaxRecords = psSHP->nMaxRecords + psSHP->nMaxRecords / 3 + 100; - unsigned int* panRecOffsetNew; - unsigned int* panRecSizeNew; + unsigned int *panRecOffsetNew; + unsigned int *panRecSizeNew; - panRecOffsetNew = STATIC_CAST(unsigned int *, - SfRealloc(psSHP->panRecOffset,sizeof(unsigned int) * nNewMaxRecords )); - if( panRecOffsetNew == SHPLIB_NULLPTR ) + panRecOffsetNew = STATIC_CAST( + unsigned int *, realloc(psSHP->panRecOffset, + sizeof(unsigned int) * nNewMaxRecords)); + if (panRecOffsetNew == SHPLIB_NULLPTR) + { + psSHP->sHooks.Error("Failed to write shape object. " + "Memory allocation error."); return -1; + } psSHP->panRecOffset = panRecOffsetNew; - panRecSizeNew = STATIC_CAST(unsigned int *, - SfRealloc(psSHP->panRecSize,sizeof(unsigned int) * nNewMaxRecords )); - if( panRecSizeNew == SHPLIB_NULLPTR ) + panRecSizeNew = STATIC_CAST( + unsigned int *, + realloc(psSHP->panRecSize, sizeof(unsigned int) * nNewMaxRecords)); + if (panRecSizeNew == SHPLIB_NULLPTR) + { + psSHP->sHooks.Error("Failed to write shape object. " + "Memory allocation error."); return -1; + } psSHP->panRecSize = panRecSizeNew; psSHP->nMaxRecords = nNewMaxRecords; } -/* -------------------------------------------------------------------- */ -/* Initialize record. */ -/* -------------------------------------------------------------------- */ - pabyRec = STATIC_CAST(uchar *, malloc(psObject->nVertices * 4 * sizeof(double) - + psObject->nParts * 8 + 128)); - if( pabyRec == SHPLIB_NULLPTR ) - return -1; + /* -------------------------------------------------------------------- */ + /* Initialize record. */ + /* -------------------------------------------------------------------- */ -/* -------------------------------------------------------------------- */ -/* Extract vertices for a Polygon or Arc. */ -/* -------------------------------------------------------------------- */ - if( psObject->nSHPType == SHPT_POLYGON - || psObject->nSHPType == SHPT_POLYGONZ - || psObject->nSHPType == SHPT_POLYGONM - || psObject->nSHPType == SHPT_ARC - || psObject->nSHPType == SHPT_ARCZ - || psObject->nSHPType == SHPT_ARCM - || psObject->nSHPType == SHPT_MULTIPATCH ) + /* The following computation cannot overflow on 32-bit platforms given that + * the user had to allocate arrays of at least that size. */ + size_t nRecMaxSize = + psObject->nVertices * 4 * sizeof(double) + psObject->nParts * 8; + /* But the following test could trigger on 64-bit platforms on huge + * geometries. */ + const unsigned nExtraSpaceForGeomHeader = 128; + if (nRecMaxSize > UINT_MAX - nExtraSpaceForGeomHeader) + { + psSHP->sHooks.Error("Failed to write shape object. Too big geometry."); + return -1; + } + nRecMaxSize += nExtraSpaceForGeomHeader; + unsigned char *pabyRec = STATIC_CAST(unsigned char *, malloc(nRecMaxSize)); + if (pabyRec == SHPLIB_NULLPTR) { - int32 nPoints, nParts; + psSHP->sHooks.Error("Failed to write shape object. " + "Memory allocation error."); + return -1; + } + + /* -------------------------------------------------------------------- */ + /* Extract vertices for a Polygon or Arc. */ + /* -------------------------------------------------------------------- */ + unsigned int nRecordSize = 0; + const bool bFirstFeature = psSHP->nRecords == 0; - nPoints = psObject->nVertices; - nParts = psObject->nParts; + if (psObject->nSHPType == SHPT_POLYGON || + psObject->nSHPType == SHPT_POLYGONZ || + psObject->nSHPType == SHPT_POLYGONM || psObject->nSHPType == SHPT_ARC || + psObject->nSHPType == SHPT_ARCZ || psObject->nSHPType == SHPT_ARCM || + psObject->nSHPType == SHPT_MULTIPATCH) + { + uint32_t nPoints = psObject->nVertices; + uint32_t nParts = psObject->nParts; - _SHPSetBounds( pabyRec + 12, psObject ); + _SHPSetBounds(pabyRec + 12, psObject); - if( bBigEndian ) SwapWord( 4, &nPoints ); - if( bBigEndian ) SwapWord( 4, &nParts ); + if (bBigEndian) + SwapWord(4, &nPoints); + if (bBigEndian) + SwapWord(4, &nParts); - ByteCopy( &nPoints, pabyRec + 40 + 8, 4 ); - ByteCopy( &nParts, pabyRec + 36 + 8, 4 ); + ByteCopy(&nPoints, pabyRec + 40 + 8, 4); + ByteCopy(&nParts, pabyRec + 36 + 8, 4); nRecordSize = 52; /* * Write part start positions. */ - ByteCopy( psObject->panPartStart, pabyRec + 44 + 8, - 4 * psObject->nParts ); - for( i = 0; i < psObject->nParts; i++ ) + ByteCopy(psObject->panPartStart, pabyRec + 44 + 8, + 4 * psObject->nParts); + for (int i = 0; i < psObject->nParts; i++) { - if( bBigEndian ) SwapWord( 4, pabyRec + 44 + 8 + 4*i ); + if (bBigEndian) + SwapWord(4, pabyRec + 44 + 8 + 4 * i); nRecordSize += 4; } /* * Write multipatch part types if needed. */ - if( psObject->nSHPType == SHPT_MULTIPATCH ) + if (psObject->nSHPType == SHPT_MULTIPATCH) { - memcpy( pabyRec + nRecordSize, psObject->panPartType, - 4*psObject->nParts ); - for( i = 0; i < psObject->nParts; i++ ) + memcpy(pabyRec + nRecordSize, psObject->panPartType, + 4 * psObject->nParts); + for (int i = 0; i < psObject->nParts; i++) { - if( bBigEndian ) SwapWord( 4, pabyRec + nRecordSize ); + if (bBigEndian) + SwapWord(4, pabyRec + nRecordSize); nRecordSize += 4; } } @@ -1717,16 +1512,16 @@ SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject ) /* * Write the (x,y) vertex values. */ - for( i = 0; i < psObject->nVertices; i++ ) + for (int i = 0; i < psObject->nVertices; i++) { - ByteCopy( psObject->padfX + i, pabyRec + nRecordSize, 8 ); - ByteCopy( psObject->padfY + i, pabyRec + nRecordSize + 8, 8 ); + ByteCopy(psObject->padfX + i, pabyRec + nRecordSize, 8); + ByteCopy(psObject->padfY + i, pabyRec + nRecordSize + 8, 8); - if( bBigEndian ) - SwapWord( 8, pabyRec + nRecordSize ); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); - if( bBigEndian ) - SwapWord( 8, pabyRec + nRecordSize + 8 ); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize + 8); nRecordSize += 2 * 8; } @@ -1734,22 +1529,25 @@ SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject ) /* * Write the Z coordinates (if any). */ - if( psObject->nSHPType == SHPT_POLYGONZ - || psObject->nSHPType == SHPT_ARCZ - || psObject->nSHPType == SHPT_MULTIPATCH ) + if (psObject->nSHPType == SHPT_POLYGONZ || + psObject->nSHPType == SHPT_ARCZ || + psObject->nSHPType == SHPT_MULTIPATCH) { - ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(&(psObject->dfZMin), pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; - ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(&(psObject->dfZMax), pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; - for( i = 0; i < psObject->nVertices; i++ ) + for (int i = 0; i < psObject->nVertices; i++) { - ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(psObject->padfZ + i, pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; } } @@ -1757,172 +1555,190 @@ SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject ) /* * Write the M values, if any. */ - if( psObject->bMeasureIsUsed - && (psObject->nSHPType == SHPT_POLYGONM - || psObject->nSHPType == SHPT_ARCM + if (psObject->bMeasureIsUsed && + (psObject->nSHPType == SHPT_POLYGONM || + psObject->nSHPType == SHPT_ARCM #ifndef DISABLE_MULTIPATCH_MEASURE - || psObject->nSHPType == SHPT_MULTIPATCH + || psObject->nSHPType == SHPT_MULTIPATCH #endif - || psObject->nSHPType == SHPT_POLYGONZ - || psObject->nSHPType == SHPT_ARCZ) ) + || psObject->nSHPType == SHPT_POLYGONZ || + psObject->nSHPType == SHPT_ARCZ)) { - ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(&(psObject->dfMMin), pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; - ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(&(psObject->dfMMax), pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; - for( i = 0; i < psObject->nVertices; i++ ) + for (int i = 0; i < psObject->nVertices; i++) { - ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(psObject->padfM + i, pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; } } } -/* -------------------------------------------------------------------- */ -/* Extract vertices for a MultiPoint. */ -/* -------------------------------------------------------------------- */ - else if( psObject->nSHPType == SHPT_MULTIPOINT - || psObject->nSHPType == SHPT_MULTIPOINTZ - || psObject->nSHPType == SHPT_MULTIPOINTM ) + /* -------------------------------------------------------------------- */ + /* Extract vertices for a MultiPoint. */ + /* -------------------------------------------------------------------- */ + else if (psObject->nSHPType == SHPT_MULTIPOINT || + psObject->nSHPType == SHPT_MULTIPOINTZ || + psObject->nSHPType == SHPT_MULTIPOINTM) { - int32 nPoints; + uint32_t nPoints = psObject->nVertices; - nPoints = psObject->nVertices; + _SHPSetBounds(pabyRec + 12, psObject); - _SHPSetBounds( pabyRec + 12, psObject ); + if (bBigEndian) + SwapWord(4, &nPoints); + ByteCopy(&nPoints, pabyRec + 44, 4); - if( bBigEndian ) SwapWord( 4, &nPoints ); - ByteCopy( &nPoints, pabyRec + 44, 4 ); - - for( i = 0; i < psObject->nVertices; i++ ) + for (int i = 0; i < psObject->nVertices; i++) { - ByteCopy( psObject->padfX + i, pabyRec + 48 + i*16, 8 ); - ByteCopy( psObject->padfY + i, pabyRec + 48 + i*16 + 8, 8 ); + ByteCopy(psObject->padfX + i, pabyRec + 48 + i * 16, 8); + ByteCopy(psObject->padfY + i, pabyRec + 48 + i * 16 + 8, 8); - if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 ); - if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 + 8 ); + if (bBigEndian) + SwapWord(8, pabyRec + 48 + i * 16); + if (bBigEndian) + SwapWord(8, pabyRec + 48 + i * 16 + 8); } nRecordSize = 48 + 16 * psObject->nVertices; - if( psObject->nSHPType == SHPT_MULTIPOINTZ ) + if (psObject->nSHPType == SHPT_MULTIPOINTZ) { - ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(&(psObject->dfZMin), pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; - ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(&(psObject->dfZMax), pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; - for( i = 0; i < psObject->nVertices; i++ ) + for (int i = 0; i < psObject->nVertices; i++) { - ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(psObject->padfZ + i, pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; } } - if( psObject->bMeasureIsUsed - && (psObject->nSHPType == SHPT_MULTIPOINTZ - || psObject->nSHPType == SHPT_MULTIPOINTM) ) + if (psObject->bMeasureIsUsed && + (psObject->nSHPType == SHPT_MULTIPOINTZ || + psObject->nSHPType == SHPT_MULTIPOINTM)) { - ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(&(psObject->dfMMin), pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; - ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(&(psObject->dfMMax), pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; - for( i = 0; i < psObject->nVertices; i++ ) + for (int i = 0; i < psObject->nVertices; i++) { - ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(psObject->padfM + i, pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; } } } -/* -------------------------------------------------------------------- */ -/* Write point. */ -/* -------------------------------------------------------------------- */ - else if( psObject->nSHPType == SHPT_POINT - || psObject->nSHPType == SHPT_POINTZ - || psObject->nSHPType == SHPT_POINTM ) + /* -------------------------------------------------------------------- */ + /* Write point. */ + /* -------------------------------------------------------------------- */ + else if (psObject->nSHPType == SHPT_POINT || + psObject->nSHPType == SHPT_POINTZ || + psObject->nSHPType == SHPT_POINTM) { - ByteCopy( psObject->padfX, pabyRec + 12, 8 ); - ByteCopy( psObject->padfY, pabyRec + 20, 8 ); + ByteCopy(psObject->padfX, pabyRec + 12, 8); + ByteCopy(psObject->padfY, pabyRec + 20, 8); - if( bBigEndian ) SwapWord( 8, pabyRec + 12 ); - if( bBigEndian ) SwapWord( 8, pabyRec + 20 ); + if (bBigEndian) + SwapWord(8, pabyRec + 12); + if (bBigEndian) + SwapWord(8, pabyRec + 20); nRecordSize = 28; - if( psObject->nSHPType == SHPT_POINTZ ) + if (psObject->nSHPType == SHPT_POINTZ) { - ByteCopy( psObject->padfZ, pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(psObject->padfZ, pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; } - if( psObject->bMeasureIsUsed - && (psObject->nSHPType == SHPT_POINTZ - || psObject->nSHPType == SHPT_POINTM) ) + if (psObject->bMeasureIsUsed && (psObject->nSHPType == SHPT_POINTZ || + psObject->nSHPType == SHPT_POINTM)) { - ByteCopy( psObject->padfM, pabyRec + nRecordSize, 8 ); - if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); + ByteCopy(psObject->padfM, pabyRec + nRecordSize, 8); + if (bBigEndian) + SwapWord(8, pabyRec + nRecordSize); nRecordSize += 8; } } -/* -------------------------------------------------------------------- */ -/* Not much to do for null geometries. */ -/* -------------------------------------------------------------------- */ - else if( psObject->nSHPType == SHPT_NULL ) + /* -------------------------------------------------------------------- */ + /* Not much to do for null geometries. */ + /* -------------------------------------------------------------------- */ + else if (psObject->nSHPType == SHPT_NULL) { nRecordSize = 12; } - else { /* unknown type */ - assert( FALSE ); - } - -/* -------------------------------------------------------------------- */ -/* Establish where we are going to put this record. If we are */ -/* rewriting the last record of the file, then we can update it in */ -/* place. Otherwise if rewriting an existing record, and it will */ -/* fit, then put it back where the original came from. Otherwise */ -/* write at the end. */ -/* -------------------------------------------------------------------- */ - if( nShapeId != -1 && psSHP->panRecOffset[nShapeId] + - psSHP->panRecSize[nShapeId] + 8 == psSHP->nFileSize ) + assert(false); + } + + /* -------------------------------------------------------------------- */ + /* Establish where we are going to put this record. If we are */ + /* rewriting the last record of the file, then we can update it in */ + /* place. Otherwise if rewriting an existing record, and it will */ + /* fit, then put it back where the original came from. Otherwise */ + /* write at the end. */ + /* -------------------------------------------------------------------- */ + SAOffset nRecordOffset; + bool bAppendToLastRecord = false; + bool bAppendToFile = false; + if (nShapeId != -1 && + psSHP->panRecOffset[nShapeId] + psSHP->panRecSize[nShapeId] + 8 == + psSHP->nFileSize) { nRecordOffset = psSHP->panRecOffset[nShapeId]; - bAppendToLastRecord = TRUE; + bAppendToLastRecord = true; } - else if( nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize-8 ) + else if (nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize - 8) { - if( psSHP->nFileSize > UINT_MAX - nRecordSize) + if (psSHP->nFileSize > UINT_MAX - nRecordSize) { - char str[128]; - snprintf( str, sizeof(str), "Failed to write shape object. " - "File size cannot reach %u + %u.", - psSHP->nFileSize, nRecordSize ); - str[sizeof(str)-1] = '\0'; - psSHP->sHooks.Error( str ); - free( pabyRec ); + char str[255]; + snprintf(str, sizeof(str), + "Failed to write shape object. " + "The maximum file size of %u has been reached. " + "The current record of size %u cannot be added.", + psSHP->nFileSize, nRecordSize); + str[sizeof(str) - 1] = '\0'; + psSHP->sHooks.Error(str); + free(pabyRec); return -1; } - bAppendToFile = TRUE; + bAppendToFile = true; nRecordOffset = psSHP->nFileSize; } else @@ -1930,76 +1746,87 @@ SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject ) nRecordOffset = psSHP->panRecOffset[nShapeId]; } -/* -------------------------------------------------------------------- */ -/* Set the shape type, record number, and record size. */ -/* -------------------------------------------------------------------- */ - i32 = (nShapeId < 0) ? psSHP->nRecords+1 : nShapeId+1; /* record # */ - if( !bBigEndian ) SwapWord( 4, &i32 ); - ByteCopy( &i32, pabyRec, 4 ); + /* -------------------------------------------------------------------- */ + /* Set the shape type, record number, and record size. */ + /* -------------------------------------------------------------------- */ + uint32_t i32 = + (nShapeId < 0) ? psSHP->nRecords + 1 : nShapeId + 1; /* record # */ + if (!bBigEndian) + SwapWord(4, &i32); + ByteCopy(&i32, pabyRec, 4); - i32 = (nRecordSize-8)/2; /* record size */ - if( !bBigEndian ) SwapWord( 4, &i32 ); - ByteCopy( &i32, pabyRec + 4, 4 ); + i32 = (nRecordSize - 8) / 2; /* record size */ + if (!bBigEndian) + SwapWord(4, &i32); + ByteCopy(&i32, pabyRec + 4, 4); - i32 = psObject->nSHPType; /* shape type */ - if( bBigEndian ) SwapWord( 4, &i32 ); - ByteCopy( &i32, pabyRec + 8, 4 ); + i32 = psObject->nSHPType; /* shape type */ + if (bBigEndian) + SwapWord(4, &i32); + ByteCopy(&i32, pabyRec + 8, 4); -/* -------------------------------------------------------------------- */ -/* Write out record. */ -/* -------------------------------------------------------------------- */ - if( psSHP->sHooks.FSeek( psSHP->fpSHP, nRecordOffset, 0 ) != 0 ) + /* -------------------------------------------------------------------- */ + /* Write out record. */ + /* -------------------------------------------------------------------- */ + + /* -------------------------------------------------------------------- */ + /* Guard FSeek with check for whether we're already at position; */ + /* no-op FSeeks defeat network filesystems' write buffering. */ + /* -------------------------------------------------------------------- */ + if (psSHP->sHooks.FTell(psSHP->fpSHP) != nRecordOffset) { - char szErrorMsg[200]; + if (psSHP->sHooks.FSeek(psSHP->fpSHP, nRecordOffset, 0) != 0) + { + char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Error in psSHP->sHooks.FSeek() while writing object to .shp file: %s", - strerror(errno) ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Error in psSHP->sHooks.FSeek() while writing object to " + ".shp file: %s", + strerror(errno)); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); - free( pabyRec ); - return -1; + free(pabyRec); + return -1; + } } - if( psSHP->sHooks.FWrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 ) + if (psSHP->sHooks.FWrite(pabyRec, nRecordSize, 1, psSHP->fpSHP) < 1) { char szErrorMsg[200]; - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Error in psSHP->sHooks.FWrite() while writing object of %u bytes to .shp file: %s", - nRecordSize, strerror(errno) ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Error in psSHP->sHooks.FWrite() while writing object of %u " + "bytes to .shp file: %s", + nRecordSize, strerror(errno)); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); - free( pabyRec ); + free(pabyRec); return -1; } - free( pabyRec ); + free(pabyRec); - if( bAppendToLastRecord ) + if (bAppendToLastRecord) { - psSHP->nFileSize = psSHP->panRecOffset[nShapeId] + nRecordSize; + psSHP->nFileSize = psSHP->panRecOffset[nShapeId] + nRecordSize; } - else if( bAppendToFile ) + else if (bAppendToFile) { - if( nShapeId == -1 ) + if (nShapeId == -1) nShapeId = psSHP->nRecords++; psSHP->panRecOffset[nShapeId] = psSHP->nFileSize; psSHP->nFileSize += nRecordSize; } - psSHP->panRecSize[nShapeId] = nRecordSize-8; + psSHP->panRecSize[nShapeId] = nRecordSize - 8; -/* -------------------------------------------------------------------- */ -/* Expand file wide bounds based on this shape. */ -/* -------------------------------------------------------------------- */ - if( psSHP->adBoundsMin[0] == 0.0 - && psSHP->adBoundsMax[0] == 0.0 - && psSHP->adBoundsMin[1] == 0.0 - && psSHP->adBoundsMax[1] == 0.0 ) + /* -------------------------------------------------------------------- */ + /* Expand file wide bounds based on this shape. */ + /* -------------------------------------------------------------------- */ + if (bFirstFeature) { - if( psObject->nSHPType == SHPT_NULL || psObject->nVertices == 0 ) + if (psObject->nSHPType == SHPT_NULL || psObject->nVertices == 0) { psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = 0.0; psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = 0.0; @@ -2010,45 +1837,49 @@ SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject ) { psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0]; psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0]; - psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ ? psObject->padfZ[0] : 0.0; - psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM ? psObject->padfM[0] : 0.0; + psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = + psObject->padfZ ? psObject->padfZ[0] : 0.0; + psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = + psObject->padfM ? psObject->padfM[0] : 0.0; } } - for( i = 0; i < psObject->nVertices; i++ ) + for (int i = 0; i < psObject->nVertices; i++) { - psSHP->adBoundsMin[0] = MIN(psSHP->adBoundsMin[0],psObject->padfX[i]); - psSHP->adBoundsMin[1] = MIN(psSHP->adBoundsMin[1],psObject->padfY[i]); - psSHP->adBoundsMax[0] = MAX(psSHP->adBoundsMax[0],psObject->padfX[i]); - psSHP->adBoundsMax[1] = MAX(psSHP->adBoundsMax[1],psObject->padfY[i]); - if( psObject->padfZ ) + psSHP->adBoundsMin[0] = MIN(psSHP->adBoundsMin[0], psObject->padfX[i]); + psSHP->adBoundsMin[1] = MIN(psSHP->adBoundsMin[1], psObject->padfY[i]); + psSHP->adBoundsMax[0] = MAX(psSHP->adBoundsMax[0], psObject->padfX[i]); + psSHP->adBoundsMax[1] = MAX(psSHP->adBoundsMax[1], psObject->padfY[i]); + if (psObject->padfZ) { - psSHP->adBoundsMin[2] = MIN(psSHP->adBoundsMin[2],psObject->padfZ[i]); - psSHP->adBoundsMax[2] = MAX(psSHP->adBoundsMax[2],psObject->padfZ[i]); + psSHP->adBoundsMin[2] = + MIN(psSHP->adBoundsMin[2], psObject->padfZ[i]); + psSHP->adBoundsMax[2] = + MAX(psSHP->adBoundsMax[2], psObject->padfZ[i]); } - if( psObject->padfM ) + if (psObject->padfM) { - psSHP->adBoundsMin[3] = MIN(psSHP->adBoundsMin[3],psObject->padfM[i]); - psSHP->adBoundsMax[3] = MAX(psSHP->adBoundsMax[3],psObject->padfM[i]); + psSHP->adBoundsMin[3] = + MIN(psSHP->adBoundsMin[3], psObject->padfM[i]); + psSHP->adBoundsMax[3] = + MAX(psSHP->adBoundsMax[3], psObject->padfM[i]); } } - return( nShapeId ); + return (nShapeId); } /************************************************************************/ /* SHPAllocBuffer() */ /************************************************************************/ -static void* SHPAllocBuffer(unsigned char** pBuffer, int nSize) +static void *SHPAllocBuffer(unsigned char **pBuffer, int nSize) { - unsigned char* pRet; - - if( pBuffer == SHPLIB_NULLPTR ) + if (pBuffer == SHPLIB_NULLPTR) return calloc(1, nSize); - pRet = *pBuffer; - if( pRet == SHPLIB_NULLPTR ) + unsigned char *pRet = *pBuffer; + if (pRet == SHPLIB_NULLPTR) return SHPLIB_NULLPTR; (*pBuffer) += nSize; @@ -2059,108 +1890,106 @@ static void* SHPAllocBuffer(unsigned char** pBuffer, int nSize) /* SHPReallocObjectBufIfNecessary() */ /************************************************************************/ -static unsigned char* SHPReallocObjectBufIfNecessary ( SHPHandle psSHP, - int nObjectBufSize ) +static unsigned char *SHPReallocObjectBufIfNecessary(SHPHandle psSHP, + int nObjectBufSize) { - unsigned char* pBuffer; - if( nObjectBufSize == 0 ) + if (nObjectBufSize == 0) { nObjectBufSize = 4 * sizeof(double); } - if( nObjectBufSize > psSHP->nObjectBufSize ) + + unsigned char *pBuffer; + if (nObjectBufSize > psSHP->nObjectBufSize) { - pBuffer = STATIC_CAST(unsigned char*, realloc( psSHP->pabyObjectBuf, nObjectBufSize )); - if( pBuffer != SHPLIB_NULLPTR ) + pBuffer = STATIC_CAST(unsigned char *, + realloc(psSHP->pabyObjectBuf, nObjectBufSize)); + if (pBuffer != SHPLIB_NULLPTR) { psSHP->pabyObjectBuf = pBuffer; psSHP->nObjectBufSize = nObjectBufSize; } } else + { pBuffer = psSHP->pabyObjectBuf; + } + return pBuffer; } /************************************************************************/ /* SHPReadObject() */ /* */ -/* Read the vertices, parts, and other non-attribute information */ -/* for one shape. */ +/* Read the vertices, parts, and other non-attribute information */ +/* for one shape. */ /************************************************************************/ -SHPObject SHPAPI_CALL1(*) -SHPReadObject( SHPHandle psSHP, int hEntity ) - +SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) { - int nEntitySize, nRequiredSize; - SHPObject *psShape; - char szErrorMsg[128]; - int nSHPType; - int nBytesRead; - -/* -------------------------------------------------------------------- */ -/* Validate the record/entity number. */ -/* -------------------------------------------------------------------- */ - if( hEntity < 0 || hEntity >= psSHP->nRecords ) + /* -------------------------------------------------------------------- */ + /* Validate the record/entity number. */ + /* -------------------------------------------------------------------- */ + if (hEntity < 0 || hEntity >= psSHP->nRecords) return SHPLIB_NULLPTR; -/* -------------------------------------------------------------------- */ -/* Read offset/length from SHX loading if necessary. */ -/* -------------------------------------------------------------------- */ - if( psSHP->panRecOffset[hEntity] == 0 && psSHP->fpSHX != SHPLIB_NULLPTR ) + /* -------------------------------------------------------------------- */ + /* Read offset/length from SHX loading if necessary. */ + /* -------------------------------------------------------------------- */ + if (psSHP->panRecOffset[hEntity] == 0 && psSHP->fpSHX != SHPLIB_NULLPTR) { - unsigned int nOffset, nLength; + unsigned int nOffset; + unsigned int nLength; - if( psSHP->sHooks.FSeek( psSHP->fpSHX, 100 + 8 * hEntity, 0 ) != 0 || - psSHP->sHooks.FRead( &nOffset, 1, 4, psSHP->fpSHX ) != 4 || - psSHP->sHooks.FRead( &nLength, 1, 4, psSHP->fpSHX ) != 4 ) + if (psSHP->sHooks.FSeek(psSHP->fpSHX, 100 + 8 * hEntity, 0) != 0 || + psSHP->sHooks.FRead(&nOffset, 1, 4, psSHP->fpSHX) != 4 || + psSHP->sHooks.FRead(&nLength, 1, 4, psSHP->fpSHX) != 4) { char str[128]; - snprintf( str, sizeof(str), - "Error in fseek()/fread() reading object from .shx file at offset %d", - 100 + 8 * hEntity); - str[sizeof(str)-1] = '\0'; + snprintf(str, sizeof(str), + "Error in fseek()/fread() reading object from .shx file " + "at offset %d", + 100 + 8 * hEntity); + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); return SHPLIB_NULLPTR; } - if( !bBigEndian ) SwapWord( 4, &nOffset ); - if( !bBigEndian ) SwapWord( 4, &nLength ); + if (!bBigEndian) + SwapWord(4, &nOffset); + if (!bBigEndian) + SwapWord(4, &nLength); - if( nOffset > STATIC_CAST(unsigned int, INT_MAX) ) + if (nOffset > STATIC_CAST(unsigned int, INT_MAX)) { char str[128]; - snprintf( str, sizeof(str), - "Invalid offset for entity %d", hEntity); - str[sizeof(str)-1] = '\0'; + snprintf(str, sizeof(str), "Invalid offset for entity %d", hEntity); + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); return SHPLIB_NULLPTR; } - if( nLength > STATIC_CAST(unsigned int, INT_MAX / 2 - 4) ) + if (nLength > STATIC_CAST(unsigned int, INT_MAX / 2 - 4)) { char str[128]; - snprintf( str, sizeof(str), - "Invalid length for entity %d", hEntity); - str[sizeof(str)-1] = '\0'; + snprintf(str, sizeof(str), "Invalid length for entity %d", hEntity); + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); return SHPLIB_NULLPTR; } - psSHP->panRecOffset[hEntity] = nOffset*2; - psSHP->panRecSize[hEntity] = nLength*2; + psSHP->panRecOffset[hEntity] = nOffset * 2; + psSHP->panRecSize[hEntity] = nLength * 2; } -/* -------------------------------------------------------------------- */ -/* Ensure our record buffer is large enough. */ -/* -------------------------------------------------------------------- */ - nEntitySize = psSHP->panRecSize[hEntity]+8; - if( nEntitySize > psSHP->nBufSize ) + /* -------------------------------------------------------------------- */ + /* Ensure our record buffer is large enough. */ + /* -------------------------------------------------------------------- */ + const int nEntitySize = psSHP->panRecSize[hEntity] + 8; + if (nEntitySize > psSHP->nBufSize) { - uchar* pabyRecNew; int nNewBufSize = nEntitySize; - if( nNewBufSize < INT_MAX - nNewBufSize / 3 ) + if (nNewBufSize < INT_MAX - nNewBufSize / 3) nNewBufSize += nNewBufSize / 3; else nNewBufSize = INT_MAX; @@ -2168,45 +1997,51 @@ SHPReadObject( SHPHandle psSHP, int hEntity ) /* Before allocating too much memory, check that the file is big enough */ /* and do not trust the file size in the header the first time we */ /* need to allocate more than 10 MB */ - if( nNewBufSize >= 10 * 1024 * 1024 ) + if (nNewBufSize >= 10 * 1024 * 1024) { - if( psSHP->nBufSize < 10 * 1024 * 1024 ) + if (psSHP->nBufSize < 10 * 1024 * 1024) { SAOffset nFileSize; - psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 2 ); + psSHP->sHooks.FSeek(psSHP->fpSHP, 0, 2); nFileSize = psSHP->sHooks.FTell(psSHP->fpSHP); - if( nFileSize >= UINT_MAX ) + if (nFileSize >= UINT_MAX) psSHP->nFileSize = UINT_MAX; else psSHP->nFileSize = STATIC_CAST(unsigned int, nFileSize); } - if( psSHP->panRecOffset[hEntity] >= psSHP->nFileSize || + if (psSHP->panRecOffset[hEntity] >= psSHP->nFileSize || /* We should normally use nEntitySize instead of*/ /* psSHP->panRecSize[hEntity] in the below test, but because of */ /* the case of non conformant .shx files detailed a bit below, */ /* let be more tolerant */ - psSHP->panRecSize[hEntity] > psSHP->nFileSize - psSHP->panRecOffset[hEntity] ) + psSHP->panRecSize[hEntity] > + psSHP->nFileSize - psSHP->panRecOffset[hEntity]) { char str[128]; - snprintf( str, sizeof(str), - "Error in fread() reading object of size %d at offset %u from .shp file", - nEntitySize, psSHP->panRecOffset[hEntity] ); - str[sizeof(str)-1] = '\0'; + snprintf(str, sizeof(str), + "Error in fread() reading object of size %d at offset " + "%u from .shp file", + nEntitySize, psSHP->panRecOffset[hEntity]); + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); return SHPLIB_NULLPTR; } } - pabyRecNew = STATIC_CAST(uchar *, SfRealloc(psSHP->pabyRec,nNewBufSize)); + unsigned char *pabyRecNew = + STATIC_CAST(unsigned char *, realloc(psSHP->pabyRec, nNewBufSize)); if (pabyRecNew == SHPLIB_NULLPTR) { - snprintf( szErrorMsg, sizeof(szErrorMsg), - "Not enough memory to allocate requested memory (nNewBufSize=%d). " - "Probably broken SHP file", nNewBufSize); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + char szErrorMsg[160]; + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Not enough memory to allocate requested memory " + "(nNewBufSize=%d). " + "Probably broken SHP file", + nNewBufSize); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); return SHPLIB_NULLPTR; } @@ -2221,26 +2056,27 @@ SHPReadObject( SHPHandle psSHP, int hEntity ) return SHPLIB_NULLPTR; } -/* -------------------------------------------------------------------- */ -/* Read the record. */ -/* -------------------------------------------------------------------- */ - if( psSHP->sHooks.FSeek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 ) != 0 ) + /* -------------------------------------------------------------------- */ + /* Read the record. */ + /* -------------------------------------------------------------------- */ + if (psSHP->sHooks.FSeek(psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0) != 0) { /* * TODO - mloskot: Consider detailed diagnostics of shape file, * for example to detect if file is truncated. */ char str[128]; - snprintf( str, sizeof(str), + snprintf(str, sizeof(str), "Error in fseek() reading object from .shp file at offset %u", psSHP->panRecOffset[hEntity]); - str[sizeof(str)-1] = '\0'; + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); return SHPLIB_NULLPTR; } - nBytesRead = STATIC_CAST(int, psSHP->sHooks.FRead( psSHP->pabyRec, 1, nEntitySize, psSHP->fpSHP )); + const int nBytesRead = STATIC_CAST( + int, psSHP->sHooks.FRead(psSHP->pabyRec, 1, nEntitySize, psSHP->fpSHP)); /* Special case for a shapefile whose .shx content length field is not equal */ /* to the content length field of the .shp, which is a violation of "The */ @@ -2248,64 +2084,70 @@ SHPReadObject( SHPHandle psSHP, int hEntity ) /* file record header." (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf, page 24) */ /* Actually in that case the .shx content length is equal to the .shp content length + */ /* 4 (16 bit words), representing the 8 bytes of the record header... */ - if( nBytesRead >= 8 && nBytesRead == nEntitySize - 8 ) + if (nBytesRead >= 8 && nBytesRead == nEntitySize - 8) { /* Do a sanity check */ int nSHPContentLength; - memcpy( &nSHPContentLength, psSHP->pabyRec + 4, 4 ); - if( !bBigEndian ) SwapWord( 4, &(nSHPContentLength) ); - if( nSHPContentLength < 0 || - nSHPContentLength > INT_MAX / 2 - 4 || - 2 * nSHPContentLength + 8 != nBytesRead ) + memcpy(&nSHPContentLength, psSHP->pabyRec + 4, 4); + if (!bBigEndian) + SwapWord(4, &(nSHPContentLength)); + if (nSHPContentLength < 0 || nSHPContentLength > INT_MAX / 2 - 4 || + 2 * nSHPContentLength + 8 != nBytesRead) { char str[128]; - snprintf( str, sizeof(str), - "Sanity check failed when trying to recover from inconsistent .shx/.shp with shape %d", - hEntity ); - str[sizeof(str)-1] = '\0'; + snprintf(str, sizeof(str), + "Sanity check failed when trying to recover from " + "inconsistent .shx/.shp with shape %d", + hEntity); + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); return SHPLIB_NULLPTR; } } - else if( nBytesRead != nEntitySize ) + else if (nBytesRead != nEntitySize) { /* * TODO - mloskot: Consider detailed diagnostics of shape file, * for example to detect if file is truncated. */ char str[128]; - snprintf( str, sizeof(str), - "Error in fread() reading object of size %d at offset %u from .shp file", - nEntitySize, psSHP->panRecOffset[hEntity] ); - str[sizeof(str)-1] = '\0'; + snprintf(str, sizeof(str), + "Error in fread() reading object of size %d at offset %u from " + ".shp file", + nEntitySize, psSHP->panRecOffset[hEntity]); + str[sizeof(str) - 1] = '\0'; - psSHP->sHooks.Error( str ); + psSHP->sHooks.Error(str); return SHPLIB_NULLPTR; } - if ( 8 + 4 > nEntitySize ) + if (8 + 4 > nEntitySize) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), - "Corrupted .shp file : shape %d : nEntitySize = %d", - hEntity, nEntitySize); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + "Corrupted .shp file : shape %d : nEntitySize = %d", hEntity, + nEntitySize); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); return SHPLIB_NULLPTR; } - memcpy( &nSHPType, psSHP->pabyRec + 8, 4 ); + int nSHPType; + memcpy(&nSHPType, psSHP->pabyRec + 8, 4); - if( bBigEndian ) SwapWord( 4, &(nSHPType) ); + if (bBigEndian) + SwapWord(4, &(nSHPType)); -/* -------------------------------------------------------------------- */ -/* Allocate and minimally initialize the object. */ -/* -------------------------------------------------------------------- */ - if( psSHP->bFastModeReadObject ) + /* -------------------------------------------------------------------- */ + /* Allocate and minimally initialize the object. */ + /* -------------------------------------------------------------------- */ + SHPObject *psShape; + if (psSHP->bFastModeReadObject) { - if( psSHP->psCachedObject->bFastModeReadObject ) + if (psSHP->psCachedObject->bFastModeReadObject) { - psSHP->sHooks.Error( "Invalid read pattern in fast read mode. " - "SHPDestroyObject() should be called." ); + psSHP->sHooks.Error("Invalid read pattern in fast read mode. " + "SHPDestroyObject() should be called."); return SHPLIB_NULLPTR; } @@ -2313,69 +2155,74 @@ SHPReadObject( SHPHandle psSHP, int hEntity ) memset(psShape, 0, sizeof(SHPObject)); } else - psShape = STATIC_CAST(SHPObject *, calloc(1,sizeof(SHPObject))); + { + psShape = STATIC_CAST(SHPObject *, calloc(1, sizeof(SHPObject))); + } psShape->nShapeId = hEntity; psShape->nSHPType = nSHPType; psShape->bMeasureIsUsed = FALSE; psShape->bFastModeReadObject = psSHP->bFastModeReadObject; -/* ==================================================================== */ -/* Extract vertices for a Polygon or Arc. */ -/* ==================================================================== */ - if( psShape->nSHPType == SHPT_POLYGON || psShape->nSHPType == SHPT_ARC - || psShape->nSHPType == SHPT_POLYGONZ - || psShape->nSHPType == SHPT_POLYGONM - || psShape->nSHPType == SHPT_ARCZ - || psShape->nSHPType == SHPT_ARCM - || psShape->nSHPType == SHPT_MULTIPATCH ) + /* ==================================================================== */ + /* Extract vertices for a Polygon or Arc. */ + /* ==================================================================== */ + if (psShape->nSHPType == SHPT_POLYGON || psShape->nSHPType == SHPT_ARC || + psShape->nSHPType == SHPT_POLYGONZ || + psShape->nSHPType == SHPT_POLYGONM || psShape->nSHPType == SHPT_ARCZ || + psShape->nSHPType == SHPT_ARCM || psShape->nSHPType == SHPT_MULTIPATCH) { - int32 nPoints, nParts; - int i, nOffset; - unsigned char* pBuffer = SHPLIB_NULLPTR; - unsigned char** ppBuffer = SHPLIB_NULLPTR; - - if ( 40 + 8 + 4 > nEntitySize ) + if (40 + 8 + 4 > nEntitySize) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), "Corrupted .shp file : shape %d : nEntitySize = %d", hEntity, nEntitySize); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } -/* -------------------------------------------------------------------- */ -/* Get the X/Y bounds. */ -/* -------------------------------------------------------------------- */ - memcpy( &(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8 ); - memcpy( &(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 ); - memcpy( &(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 ); - memcpy( &(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 ); - - if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) ); - -/* -------------------------------------------------------------------- */ -/* Extract part/point count, and build vertex and part arrays */ -/* to proper size. */ -/* -------------------------------------------------------------------- */ - memcpy( &nPoints, psSHP->pabyRec + 40 + 8, 4 ); - memcpy( &nParts, psSHP->pabyRec + 36 + 8, 4 ); - - if( bBigEndian ) SwapWord( 4, &nPoints ); - if( bBigEndian ) SwapWord( 4, &nParts ); + /* -------------------------------------------------------------------- */ + /* Get the X/Y bounds. */ + /* -------------------------------------------------------------------- */ + memcpy(&(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8); + memcpy(&(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8); + memcpy(&(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8); + memcpy(&(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8); + + if (bBigEndian) + SwapWord(8, &(psShape->dfXMin)); + if (bBigEndian) + SwapWord(8, &(psShape->dfYMin)); + if (bBigEndian) + SwapWord(8, &(psShape->dfXMax)); + if (bBigEndian) + SwapWord(8, &(psShape->dfYMax)); + + /* -------------------------------------------------------------------- */ + /* Extract part/point count, and build vertex and part arrays */ + /* to proper size. */ + /* -------------------------------------------------------------------- */ + uint32_t nPoints; + memcpy(&nPoints, psSHP->pabyRec + 40 + 8, 4); + uint32_t nParts; + memcpy(&nParts, psSHP->pabyRec + 36 + 8, 4); + + if (bBigEndian) + SwapWord(4, &nPoints); + if (bBigEndian) + SwapWord(4, &nParts); /* nPoints and nParts are unsigned */ if (/* nPoints < 0 || nParts < 0 || */ nPoints > 50 * 1000 * 1000 || nParts > 10 * 1000 * 1000) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u.", hEntity, nPoints, nParts); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } @@ -2383,44 +2230,56 @@ SHPReadObject( SHPHandle psSHP, int hEntity ) /* With the previous checks on nPoints and nParts, */ /* we should not overflow here and after */ /* since 50 M * (16 + 8 + 8) = 1 600 MB */ - nRequiredSize = 44 + 8 + 4 * nParts + 16 * nPoints; - if ( psShape->nSHPType == SHPT_POLYGONZ - || psShape->nSHPType == SHPT_ARCZ - || psShape->nSHPType == SHPT_MULTIPATCH ) + int nRequiredSize = 44 + 8 + 4 * nParts + 16 * nPoints; + if (psShape->nSHPType == SHPT_POLYGONZ || + psShape->nSHPType == SHPT_ARCZ || + psShape->nSHPType == SHPT_MULTIPATCH) { nRequiredSize += 16 + 8 * nPoints; } - if( psShape->nSHPType == SHPT_MULTIPATCH ) + if (psShape->nSHPType == SHPT_MULTIPATCH) { nRequiredSize += 4 * nParts; } if (nRequiredSize > nEntitySize) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), - "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u, nEntitySize=%d.", + "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u, " + "nEntitySize=%d.", hEntity, nPoints, nParts, nEntitySize); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - if( psShape->bFastModeReadObject ) + unsigned char *pBuffer = SHPLIB_NULLPTR; + unsigned char **ppBuffer = SHPLIB_NULLPTR; + + if (psShape->bFastModeReadObject) { - int nObjectBufSize = 4 * sizeof(double) * nPoints + 2 * sizeof(int) * nParts; + const int nObjectBufSize = + 4 * sizeof(double) * nPoints + 2 * sizeof(int) * nParts; pBuffer = SHPReallocObjectBufIfNecessary(psSHP, nObjectBufSize); ppBuffer = &pBuffer; } psShape->nVertices = nPoints; - psShape->padfX = STATIC_CAST(double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); - psShape->padfY = STATIC_CAST(double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); - psShape->padfZ = STATIC_CAST(double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); - psShape->padfM = STATIC_CAST(double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); + psShape->padfX = STATIC_CAST( + double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); + psShape->padfY = STATIC_CAST( + double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); + psShape->padfZ = STATIC_CAST( + double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); + psShape->padfM = STATIC_CAST( + double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); psShape->nParts = nParts; - psShape->panPartStart = STATIC_CAST(int *, SHPAllocBuffer(ppBuffer, nParts * sizeof(int))); - psShape->panPartType = STATIC_CAST(int *, SHPAllocBuffer(ppBuffer, nParts * sizeof(int))); + psShape->panPartStart = + STATIC_CAST(int *, SHPAllocBuffer(ppBuffer, nParts * sizeof(int))); + psShape->panPartType = + STATIC_CAST(int *, SHPAllocBuffer(ppBuffer, nParts * sizeof(int))); if (psShape->padfX == SHPLIB_NULLPTR || psShape->padfY == SHPLIB_NULLPTR || @@ -2429,308 +2288,346 @@ SHPReadObject( SHPHandle psSHP, int hEntity ) psShape->panPartStart == SHPLIB_NULLPTR || psShape->panPartType == SHPLIB_NULLPTR) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), - "Not enough memory to allocate requested memory (nPoints=%u, nParts=%u) for shape %d. " - "Probably broken SHP file", nPoints, nParts, hEntity ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + "Not enough memory to allocate requested memory " + "(nPoints=%u, nParts=%u) for shape %d. " + "Probably broken SHP file", + nPoints, nParts, hEntity); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - for( i = 0; STATIC_CAST(int32, i) < nParts; i++ ) + for (int i = 0; STATIC_CAST(uint32_t, i) < nParts; i++) psShape->panPartType[i] = SHPP_RING; -/* -------------------------------------------------------------------- */ -/* Copy out the part array from the record. */ -/* -------------------------------------------------------------------- */ - memcpy( psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts ); - for( i = 0; STATIC_CAST(int32, i) < nParts; i++ ) + /* -------------------------------------------------------------------- */ + /* Copy out the part array from the record. */ + /* -------------------------------------------------------------------- */ + memcpy(psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts); + for (int i = 0; STATIC_CAST(uint32_t, i) < nParts; i++) { - if( bBigEndian ) SwapWord( 4, psShape->panPartStart+i ); + if (bBigEndian) + SwapWord(4, psShape->panPartStart + i); /* We check that the offset is inside the vertex array */ - if (psShape->panPartStart[i] < 0 - || (psShape->panPartStart[i] >= psShape->nVertices - && psShape->nVertices > 0) - || (psShape->panPartStart[i] > 0 && psShape->nVertices == 0) ) + if (psShape->panPartStart[i] < 0 || + (psShape->panPartStart[i] >= psShape->nVertices && + psShape->nVertices > 0) || + (psShape->panPartStart[i] > 0 && psShape->nVertices == 0)) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), - "Corrupted .shp file : shape %d : panPartStart[%d] = %d, nVertices = %d", - hEntity, i, psShape->panPartStart[i], psShape->nVertices); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + "Corrupted .shp file : shape %d : panPartStart[%d] = " + "%d, nVertices = %d", + hEntity, i, psShape->panPartStart[i], + psShape->nVertices); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - if (i > 0 && psShape->panPartStart[i] <= psShape->panPartStart[i-1]) + if (i > 0 && + psShape->panPartStart[i] <= psShape->panPartStart[i - 1]) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), - "Corrupted .shp file : shape %d : panPartStart[%d] = %d, panPartStart[%d] = %d", - hEntity, i, psShape->panPartStart[i], i - 1, psShape->panPartStart[i - 1]); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + "Corrupted .shp file : shape %d : panPartStart[%d] = " + "%d, panPartStart[%d] = %d", + hEntity, i, psShape->panPartStart[i], i - 1, + psShape->panPartStart[i - 1]); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } } - nOffset = 44 + 8 + 4*nParts; + int nOffset = 44 + 8 + 4 * nParts; -/* -------------------------------------------------------------------- */ -/* If this is a multipatch, we will also have parts types. */ -/* -------------------------------------------------------------------- */ - if( psShape->nSHPType == SHPT_MULTIPATCH ) + /* -------------------------------------------------------------------- */ + /* If this is a multipatch, we will also have parts types. */ + /* -------------------------------------------------------------------- */ + if (psShape->nSHPType == SHPT_MULTIPATCH) { - memcpy( psShape->panPartType, psSHP->pabyRec + nOffset, 4*nParts ); - for( i = 0; STATIC_CAST(int32, i) < nParts; i++ ) + memcpy(psShape->panPartType, psSHP->pabyRec + nOffset, 4 * nParts); + for (int i = 0; STATIC_CAST(uint32_t, i) < nParts; i++) { - if( bBigEndian ) SwapWord( 4, psShape->panPartType+i ); + if (bBigEndian) + SwapWord(4, psShape->panPartType + i); } - nOffset += 4*nParts; + nOffset += 4 * nParts; } -/* -------------------------------------------------------------------- */ -/* Copy out the vertices from the record. */ -/* -------------------------------------------------------------------- */ - for( i = 0; STATIC_CAST(int32, i) < nPoints; i++ ) + /* -------------------------------------------------------------------- */ + /* Copy out the vertices from the record. */ + /* -------------------------------------------------------------------- */ + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { - memcpy(psShape->padfX + i, - psSHP->pabyRec + nOffset + i * 16, - 8 ); + memcpy(psShape->padfX + i, psSHP->pabyRec + nOffset + i * 16, 8); - memcpy(psShape->padfY + i, - psSHP->pabyRec + nOffset + i * 16 + 8, - 8 ); + memcpy(psShape->padfY + i, psSHP->pabyRec + nOffset + i * 16 + 8, + 8); - if( bBigEndian ) SwapWord( 8, psShape->padfX + i ); - if( bBigEndian ) SwapWord( 8, psShape->padfY + i ); + if (bBigEndian) + SwapWord(8, psShape->padfX + i); + if (bBigEndian) + SwapWord(8, psShape->padfY + i); } - nOffset += 16*nPoints; + nOffset += 16 * nPoints; -/* -------------------------------------------------------------------- */ -/* If we have a Z coordinate, collect that now. */ -/* -------------------------------------------------------------------- */ - if( psShape->nSHPType == SHPT_POLYGONZ - || psShape->nSHPType == SHPT_ARCZ - || psShape->nSHPType == SHPT_MULTIPATCH ) + /* -------------------------------------------------------------------- */ + /* If we have a Z coordinate, collect that now. */ + /* -------------------------------------------------------------------- */ + if (psShape->nSHPType == SHPT_POLYGONZ || + psShape->nSHPType == SHPT_ARCZ || + psShape->nSHPType == SHPT_MULTIPATCH) { - memcpy( &(psShape->dfZMin), psSHP->pabyRec + nOffset, 8 ); - memcpy( &(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 ); + memcpy(&(psShape->dfZMin), psSHP->pabyRec + nOffset, 8); + memcpy(&(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8); - if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) ); + if (bBigEndian) + SwapWord(8, &(psShape->dfZMin)); + if (bBigEndian) + SwapWord(8, &(psShape->dfZMax)); - for( i = 0; STATIC_CAST(int32, i) < nPoints; i++ ) + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { - memcpy( psShape->padfZ + i, - psSHP->pabyRec + nOffset + 16 + i*8, 8 ); - if( bBigEndian ) SwapWord( 8, psShape->padfZ + i ); + memcpy(psShape->padfZ + i, + psSHP->pabyRec + nOffset + 16 + i * 8, 8); + if (bBigEndian) + SwapWord(8, psShape->padfZ + i); } - nOffset += 16 + 8*nPoints; + nOffset += 16 + 8 * nPoints; } - else if( psShape->bFastModeReadObject ) + else if (psShape->bFastModeReadObject) { psShape->padfZ = SHPLIB_NULLPTR; } -/* -------------------------------------------------------------------- */ -/* If we have a M measure value, then read it now. We assume */ -/* that the measure can be present for any shape if the size is */ -/* big enough, but really it will only occur for the Z shapes */ -/* (options), and the M shapes. */ -/* -------------------------------------------------------------------- */ - if( nEntitySize >= STATIC_CAST(int, nOffset + 16 + 8*nPoints) ) + /* -------------------------------------------------------------------- */ + /* If we have a M measure value, then read it now. We assume */ + /* that the measure can be present for any shape if the size is */ + /* big enough, but really it will only occur for the Z shapes */ + /* (options), and the M shapes. */ + /* -------------------------------------------------------------------- */ + if (nEntitySize >= STATIC_CAST(int, nOffset + 16 + 8 * nPoints)) { - memcpy( &(psShape->dfMMin), psSHP->pabyRec + nOffset, 8 ); - memcpy( &(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 ); + memcpy(&(psShape->dfMMin), psSHP->pabyRec + nOffset, 8); + memcpy(&(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8); - if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) ); + if (bBigEndian) + SwapWord(8, &(psShape->dfMMin)); + if (bBigEndian) + SwapWord(8, &(psShape->dfMMax)); - for( i = 0; STATIC_CAST(int32, i) < nPoints; i++ ) + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { - memcpy( psShape->padfM + i, - psSHP->pabyRec + nOffset + 16 + i*8, 8 ); - if( bBigEndian ) SwapWord( 8, psShape->padfM + i ); + memcpy(psShape->padfM + i, + psSHP->pabyRec + nOffset + 16 + i * 8, 8); + if (bBigEndian) + SwapWord(8, psShape->padfM + i); } psShape->bMeasureIsUsed = TRUE; } - else if( psShape->bFastModeReadObject ) + else if (psShape->bFastModeReadObject) { psShape->padfM = SHPLIB_NULLPTR; } } -/* ==================================================================== */ -/* Extract vertices for a MultiPoint. */ -/* ==================================================================== */ - else if( psShape->nSHPType == SHPT_MULTIPOINT - || psShape->nSHPType == SHPT_MULTIPOINTM - || psShape->nSHPType == SHPT_MULTIPOINTZ ) + /* ==================================================================== */ + /* Extract vertices for a MultiPoint. */ + /* ==================================================================== */ + else if (psShape->nSHPType == SHPT_MULTIPOINT || + psShape->nSHPType == SHPT_MULTIPOINTM || + psShape->nSHPType == SHPT_MULTIPOINTZ) { - int32 nPoints; - int i, nOffset; - unsigned char* pBuffer = SHPLIB_NULLPTR; - unsigned char** ppBuffer = SHPLIB_NULLPTR; - - if ( 44 + 4 > nEntitySize ) + if (44 + 4 > nEntitySize) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), "Corrupted .shp file : shape %d : nEntitySize = %d", hEntity, nEntitySize); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - memcpy( &nPoints, psSHP->pabyRec + 44, 4 ); + uint32_t nPoints; + memcpy(&nPoints, psSHP->pabyRec + 44, 4); - if( bBigEndian ) SwapWord( 4, &nPoints ); + if (bBigEndian) + SwapWord(4, &nPoints); /* nPoints is unsigned */ if (/* nPoints < 0 || */ nPoints > 50 * 1000 * 1000) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), - "Corrupted .shp file : shape %d : nPoints = %u", - hEntity, nPoints); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + "Corrupted .shp file : shape %d : nPoints = %u", hEntity, + nPoints); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - nRequiredSize = 48 + nPoints * 16; - if( psShape->nSHPType == SHPT_MULTIPOINTZ ) + int nRequiredSize = 48 + nPoints * 16; + if (psShape->nSHPType == SHPT_MULTIPOINTZ) { nRequiredSize += 16 + nPoints * 8; } if (nRequiredSize > nEntitySize) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), - "Corrupted .shp file : shape %d : nPoints = %u, nEntitySize = %d", + "Corrupted .shp file : shape %d : nPoints = %u, " + "nEntitySize = %d", hEntity, nPoints, nEntitySize); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - if( psShape->bFastModeReadObject ) + unsigned char *pBuffer = SHPLIB_NULLPTR; + unsigned char **ppBuffer = SHPLIB_NULLPTR; + + if (psShape->bFastModeReadObject) { - int nObjectBufSize = 4 * sizeof(double) * nPoints; + const int nObjectBufSize = 4 * sizeof(double) * nPoints; pBuffer = SHPReallocObjectBufIfNecessary(psSHP, nObjectBufSize); ppBuffer = &pBuffer; } psShape->nVertices = nPoints; - psShape->padfX = STATIC_CAST(double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); - psShape->padfY = STATIC_CAST(double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); - psShape->padfZ = STATIC_CAST(double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); - psShape->padfM = STATIC_CAST(double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); + psShape->padfX = STATIC_CAST( + double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); + psShape->padfY = STATIC_CAST( + double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); + psShape->padfZ = STATIC_CAST( + double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); + psShape->padfM = STATIC_CAST( + double *, SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints)); if (psShape->padfX == SHPLIB_NULLPTR || psShape->padfY == SHPLIB_NULLPTR || psShape->padfZ == SHPLIB_NULLPTR || psShape->padfM == SHPLIB_NULLPTR) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), - "Not enough memory to allocate requested memory (nPoints=%u) for shape %d. " - "Probably broken SHP file", nPoints, hEntity ); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + "Not enough memory to allocate requested memory " + "(nPoints=%u) for shape %d. " + "Probably broken SHP file", + nPoints, hEntity); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - for( i = 0; STATIC_CAST(int32, i) < nPoints; i++ ) + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { - memcpy(psShape->padfX+i, psSHP->pabyRec + 48 + 16 * i, 8 ); - memcpy(psShape->padfY+i, psSHP->pabyRec + 48 + 16 * i + 8, 8 ); + memcpy(psShape->padfX + i, psSHP->pabyRec + 48 + 16 * i, 8); + memcpy(psShape->padfY + i, psSHP->pabyRec + 48 + 16 * i + 8, 8); - if( bBigEndian ) SwapWord( 8, psShape->padfX + i ); - if( bBigEndian ) SwapWord( 8, psShape->padfY + i ); + if (bBigEndian) + SwapWord(8, psShape->padfX + i); + if (bBigEndian) + SwapWord(8, psShape->padfY + i); } - nOffset = 48 + 16*nPoints; + int nOffset = 48 + 16 * nPoints; -/* -------------------------------------------------------------------- */ -/* Get the X/Y bounds. */ -/* -------------------------------------------------------------------- */ - memcpy( &(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8 ); - memcpy( &(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 ); - memcpy( &(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 ); - memcpy( &(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 ); + /* -------------------------------------------------------------------- */ + /* Get the X/Y bounds. */ + /* -------------------------------------------------------------------- */ + memcpy(&(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8); + memcpy(&(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8); + memcpy(&(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8); + memcpy(&(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8); - if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) ); + if (bBigEndian) + SwapWord(8, &(psShape->dfXMin)); + if (bBigEndian) + SwapWord(8, &(psShape->dfYMin)); + if (bBigEndian) + SwapWord(8, &(psShape->dfXMax)); + if (bBigEndian) + SwapWord(8, &(psShape->dfYMax)); -/* -------------------------------------------------------------------- */ -/* If we have a Z coordinate, collect that now. */ -/* -------------------------------------------------------------------- */ - if( psShape->nSHPType == SHPT_MULTIPOINTZ ) + /* -------------------------------------------------------------------- */ + /* If we have a Z coordinate, collect that now. */ + /* -------------------------------------------------------------------- */ + if (psShape->nSHPType == SHPT_MULTIPOINTZ) { - memcpy( &(psShape->dfZMin), psSHP->pabyRec + nOffset, 8 ); - memcpy( &(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 ); + memcpy(&(psShape->dfZMin), psSHP->pabyRec + nOffset, 8); + memcpy(&(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8); - if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) ); + if (bBigEndian) + SwapWord(8, &(psShape->dfZMin)); + if (bBigEndian) + SwapWord(8, &(psShape->dfZMax)); - for( i = 0; STATIC_CAST(int32, i) < nPoints; i++ ) + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { - memcpy( psShape->padfZ + i, - psSHP->pabyRec + nOffset + 16 + i*8, 8 ); - if( bBigEndian ) SwapWord( 8, psShape->padfZ + i ); + memcpy(psShape->padfZ + i, + psSHP->pabyRec + nOffset + 16 + i * 8, 8); + if (bBigEndian) + SwapWord(8, psShape->padfZ + i); } - nOffset += 16 + 8*nPoints; + nOffset += 16 + 8 * nPoints; } - else if( psShape->bFastModeReadObject ) + else if (psShape->bFastModeReadObject) psShape->padfZ = SHPLIB_NULLPTR; -/* -------------------------------------------------------------------- */ -/* If we have a M measure value, then read it now. We assume */ -/* that the measure can be present for any shape if the size is */ -/* big enough, but really it will only occur for the Z shapes */ -/* (options), and the M shapes. */ -/* -------------------------------------------------------------------- */ - if( nEntitySize >= STATIC_CAST(int, nOffset + 16 + 8*nPoints) ) + /* -------------------------------------------------------------------- */ + /* If we have a M measure value, then read it now. We assume */ + /* that the measure can be present for any shape if the size is */ + /* big enough, but really it will only occur for the Z shapes */ + /* (options), and the M shapes. */ + /* -------------------------------------------------------------------- */ + if (nEntitySize >= STATIC_CAST(int, nOffset + 16 + 8 * nPoints)) { - memcpy( &(psShape->dfMMin), psSHP->pabyRec + nOffset, 8 ); - memcpy( &(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 ); + memcpy(&(psShape->dfMMin), psSHP->pabyRec + nOffset, 8); + memcpy(&(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8); - if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) ); - if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) ); + if (bBigEndian) + SwapWord(8, &(psShape->dfMMin)); + if (bBigEndian) + SwapWord(8, &(psShape->dfMMax)); - for( i = 0; STATIC_CAST(int32, i) < nPoints; i++ ) + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { - memcpy( psShape->padfM + i, - psSHP->pabyRec + nOffset + 16 + i*8, 8 ); - if( bBigEndian ) SwapWord( 8, psShape->padfM + i ); + memcpy(psShape->padfM + i, + psSHP->pabyRec + nOffset + 16 + i * 8, 8); + if (bBigEndian) + SwapWord(8, psShape->padfM + i); } psShape->bMeasureIsUsed = TRUE; } - else if( psShape->bFastModeReadObject ) + else if (psShape->bFastModeReadObject) psShape->padfM = SHPLIB_NULLPTR; } -/* ==================================================================== */ -/* Extract vertices for a point. */ -/* ==================================================================== */ - else if( psShape->nSHPType == SHPT_POINT - || psShape->nSHPType == SHPT_POINTM - || psShape->nSHPType == SHPT_POINTZ ) + /* ==================================================================== */ + /* Extract vertices for a point. */ + /* ==================================================================== */ + else if (psShape->nSHPType == SHPT_POINT || + psShape->nSHPType == SHPT_POINTM || + psShape->nSHPType == SHPT_POINTZ) { - int nOffset; - psShape->nVertices = 1; - if( psShape->bFastModeReadObject ) + if (psShape->bFastModeReadObject) { psShape->padfX = &(psShape->dfXMin); psShape->padfY = &(psShape->dfYMin); @@ -2741,123 +2638,126 @@ SHPReadObject( SHPHandle psSHP, int hEntity ) } else { - psShape->padfX = STATIC_CAST(double *, calloc(1,sizeof(double))); - psShape->padfY = STATIC_CAST(double *, calloc(1,sizeof(double))); - psShape->padfZ = STATIC_CAST(double *, calloc(1,sizeof(double))); - psShape->padfM = STATIC_CAST(double *, calloc(1,sizeof(double))); + psShape->padfX = STATIC_CAST(double *, calloc(1, sizeof(double))); + psShape->padfY = STATIC_CAST(double *, calloc(1, sizeof(double))); + psShape->padfZ = STATIC_CAST(double *, calloc(1, sizeof(double))); + psShape->padfM = STATIC_CAST(double *, calloc(1, sizeof(double))); } - if (20 + 8 + (( psShape->nSHPType == SHPT_POINTZ ) ? 8 : 0)> nEntitySize) + if (20 + 8 + ((psShape->nSHPType == SHPT_POINTZ) ? 8 : 0) > nEntitySize) { + char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), "Corrupted .shp file : shape %d : nEntitySize = %d", hEntity, nEntitySize); - szErrorMsg[sizeof(szErrorMsg)-1] = '\0'; - psSHP->sHooks.Error( szErrorMsg ); + szErrorMsg[sizeof(szErrorMsg) - 1] = '\0'; + psSHP->sHooks.Error(szErrorMsg); SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - memcpy( psShape->padfX, psSHP->pabyRec + 12, 8 ); - memcpy( psShape->padfY, psSHP->pabyRec + 20, 8 ); + memcpy(psShape->padfX, psSHP->pabyRec + 12, 8); + memcpy(psShape->padfY, psSHP->pabyRec + 20, 8); - if( bBigEndian ) SwapWord( 8, psShape->padfX ); - if( bBigEndian ) SwapWord( 8, psShape->padfY ); + if (bBigEndian) + SwapWord(8, psShape->padfX); + if (bBigEndian) + SwapWord(8, psShape->padfY); - nOffset = 20 + 8; + int nOffset = 20 + 8; -/* -------------------------------------------------------------------- */ -/* If we have a Z coordinate, collect that now. */ -/* -------------------------------------------------------------------- */ - if( psShape->nSHPType == SHPT_POINTZ ) + /* -------------------------------------------------------------------- */ + /* If we have a Z coordinate, collect that now. */ + /* -------------------------------------------------------------------- */ + if (psShape->nSHPType == SHPT_POINTZ) { - memcpy( psShape->padfZ, psSHP->pabyRec + nOffset, 8 ); + memcpy(psShape->padfZ, psSHP->pabyRec + nOffset, 8); - if( bBigEndian ) SwapWord( 8, psShape->padfZ ); + if (bBigEndian) + SwapWord(8, psShape->padfZ); nOffset += 8; } -/* -------------------------------------------------------------------- */ -/* If we have a M measure value, then read it now. We assume */ -/* that the measure can be present for any shape if the size is */ -/* big enough, but really it will only occur for the Z shapes */ -/* (options), and the M shapes. */ -/* -------------------------------------------------------------------- */ - if( nEntitySize >= nOffset + 8 ) + /* -------------------------------------------------------------------- */ + /* If we have a M measure value, then read it now. We assume */ + /* that the measure can be present for any shape if the size is */ + /* big enough, but really it will only occur for the Z shapes */ + /* (options), and the M shapes. */ + /* -------------------------------------------------------------------- */ + if (nEntitySize >= nOffset + 8) { - memcpy( psShape->padfM, psSHP->pabyRec + nOffset, 8 ); + memcpy(psShape->padfM, psSHP->pabyRec + nOffset, 8); - if( bBigEndian ) SwapWord( 8, psShape->padfM ); + if (bBigEndian) + SwapWord(8, psShape->padfM); psShape->bMeasureIsUsed = TRUE; } -/* -------------------------------------------------------------------- */ -/* Since no extents are supplied in the record, we will apply */ -/* them from the single vertex. */ -/* -------------------------------------------------------------------- */ + /* -------------------------------------------------------------------- */ + /* Since no extents are supplied in the record, we will apply */ + /* them from the single vertex. */ + /* -------------------------------------------------------------------- */ psShape->dfXMin = psShape->dfXMax = psShape->padfX[0]; psShape->dfYMin = psShape->dfYMax = psShape->padfY[0]; psShape->dfZMin = psShape->dfZMax = psShape->padfZ[0]; psShape->dfMMin = psShape->dfMMax = psShape->padfM[0]; } - return( psShape ); + return (psShape); } /************************************************************************/ /* SHPTypeName() */ /************************************************************************/ -const char SHPAPI_CALL1(*) -SHPTypeName( int nSHPType ) - +const char SHPAPI_CALL1(*) SHPTypeName(int nSHPType) { - switch( nSHPType ) + switch (nSHPType) { - case SHPT_NULL: - return "NullShape"; + case SHPT_NULL: + return "NullShape"; - case SHPT_POINT: - return "Point"; + case SHPT_POINT: + return "Point"; - case SHPT_ARC: - return "Arc"; + case SHPT_ARC: + return "Arc"; - case SHPT_POLYGON: - return "Polygon"; + case SHPT_POLYGON: + return "Polygon"; - case SHPT_MULTIPOINT: - return "MultiPoint"; + case SHPT_MULTIPOINT: + return "MultiPoint"; - case SHPT_POINTZ: - return "PointZ"; + case SHPT_POINTZ: + return "PointZ"; - case SHPT_ARCZ: - return "ArcZ"; + case SHPT_ARCZ: + return "ArcZ"; - case SHPT_POLYGONZ: - return "PolygonZ"; + case SHPT_POLYGONZ: + return "PolygonZ"; - case SHPT_MULTIPOINTZ: - return "MultiPointZ"; + case SHPT_MULTIPOINTZ: + return "MultiPointZ"; - case SHPT_POINTM: - return "PointM"; + case SHPT_POINTM: + return "PointM"; - case SHPT_ARCM: - return "ArcM"; + case SHPT_ARCM: + return "ArcM"; - case SHPT_POLYGONM: - return "PolygonM"; + case SHPT_POLYGONM: + return "PolygonM"; - case SHPT_MULTIPOINTM: - return "MultiPointM"; + case SHPT_MULTIPOINTM: + return "MultiPointM"; - case SHPT_MULTIPATCH: - return "MultiPatch"; + case SHPT_MULTIPATCH: + return "MultiPatch"; - default: - return "UnknownShapeType"; + default: + return "UnknownShapeType"; } } @@ -2865,32 +2765,30 @@ SHPTypeName( int nSHPType ) /* SHPPartTypeName() */ /************************************************************************/ -const char SHPAPI_CALL1(*) -SHPPartTypeName( int nPartType ) - +const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType) { - switch( nPartType ) + switch (nPartType) { - case SHPP_TRISTRIP: - return "TriangleStrip"; + case SHPP_TRISTRIP: + return "TriangleStrip"; - case SHPP_TRIFAN: - return "TriangleFan"; + case SHPP_TRIFAN: + return "TriangleFan"; - case SHPP_OUTERRING: - return "OuterRing"; + case SHPP_OUTERRING: + return "OuterRing"; - case SHPP_INNERRING: - return "InnerRing"; + case SHPP_INNERRING: + return "InnerRing"; - case SHPP_FIRSTRING: - return "FirstRing"; + case SHPP_FIRSTRING: + return "FirstRing"; - case SHPP_RING: - return "Ring"; + case SHPP_RING: + return "Ring"; - default: - return "UnknownPartType"; + default: + return "UnknownPartType"; } } @@ -2898,118 +2796,130 @@ SHPPartTypeName( int nPartType ) /* SHPDestroyObject() */ /************************************************************************/ -void SHPAPI_CALL -SHPDestroyObject( SHPObject * psShape ) - +void SHPAPI_CALL SHPDestroyObject(SHPObject *psShape) { - if( psShape == SHPLIB_NULLPTR ) + if (psShape == SHPLIB_NULLPTR) return; - if( psShape->bFastModeReadObject ) + if (psShape->bFastModeReadObject) { psShape->bFastModeReadObject = FALSE; return; } - if( psShape->padfX != SHPLIB_NULLPTR ) - free( psShape->padfX ); - if( psShape->padfY != SHPLIB_NULLPTR ) - free( psShape->padfY ); - if( psShape->padfZ != SHPLIB_NULLPTR ) - free( psShape->padfZ ); - if( psShape->padfM != SHPLIB_NULLPTR ) - free( psShape->padfM ); + if (psShape->padfX != SHPLIB_NULLPTR) + free(psShape->padfX); + if (psShape->padfY != SHPLIB_NULLPTR) + free(psShape->padfY); + if (psShape->padfZ != SHPLIB_NULLPTR) + free(psShape->padfZ); + if (psShape->padfM != SHPLIB_NULLPTR) + free(psShape->padfM); - if( psShape->panPartStart != SHPLIB_NULLPTR ) - free( psShape->panPartStart ); - if( psShape->panPartType != SHPLIB_NULLPTR ) - free( psShape->panPartType ); + if (psShape->panPartStart != SHPLIB_NULLPTR) + free(psShape->panPartStart); + if (psShape->panPartType != SHPLIB_NULLPTR) + free(psShape->panPartType); - free( psShape ); + free(psShape); } /************************************************************************/ /* SHPGetPartVertexCount() */ /************************************************************************/ -static int SHPGetPartVertexCount( const SHPObject * psObject, int iPart ) +static int SHPGetPartVertexCount(const SHPObject *psObject, int iPart) { - if( iPart == psObject->nParts-1 ) + if (iPart == psObject->nParts - 1) return psObject->nVertices - psObject->panPartStart[iPart]; else - return psObject->panPartStart[iPart+1] - psObject->panPartStart[iPart]; + return psObject->panPartStart[iPart + 1] - + psObject->panPartStart[iPart]; } /************************************************************************/ /* SHPRewindIsInnerRing() */ /************************************************************************/ -static int SHPRewindIsInnerRing( const SHPObject * psObject, - int iOpRing ) +/* Return -1 in case of ambiguity */ +static int SHPRewindIsInnerRing(const SHPObject *psObject, int iOpRing, + double dfTestX, double dfTestY, + double dfRelativeTolerance, int bSameZ, + double dfTestZ) { -/* -------------------------------------------------------------------- */ -/* Determine if this ring is an inner ring or an outer ring */ -/* relative to all the other rings. For now we assume the */ -/* first ring is outer and all others are inner, but eventually */ -/* we need to fix this to handle multiple island polygons and */ -/* unordered sets of rings. */ -/* */ -/* -------------------------------------------------------------------- */ - - /* Use point in the middle of segment to avoid testing - * common points of rings. - */ - const int iOpRingStart = psObject->panPartStart[iOpRing]; - double dfTestX = ( psObject->padfX[iOpRingStart] + - psObject->padfX[iOpRingStart + 1] ) / 2; - double dfTestY = ( psObject->padfY[iOpRingStart] + - psObject->padfY[iOpRingStart + 1] ) / 2; - - int bInner = FALSE; - int iCheckRing; - for( iCheckRing = 0; iCheckRing < psObject->nParts; iCheckRing++ ) - { - int nVertStartCheck, nVertCountCheck; - int iEdge; - - if( iCheckRing == iOpRing ) + /* -------------------------------------------------------------------- */ + /* Determine if this ring is an inner ring or an outer ring */ + /* relative to all the other rings. For now we assume the */ + /* first ring is outer and all others are inner, but eventually */ + /* we need to fix this to handle multiple island polygons and */ + /* unordered sets of rings. */ + /* */ + /* -------------------------------------------------------------------- */ + + bool bInner = false; + for (int iCheckRing = 0; iCheckRing < psObject->nParts; iCheckRing++) + { + if (iCheckRing == iOpRing) continue; - nVertStartCheck = psObject->panPartStart[iCheckRing]; - nVertCountCheck = SHPGetPartVertexCount(psObject, iCheckRing); + const int nVertStartCheck = psObject->panPartStart[iCheckRing]; + const int nVertCountCheck = SHPGetPartVertexCount(psObject, iCheckRing); - for( iEdge = 0; iEdge < nVertCountCheck; iEdge++ ) + /* Ignore rings that don't have the same (constant) Z value as the + * point. */ + /* As noted in SHPRewindObject(), this is a simplification */ + /* of what we should ideally do. */ + if (!bSameZ) { - int iNext; + int bZTestOK = TRUE; + for (int iVert = nVertStartCheck + 1; + iVert < nVertStartCheck + nVertCountCheck; ++iVert) + { + if (psObject->padfZ[iVert] != dfTestZ) + { + bZTestOK = FALSE; + break; + } + } + if (!bZTestOK) + continue; + } - if( iEdge < nVertCountCheck-1 ) - iNext = iEdge+1; + for (int iEdge = 0; iEdge < nVertCountCheck; iEdge++) + { + int iNext; + if (iEdge < nVertCountCheck - 1) + iNext = iEdge + 1; else iNext = 0; + const double y0 = psObject->padfY[iEdge + nVertStartCheck]; + const double y1 = psObject->padfY[iNext + nVertStartCheck]; /* Rule #1: * Test whether the edge 'straddles' the horizontal ray from * the test point (dfTestY,dfTestY) * The rule #1 also excludes edges colinear with the ray. */ - if ( ( psObject->padfY[iEdge+nVertStartCheck] < dfTestY - && dfTestY <= psObject->padfY[iNext+nVertStartCheck] ) - || ( psObject->padfY[iNext+nVertStartCheck] < dfTestY - && dfTestY <= psObject->padfY[iEdge+nVertStartCheck] ) ) + if ((y0 < dfTestY && dfTestY <= y1) || + (y1 < dfTestY && dfTestY <= y0)) { /* Rule #2: * Test if edge-ray intersection is on the right from the * test point (dfTestY,dfTestY) */ - double const intersect = - ( psObject->padfX[iEdge+nVertStartCheck] - + ( dfTestY - psObject->padfY[iEdge+nVertStartCheck] ) - / ( psObject->padfY[iNext+nVertStartCheck] - - psObject->padfY[iEdge+nVertStartCheck] ) - * ( psObject->padfX[iNext+nVertStartCheck] - - psObject->padfX[iEdge+nVertStartCheck] ) ); - - if (intersect < dfTestX) + const double x0 = psObject->padfX[iEdge + nVertStartCheck]; + const double x1 = psObject->padfX[iNext + nVertStartCheck]; + const double intersect_minus_testX = + (x0 - dfTestX) + (dfTestY - y0) / (y1 - y0) * (x1 - x0); + + if (fabs(intersect_minus_testX) <= + dfRelativeTolerance * fabs(dfTestX)) + { + /* Potential shared edge, or slightly overlapping polygons + */ + return -1; + } + else if (intersect_minus_testX < 0) { bInner = !bInner; } @@ -3026,96 +2936,169 @@ static int SHPRewindIsInnerRing( const SHPObject * psObject, /* specification. */ /************************************************************************/ -int SHPAPI_CALL -SHPRewindObject( CPL_UNUSED SHPHandle hSHP, - SHPObject * psObject ) +int SHPAPI_CALL SHPRewindObject(CPL_UNUSED SHPHandle hSHP, SHPObject *psObject) { - int iOpRing, bAltered = 0; - -/* -------------------------------------------------------------------- */ -/* Do nothing if this is not a polygon object. */ -/* -------------------------------------------------------------------- */ - if( psObject->nSHPType != SHPT_POLYGON - && psObject->nSHPType != SHPT_POLYGONZ - && psObject->nSHPType != SHPT_POLYGONM ) + /* -------------------------------------------------------------------- */ + /* Do nothing if this is not a polygon object. */ + /* -------------------------------------------------------------------- */ + if (psObject->nSHPType != SHPT_POLYGON && + psObject->nSHPType != SHPT_POLYGONZ && + psObject->nSHPType != SHPT_POLYGONM) return 0; - if( psObject->nVertices == 0 || psObject->nParts == 0 ) + if (psObject->nVertices == 0 || psObject->nParts == 0) return 0; -/* -------------------------------------------------------------------- */ -/* Process each of the rings. */ -/* -------------------------------------------------------------------- */ - for( iOpRing = 0; iOpRing < psObject->nParts; iOpRing++ ) + /* -------------------------------------------------------------------- */ + /* Test if all points have the same Z value. */ + /* -------------------------------------------------------------------- */ + int bSameZ = TRUE; + if (psObject->nSHPType == SHPT_POLYGONZ || + psObject->nSHPType == SHPT_POLYGONM) { - int bInner, iVert, nVertCount, nVertStart; - double dfSum; + for (int iVert = 1; iVert < psObject->nVertices; ++iVert) + { + if (psObject->padfZ[iVert] != psObject->padfZ[0]) + { + bSameZ = FALSE; + break; + } + } + } - nVertStart = psObject->panPartStart[iOpRing]; - nVertCount = SHPGetPartVertexCount(psObject, iOpRing); + /* -------------------------------------------------------------------- */ + /* Process each of the rings. */ + /* -------------------------------------------------------------------- */ + int bAltered = 0; + for (int iOpRing = 0; iOpRing < psObject->nParts; iOpRing++) + { + const int nVertStart = psObject->panPartStart[iOpRing]; + const int nVertCount = SHPGetPartVertexCount(psObject, iOpRing); if (nVertCount < 2) continue; - bInner = SHPRewindIsInnerRing(psObject, iOpRing); - -/* -------------------------------------------------------------------- */ -/* Determine the current order of this ring so we will know if */ -/* it has to be reversed. */ -/* -------------------------------------------------------------------- */ + /* If a ring has a non-constant Z value, then consider it as an outer */ + /* ring. */ + /* NOTE: this is a rough approximation. If we were smarter, */ + /* we would check that all points of the ring are coplanar, and compare + */ + /* that to other rings in the same (oblique) plane. */ + int bDoIsInnerRingTest = TRUE; + if (!bSameZ) + { + int bPartSameZ = TRUE; + for (int iVert = nVertStart + 1; iVert < nVertStart + nVertCount; + ++iVert) + { + if (psObject->padfZ[iVert] != psObject->padfZ[nVertStart]) + { + bPartSameZ = FALSE; + break; + } + } + if (!bPartSameZ) + bDoIsInnerRingTest = FALSE; + } - dfSum = psObject->padfX[nVertStart] * - (psObject->padfY[nVertStart+1] - - psObject->padfY[nVertStart+nVertCount-1]); - for( iVert = nVertStart + 1; iVert < nVertStart+nVertCount-1; iVert++ ) + int bInner = FALSE; + if (bDoIsInnerRingTest) { - dfSum += psObject->padfX[iVert] * (psObject->padfY[iVert+1] - - psObject->padfY[iVert-1]); + for (int iTolerance = 0; iTolerance < 2; iTolerance++) + { + /* In a first attempt, use a relaxed criterion to decide if a + * point */ + /* is inside another ring. If all points of the current ring are + * in the */ + /* "grey" zone w.r.t that criterion, which seems really + * unlikely, */ + /* then use the strict criterion for another pass. */ + const double dfRelativeTolerance = (iTolerance == 0) ? 1e-9 : 0; + for (int iVert = nVertStart; + iVert + 1 < nVertStart + nVertCount; ++iVert) + { + /* Use point in the middle of segment to avoid testing + * common points of rings. + */ + const double dfTestX = + (psObject->padfX[iVert] + psObject->padfX[iVert + 1]) / + 2; + const double dfTestY = + (psObject->padfY[iVert] + psObject->padfY[iVert + 1]) / + 2; + const double dfTestZ = + !bSameZ ? psObject->padfZ[nVertStart] : 0; + + bInner = SHPRewindIsInnerRing(psObject, iOpRing, dfTestX, + dfTestY, dfRelativeTolerance, + bSameZ, dfTestZ); + if (bInner >= 0) + break; + } + if (bInner >= 0) + break; + } + if (bInner < 0) + { + /* Completely degenerate case. Do not bother touching order. */ + continue; + } } - dfSum += psObject->padfX[iVert] * (psObject->padfY[nVertStart] - - psObject->padfY[iVert-1]); + /* -------------------------------------------------------------------- */ + /* Determine the current order of this ring so we will know if */ + /* it has to be reversed. */ + /* -------------------------------------------------------------------- */ -/* -------------------------------------------------------------------- */ -/* Reverse if necessary. */ -/* -------------------------------------------------------------------- */ - if( (dfSum < 0.0 && bInner) || (dfSum > 0.0 && !bInner) ) + double dfSum = psObject->padfX[nVertStart] * + (psObject->padfY[nVertStart + 1] - + psObject->padfY[nVertStart + nVertCount - 1]); + int iVert = nVertStart + 1; + for (; iVert < nVertStart + nVertCount - 1; iVert++) { - int i; + dfSum += psObject->padfX[iVert] * + (psObject->padfY[iVert + 1] - psObject->padfY[iVert - 1]); + } + dfSum += psObject->padfX[iVert] * + (psObject->padfY[nVertStart] - psObject->padfY[iVert - 1]); + + /* -------------------------------------------------------------------- */ + /* Reverse if necessary. */ + /* -------------------------------------------------------------------- */ + if ((dfSum < 0.0 && bInner) || (dfSum > 0.0 && !bInner)) + { bAltered++; - for( i = 0; i < nVertCount/2; i++ ) + for (int i = 0; i < nVertCount / 2; i++) { - double dfSaved; - /* Swap X */ - dfSaved = psObject->padfX[nVertStart+i]; - psObject->padfX[nVertStart+i] = - psObject->padfX[nVertStart+nVertCount-i-1]; - psObject->padfX[nVertStart+nVertCount-i-1] = dfSaved; + double dfSaved = psObject->padfX[nVertStart + i]; + psObject->padfX[nVertStart + i] = + psObject->padfX[nVertStart + nVertCount - i - 1]; + psObject->padfX[nVertStart + nVertCount - i - 1] = dfSaved; /* Swap Y */ - dfSaved = psObject->padfY[nVertStart+i]; - psObject->padfY[nVertStart+i] = - psObject->padfY[nVertStart+nVertCount-i-1]; - psObject->padfY[nVertStart+nVertCount-i-1] = dfSaved; + dfSaved = psObject->padfY[nVertStart + i]; + psObject->padfY[nVertStart + i] = + psObject->padfY[nVertStart + nVertCount - i - 1]; + psObject->padfY[nVertStart + nVertCount - i - 1] = dfSaved; /* Swap Z */ - if( psObject->padfZ ) + if (psObject->padfZ) { - dfSaved = psObject->padfZ[nVertStart+i]; - psObject->padfZ[nVertStart+i] = - psObject->padfZ[nVertStart+nVertCount-i-1]; - psObject->padfZ[nVertStart+nVertCount-i-1] = dfSaved; + dfSaved = psObject->padfZ[nVertStart + i]; + psObject->padfZ[nVertStart + i] = + psObject->padfZ[nVertStart + nVertCount - i - 1]; + psObject->padfZ[nVertStart + nVertCount - i - 1] = dfSaved; } /* Swap M */ - if( psObject->padfM ) + if (psObject->padfM) { - dfSaved = psObject->padfM[nVertStart+i]; - psObject->padfM[nVertStart+i] = - psObject->padfM[nVertStart+nVertCount-i-1]; - psObject->padfM[nVertStart+nVertCount-i-1] = dfSaved; + dfSaved = psObject->padfM[nVertStart + i]; + psObject->padfM[nVertStart + i] = + psObject->padfM[nVertStart + nVertCount - i - 1]; + psObject->padfM[nVertStart + nVertCount - i - 1] = dfSaved; } } } From 1410fc5bd5630e20f93aadc82c2e226112042a72 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:57:17 -0700 Subject: [PATCH 067/132] update zlib to 1.3.1 (#1258) * update zlib to 1.3.1 * delete extra zlib files --- zlib/ChangeLog | 30 +- zlib/FAQ | 5 +- zlib/Makefile.in | 404 -------------- zlib/README | 19 +- zlib/README.gpsbabel | 4 +- zlib/adler32.c | 32 +- zlib/algorithm.txt | 2 +- zlib/compress.c | 21 +- zlib/contrib/minizip/Makefile | 2 +- zlib/contrib/minizip/MiniZip64_Changes.txt | 2 +- zlib/contrib/minizip/configure.ac | 2 +- zlib/contrib/minizip/crypt.h | 12 +- zlib/contrib/minizip/ioapi.c | 62 +-- zlib/contrib/minizip/ioapi.c.patch | 11 - zlib/contrib/minizip/ioapi.h | 38 +- zlib/contrib/minizip/iowin32.c | 65 +-- zlib/contrib/minizip/iowin32.h | 8 +- zlib/contrib/minizip/miniunz.c | 88 ++- zlib/contrib/minizip/minizip.c | 60 +- zlib/contrib/minizip/mztools.c | 8 +- zlib/contrib/minizip/unzip.c | 523 +++++++----------- zlib/contrib/minizip/unzip.h | 138 ++--- zlib/contrib/minizip/zip.c | 336 +++++------ zlib/contrib/minizip/zip.h | 303 +++++----- zlib/crc32.c | 248 +++------ zlib/deflate.c | 612 +++++++++------------ zlib/deflate.h | 51 +- zlib/gzclose.c | 4 +- zlib/gzguts.h | 31 +- zlib/gzlib.c | 113 +--- zlib/gzread.c | 88 +-- zlib/gzwrite.c | 84 +-- zlib/infback.c | 30 +- zlib/inffast.c | 5 +- zlib/inffast.h | 2 +- zlib/inflate.c | 131 ++--- zlib/inftrees.c | 17 +- zlib/inftrees.h | 10 +- zlib/resync_zlib | 16 +- zlib/trees.c | 542 ++++++++---------- zlib/uncompr.c | 16 +- zlib/zconf.h | 18 +- zlib/zconf.h.in | 547 ------------------ zlib/zlib.3 | 6 +- zlib/zlib.h | 391 ++++++------- zlib/zutil.c | 60 +- zlib/zutil.h | 47 +- 47 files changed, 1745 insertions(+), 3499 deletions(-) delete mode 100644 zlib/Makefile.in delete mode 100644 zlib/contrib/minizip/ioapi.c.patch delete mode 100644 zlib/zconf.h.in diff --git a/zlib/ChangeLog b/zlib/ChangeLog index 457526bc6..b801a1031 100644 --- a/zlib/ChangeLog +++ b/zlib/ChangeLog @@ -1,6 +1,34 @@ ChangeLog file for zlib +Changes in 1.3.1 (22 Jan 2024) +- Reject overflows of zip header fields in minizip +- Fix bug in inflateSync() for data held in bit buffer +- Add LIT_MEM define to use more memory for a small deflate speedup +- Fix decision on the emission of Zip64 end records in minizip +- Add bounds checking to ERR_MSG() macro, used by zError() +- Neutralize zip file traversal attacks in miniunz +- Fix a bug in ZLIB_DEBUG compiles in check_match() +- Various portability and appearance improvements + +Changes in 1.3 (18 Aug 2023) +- Remove K&R function definitions and zlib2ansi +- Fix bug in deflateBound() for level 0 and memLevel 9 +- Fix bug when gzungetc() is used immediately after gzopen() +- Fix bug when using gzflush() with a very small buffer +- Fix crash when gzsetparams() attempted for transparent write +- Fix test/example.c to work with FORCE_STORED +- Rewrite of zran in examples (see zran.c version history) +- Fix minizip to allow it to open an empty zip file +- Fix reading disk number start on zip64 files in minizip +- Fix logic error in minizip argument processing +- Add minizip testing to Makefile +- Read multiple bytes instead of byte-by-byte in minizip unzip.c +- Add memory sanitizer to configure (--memory) +- Various portability improvements +- Various documentation improvements +- Various spelling and typo corrections + Changes in 1.2.13 (13 Oct 2022) - Fix configure issue that discarded provided CC definition - Correct incorrect inputs provided to the CRC functions @@ -1445,7 +1473,7 @@ Changes in 0.99 (27 Jan 96) - fix typo in Make_vms.com (f$trnlnm -> f$getsyi) - in fcalloc, normalize pointer if size > 65520 bytes - don't use special fcalloc for 32 bit Borland C++ -- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... +- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc. - use Z_BINARY instead of BINARY - document that gzclose after gzdopen will close the file - allow "a" as mode in gzopen diff --git a/zlib/FAQ b/zlib/FAQ index 99b7cf92e..92f5d3e29 100644 --- a/zlib/FAQ +++ b/zlib/FAQ @@ -4,7 +4,7 @@ If your question is not there, please check the zlib home page http://zlib.net/ which may have more recent information. -The lastest zlib FAQ is at http://zlib.net/zlib_faq.html +The latest zlib FAQ is at http://zlib.net/zlib_faq.html 1. Is zlib Y2K-compliant? @@ -14,8 +14,7 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html 2. Where can I get a Windows DLL version? The zlib sources can be compiled without change to produce a DLL. See the - file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the - precompiled DLL are found in the zlib web site at http://zlib.net/ . + file win32/DLL_FAQ.txt in the zlib distribution. 3. Where can I get a Visual Basic interface to zlib? diff --git a/zlib/Makefile.in b/zlib/Makefile.in deleted file mode 100644 index 7d2713f4c..000000000 --- a/zlib/Makefile.in +++ /dev/null @@ -1,404 +0,0 @@ -# Makefile for zlib -# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile and test, type: -# ./configure; make test -# Normally configure builds both a static and a shared library. -# If you want to build just a static library, use: ./configure --static - -# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: -# make install -# To install in $HOME instead of /usr/local, use: -# make install prefix=$HOME - -CC=cc - -CFLAGS=-O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-g -DZLIB_DEBUG -#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -# -Wstrict-prototypes -Wmissing-prototypes - -SFLAGS=-O -LDFLAGS= -TEST_LDFLAGS=$(LDFLAGS) -L. libz.a -LDSHARED=$(CC) -CPP=$(CC) -E - -STATICLIB=libz.a -SHAREDLIB=libz.so -SHAREDLIBV=libz.so.1.2.13 -SHAREDLIBM=libz.so.1 -LIBS=$(STATICLIB) $(SHAREDLIBV) - -AR=ar -ARFLAGS=rc -RANLIB=ranlib -LDCONFIG=ldconfig -LDSHAREDLIBC=-lc -TAR=tar -SHELL=/bin/sh -EXE= - -prefix = /usr/local -exec_prefix = ${prefix} -libdir = ${exec_prefix}/lib -sharedlibdir = ${libdir} -includedir = ${prefix}/include -mandir = ${prefix}/share/man -man3dir = ${mandir}/man3 -pkgconfigdir = ${libdir}/pkgconfig -SRCDIR= -ZINC= -ZINCOUT=-I. - -OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o -OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o -OBJC = $(OBJZ) $(OBJG) - -PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo -PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo -PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG) - -# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo -OBJA = -PIC_OBJA = - -OBJS = $(OBJC) $(OBJA) - -PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA) - -all: static shared - -static: example$(EXE) minigzip$(EXE) - -shared: examplesh$(EXE) minigzipsh$(EXE) - -all64: example64$(EXE) minigzip64$(EXE) - -check: test - -test: all teststatic testshared - -teststatic: static - @TMPST=tmpst_$$; \ - if echo hello world | ${QEMU_RUN} ./minigzip | ${QEMU_RUN} ./minigzip -d && ${QEMU_RUN} ./example $$TMPST ; then \ - echo ' *** zlib test OK ***'; \ - else \ - echo ' *** zlib test FAILED ***'; false; \ - fi - @rm -f tmpst_$$ - -testshared: shared - @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ - LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ - DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ - SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ - TMPSH=tmpsh_$$; \ - if echo hello world | ${QEMU_RUN} ./minigzipsh | ${QEMU_RUN} ./minigzipsh -d && ${QEMU_RUN} ./examplesh $$TMPSH; then \ - echo ' *** zlib shared test OK ***'; \ - else \ - echo ' *** zlib shared test FAILED ***'; false; \ - fi - @rm -f tmpsh_$$ - -test64: all64 - @TMP64=tmp64_$$; \ - if echo hello world | ${QEMU_RUN} ./minigzip64 | ${QEMU_RUN} ./minigzip64 -d && ${QEMU_RUN} ./example64 $$TMP64; then \ - echo ' *** zlib 64-bit test OK ***'; \ - else \ - echo ' *** zlib 64-bit test FAILED ***'; false; \ - fi - @rm -f tmp64_$$ - -infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c - -infcover: infcover.o libz.a - $(CC) $(CFLAGS) -o $@ infcover.o libz.a - -cover: infcover - rm -f *.gcda - ${QEMU_RUN} ./infcover - gcov inf*.c - -libz.a: $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) - -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 - -match.o: match.S - $(CPP) match.S > _match.s - $(CC) -c _match.s - mv _match.o match.o - rm -f _match.s - -match.lo: match.S - $(CPP) match.S > _match.s - $(CC) -c -fPIC _match.s - mv _match.o match.lo - rm -f _match.s - -example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c - -minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/minigzip.c - -example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/example.c - -minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/minigzip.c - - -adler32.o: $(SRCDIR)adler32.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c - -crc32.o: $(SRCDIR)crc32.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c - -deflate.o: $(SRCDIR)deflate.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c - -infback.o: $(SRCDIR)infback.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c - -inffast.o: $(SRCDIR)inffast.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c - -inflate.o: $(SRCDIR)inflate.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c - -inftrees.o: $(SRCDIR)inftrees.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c - -trees.o: $(SRCDIR)trees.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c - -zutil.o: $(SRCDIR)zutil.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c - -compress.o: $(SRCDIR)compress.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c - -uncompr.o: $(SRCDIR)uncompr.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c - -gzclose.o: $(SRCDIR)gzclose.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzclose.c - -gzlib.o: $(SRCDIR)gzlib.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzlib.c - -gzread.o: $(SRCDIR)gzread.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzread.c - -gzwrite.o: $(SRCDIR)gzwrite.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c - - -adler32.lo: $(SRCDIR)adler32.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/adler32.o $(SRCDIR)adler32.c - -@mv objs/adler32.o $@ - -crc32.lo: $(SRCDIR)crc32.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/crc32.o $(SRCDIR)crc32.c - -@mv objs/crc32.o $@ - -deflate.lo: $(SRCDIR)deflate.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate.o $(SRCDIR)deflate.c - -@mv objs/deflate.o $@ - -infback.lo: $(SRCDIR)infback.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/infback.o $(SRCDIR)infback.c - -@mv objs/infback.o $@ - -inffast.lo: $(SRCDIR)inffast.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inffast.o $(SRCDIR)inffast.c - -@mv objs/inffast.o $@ - -inflate.lo: $(SRCDIR)inflate.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inflate.o $(SRCDIR)inflate.c - -@mv objs/inflate.o $@ - -inftrees.lo: $(SRCDIR)inftrees.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inftrees.o $(SRCDIR)inftrees.c - -@mv objs/inftrees.o $@ - -trees.lo: $(SRCDIR)trees.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c - -@mv objs/trees.o $@ - -zutil.lo: $(SRCDIR)zutil.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c - -@mv objs/zutil.o $@ - -compress.lo: $(SRCDIR)compress.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/compress.o $(SRCDIR)compress.c - -@mv objs/compress.o $@ - -uncompr.lo: $(SRCDIR)uncompr.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/uncompr.o $(SRCDIR)uncompr.c - -@mv objs/uncompr.o $@ - -gzclose.lo: $(SRCDIR)gzclose.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzclose.o $(SRCDIR)gzclose.c - -@mv objs/gzclose.o $@ - -gzlib.lo: $(SRCDIR)gzlib.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzlib.o $(SRCDIR)gzlib.c - -@mv objs/gzlib.o $@ - -gzread.lo: $(SRCDIR)gzread.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzread.o $(SRCDIR)gzread.c - -@mv objs/gzread.o $@ - -gzwrite.lo: $(SRCDIR)gzwrite.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c - -@mv objs/gzwrite.o $@ - - -placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a - $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) - rm -f $(SHAREDLIB) $(SHAREDLIBM) - ln -s $@ $(SHAREDLIB) - ln -s $@ $(SHAREDLIBM) - -@rmdir objs - -example$(EXE): example.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) - -minigzip$(EXE): minigzip.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) - -examplesh$(EXE): example.o $(SHAREDLIBV) - $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV) - -minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) - $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV) - -example64$(EXE): example64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) - -minigzip64$(EXE): minigzip64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) - -install-libs: $(LIBS) - -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi - -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi - -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi - -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi - -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi - rm -f $(DESTDIR)$(libdir)/$(STATICLIB) - cp $(STATICLIB) $(DESTDIR)$(libdir) - chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB) - -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1 - -@if test -n "$(SHAREDLIBV)"; then \ - rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ - cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \ - echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \ - chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ - echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \ - rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ - ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \ - ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ - ($(LDCONFIG) || true) >/dev/null 2>&1; \ - fi - rm -f $(DESTDIR)$(man3dir)/zlib.3 - cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir) - chmod 644 $(DESTDIR)$(man3dir)/zlib.3 - rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc - cp zlib.pc $(DESTDIR)$(pkgconfigdir) - chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc -# The ranlib in install is needed on NeXTSTEP which checks file times -# ldconfig is for Linux - -install: install-libs - -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi - rm -f $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h - cp $(SRCDIR)zlib.h zconf.h $(DESTDIR)$(includedir) - chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h - -uninstall: - cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h - cd $(DESTDIR)$(libdir) && rm -f libz.a; \ - if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ - rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ - fi - cd $(DESTDIR)$(man3dir) && rm -f zlib.3 - cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc - -docs: zlib.3.pdf - -zlib.3.pdf: $(SRCDIR)zlib.3 - groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@ - -zconf.h.cmakein: $(SRCDIR)zconf.h.in - -@ TEMPFILE=zconfh_$$; \ - echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\ - sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\ - touch -r $(SRCDIR)zconf.h.in $@ &&\ - rm $$TEMPFILE - -zconf: $(SRCDIR)zconf.h.in - cp -p $(SRCDIR)zconf.h.in zconf.h - -mostlyclean: clean -clean: - rm -f *.o *.lo *~ \ - example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ - example64$(EXE) minigzip64$(EXE) \ - infcover \ - libz.* foo.gz so_locations \ - _match.s maketree contrib/infback9/*.o - rm -rf objs - rm -f *.gcda *.gcno *.gcov - rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov - -maintainer-clean: distclean -distclean: clean zconf zconf.h.cmakein - rm -f Makefile zlib.pc configure.log - -@rm -f .DS_Store - @if [ -f Makefile.in ]; then \ - printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \ - printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \ - touch -r $(SRCDIR)Makefile.in Makefile ; fi - -tags: - etags $(SRCDIR)*.[ch] - -adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h -gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h -compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h -crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h -deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h -infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h -inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h -inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h -trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h - -adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h -gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h -compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h -crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h -deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h -infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h -inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h -inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h -trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h diff --git a/zlib/README b/zlib/README index ba34d1894..c5f917540 100644 --- a/zlib/README +++ b/zlib/README @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.13 is a general purpose data compression library. All the code is +zlib 1.3.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and @@ -29,18 +29,17 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at -http://marknelson.us/1997/01/01/zlib-engine/ . +https://marknelson.us/posts/1997/01/01/zlib-engine.html . -The changes made in version 1.2.13 are documented in the file ChangeLog. +The changes made in version 1.3.1 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . -zlib is available in Java using the java.util.zip package, documented at -http://java.sun.com/developer/technicalArticles/Programming/compression/ . +zlib is available in Java using the java.util.zip package. Follow the API +Documentation link at: https://docs.oracle.com/search/?q=java.util.zip . -A Perl interface to zlib written by Paul Marquess is available -at CPAN (Comprehensive Perl Archive Network) sites, including -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . +A Perl interface to zlib and bzip2 written by Paul Marquess +can be found at https://github.com/pmqs/IO-Compress . A Python interface to zlib written by A.M. Kuchling is available in Python 1.5 and later versions, see @@ -64,7 +63,7 @@ Notes for some targets: - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works when compiled with cc. -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is +- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is necessary to get gzprintf working correctly. This is done by configure. - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with @@ -84,7 +83,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2022 Jean-loup Gailly and Mark Adler + (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/zlib/README.gpsbabel b/zlib/README.gpsbabel index 89f60f9f8..ca73a1031 100644 --- a/zlib/README.gpsbabel +++ b/zlib/README.gpsbabel @@ -1,5 +1,3 @@ -modified subset of zlib-1.2.13 from zlib.net. +modified subset of zlib-1.3.1 from zlib.net. note that zlib 1.2.8 has a seek bug that will bite us. other changes after zlib 1.2.8 may be required as well. -1. contrib/minizip/ioapi.c modifies a conditional adding __CYGWIN__ -See the corresponding .patch files. diff --git a/zlib/adler32.c b/zlib/adler32.c index d0be4380a..04b81d29b 100644 --- a/zlib/adler32.c +++ b/zlib/adler32.c @@ -7,8 +7,6 @@ #include "zutil.h" -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); - #define BASE 65521U /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); #endif /* ========================================================================= */ -uLong ZEXPORT adler32_z(adler, buf, len) - uLong adler; - const Bytef *buf; - z_size_t len; -{ +uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { unsigned long sum2; unsigned n; @@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len) } /* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { return adler32_z(adler, buf, len); } /* ========================================================================= */ -local uLong adler32_combine_(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { unsigned long sum1; unsigned long sum2; unsigned rem; @@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2) } /* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ +uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) { return adler32_combine_(adler1, adler2, len2); } -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ +uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) { return adler32_combine_(adler1, adler2, len2); } diff --git a/zlib/algorithm.txt b/zlib/algorithm.txt index c97f49502..029e5a313 100644 --- a/zlib/algorithm.txt +++ b/zlib/algorithm.txt @@ -77,7 +77,7 @@ table took no time (and if you had infinite memory), then there would only be a first level table to cover all the way to the longest code. However, building the table ends up taking a lot longer for more bits since short codes are replicated many times in such a table. What inflate() does is -simply to make the number of bits in the first table a variable, and then +simply to make the number of bits in the first table a variable, and then to set that variable for the maximum speed. For inflate, which has 286 possible codes for the literal/length tree, the size diff --git a/zlib/compress.c b/zlib/compress.c index 2ad5326c1..f43bacf7a 100644 --- a/zlib/compress.c +++ b/zlib/compress.c @@ -19,13 +19,8 @@ memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ -int ZEXPORT compress2(dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ +int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen, int level) { z_stream stream; int err; const uInt max = (uInt)-1; @@ -65,12 +60,8 @@ int ZEXPORT compress2(dest, destLen, source, sourceLen, level) /* =========================================================================== */ -int ZEXPORT compress(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ +int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen) { return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); } @@ -78,9 +69,7 @@ int ZEXPORT compress(dest, destLen, source, sourceLen) If the default memLevel or windowBits for deflateInit() is changed, then this function needs to be updated. */ -uLong ZEXPORT compressBound(sourceLen) - uLong sourceLen; -{ +uLong ZEXPORT compressBound(uLong sourceLen) { return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13; } diff --git a/zlib/contrib/minizip/Makefile b/zlib/contrib/minizip/Makefile index aac76e07f..3d927ec14 100644 --- a/zlib/contrib/minizip/Makefile +++ b/zlib/contrib/minizip/Makefile @@ -1,4 +1,4 @@ -CC=cc +CC?=cc CFLAGS := $(CFLAGS) -O -I../.. UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a diff --git a/zlib/contrib/minizip/MiniZip64_Changes.txt b/zlib/contrib/minizip/MiniZip64_Changes.txt index 13a1bd91a..375946811 100644 --- a/zlib/contrib/minizip/MiniZip64_Changes.txt +++ b/zlib/contrib/minizip/MiniZip64_Changes.txt @@ -1,5 +1,5 @@ -MiniZip 1.1 was derrived from MiniZip at version 1.01f +MiniZip 1.1 was derived from MiniZip at version 1.01f Change in 1.0 (Okt 2009) - **TODO - Add history** diff --git a/zlib/contrib/minizip/configure.ac b/zlib/contrib/minizip/configure.ac index bff300b30..15ec91718 100644 --- a/zlib/contrib/minizip/configure.ac +++ b/zlib/contrib/minizip/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([minizip], [1.2.13], [bugzilla.redhat.com]) +AC_INIT([minizip], [1.3.1], [bugzilla.redhat.com]) AC_CONFIG_SRCDIR([minizip.c]) AM_INIT_AUTOMAKE([foreign]) LT_INIT diff --git a/zlib/contrib/minizip/crypt.h b/zlib/contrib/minizip/crypt.h index 1cc41f19d..f4b93b78d 100644 --- a/zlib/contrib/minizip/crypt.h +++ b/zlib/contrib/minizip/crypt.h @@ -32,8 +32,7 @@ /*********************************************************************** * Return the next byte in the pseudo-random sequence */ -static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) -{ +static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) { unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an * unpredictable manner on 16-bit systems; not a problem * with any known compiler so far, though */ @@ -46,8 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) /*********************************************************************** * Update the encryption keys with the next byte of plain text */ -static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) -{ +static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) { (*(pkeys+0)) = CRC32((*(pkeys+0)), c); (*(pkeys+1)) += (*(pkeys+0)) & 0xff; (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; @@ -63,8 +61,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) * Initialize the encryption keys and the random header according to * the given password. */ -static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) -{ +static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) { *(pkeys+0) = 305419896L; *(pkeys+1) = 591751049L; *(pkeys+2) = 878082192L; @@ -93,8 +90,7 @@ static unsigned crypthead(const char* passwd, /* password string */ int bufSize, unsigned long* pkeys, const z_crc_t* pcrc_32_tab, - unsigned long crcForCrypting) -{ + unsigned long crcForCrypting) { unsigned n; /* index in random header */ int t; /* temporary */ int c; /* random byte */ diff --git a/zlib/contrib/minizip/ioapi.c b/zlib/contrib/minizip/ioapi.c index 7b9befe83..782d32469 100644 --- a/zlib/contrib/minizip/ioapi.c +++ b/zlib/contrib/minizip/ioapi.c @@ -14,7 +14,7 @@ #define _CRT_SECURE_NO_WARNINGS #endif -#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__CYGWIN__) +#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions #define FOPEN_FUNC(filename, mode) fopen(filename, mode) #define FTELLO_FUNC(stream) ftello(stream) @@ -28,8 +28,7 @@ #include "ioapi.h" -voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) -{ +voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) { if (pfilefunc->zfile_func64.zopen64_file != NULL) return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); else @@ -38,8 +37,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename } } -long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) -{ +long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) { if (pfilefunc->zfile_func64.zseek64_file != NULL) return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); else @@ -52,8 +50,7 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP } } -ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) -{ +ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) { if (pfilefunc->zfile_func64.zseek64_file != NULL) return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); else @@ -66,11 +63,9 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream } } -void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) -{ +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) { p_filefunc64_32->zfile_func64.zopen64_file = NULL; p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; - p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; p_filefunc64_32->zfile_func64.ztell64_file = NULL; @@ -84,16 +79,7 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef -static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); -static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); -static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); -static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); -static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); -static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); - -static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) -{ +static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) { FILE* file = NULL; const char* mode_fopen = NULL; (void)opaque; @@ -111,8 +97,7 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in return file; } -static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) -{ +static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) { FILE* file = NULL; const char* mode_fopen = NULL; (void)opaque; @@ -131,24 +116,21 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, } -static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) -{ +static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) { uLong ret; (void)opaque; ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); return ret; } -static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) -{ +static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) { uLong ret; (void)opaque; ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); return ret; } -static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) -{ +static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) { long ret; (void)opaque; ret = ftell((FILE *)stream); @@ -156,16 +138,14 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) } -static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) -{ +static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) { ZPOS64_T ret; (void)opaque; ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream); return ret; } -static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) -{ +static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) { int fseek_origin=0; long ret; (void)opaque; @@ -188,8 +168,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs return ret; } -static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) -{ +static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { int fseek_origin=0; long ret; (void)opaque; @@ -208,32 +187,28 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T } ret = 0; - if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0) + if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0) ret = -1; return ret; } -static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) -{ +static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) { int ret; (void)opaque; ret = fclose((FILE *)stream); return ret; } -static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) -{ +static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) { int ret; (void)opaque; ret = ferror((FILE *)stream); return ret; } -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; -{ +void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func; @@ -244,8 +219,7 @@ void fill_fopen_filefunc (pzlib_filefunc_def) pzlib_filefunc_def->opaque = NULL; } -void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) -{ +void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen64_file = fopen64_file_func; pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func; diff --git a/zlib/contrib/minizip/ioapi.c.patch b/zlib/contrib/minizip/ioapi.c.patch deleted file mode 100644 index 54f1b8f77..000000000 --- a/zlib/contrib/minizip/ioapi.c.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../zlib-1.2.8/contrib/minizip/ioapi.c 2012-01-21 12:58:45.000000000 -0700 -+++ zlib/contrib/minizip/ioapi.c 2017-11-11 09:05:50.662012999 -0700 -@@ -14,7 +14,7 @@ - #define _CRT_SECURE_NO_WARNINGS - #endif - --#if defined(__APPLE__) || defined(IOAPI_NO_64) -+#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__CYGWIN__) - // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions - #define FOPEN_FUNC(filename, mode) fopen(filename, mode) - #define FTELLO_FUNC(stream) ftello(stream) diff --git a/zlib/contrib/minizip/ioapi.h b/zlib/contrib/minizip/ioapi.h index ae9ca7e83..a2d2e6e60 100644 --- a/zlib/contrib/minizip/ioapi.h +++ b/zlib/contrib/minizip/ioapi.h @@ -50,7 +50,7 @@ #define ftello64 ftell #define fseeko64 fseek #else -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) #define fopen64 fopen #define ftello64 ftello #define fseeko64 fseeko @@ -82,7 +82,7 @@ #include "mz64conf.h" #endif -/* a type choosen by DEFINE */ +/* a type chosen by DEFINE */ #ifdef HAVE_64BIT_INT_CUSTOM typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; #else @@ -134,17 +134,17 @@ extern "C" { -typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); -typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); -typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); -typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); +typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode); +typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size); +typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size); +typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream); +typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream); -typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); +typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream); +typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin); -/* here is the "old" 32 bits structure structure */ +/* here is the "old" 32 bits structure */ typedef struct zlib_filefunc_def_s { open_file_func zopen_file; @@ -157,9 +157,9 @@ typedef struct zlib_filefunc_def_s voidpf opaque; } zlib_filefunc_def; -typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); -typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); +typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream); +typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin); +typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode); typedef struct zlib_filefunc64_def_s { @@ -173,8 +173,8 @@ typedef struct zlib_filefunc64_def_s voidpf opaque; } zlib_filefunc64_def; -void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); -void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); +void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def); +void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def); /* now internal definition, only for zip.c and unzip.h */ typedef struct zlib_filefunc64_32_def_s @@ -193,11 +193,11 @@ typedef struct zlib_filefunc64_32_def_s #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) -voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); -long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); -ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); +voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode); +long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin); +ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream); -void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) diff --git a/zlib/contrib/minizip/iowin32.c b/zlib/contrib/minizip/iowin32.c index 7df525172..08536e94b 100644 --- a/zlib/contrib/minizip/iowin32.c +++ b/zlib/contrib/minizip/iowin32.c @@ -38,14 +38,6 @@ #endif #endif -voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); -uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); -ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream)); -long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); -int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream)); -int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream)); - typedef struct { HANDLE hf; @@ -57,8 +49,7 @@ static void win32_translate_open_mode(int mode, DWORD* lpdwDesiredAccess, DWORD* lpdwCreationDisposition, DWORD* lpdwShareMode, - DWORD* lpdwFlagsAndAttributes) -{ + DWORD* lpdwFlagsAndAttributes) { *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) @@ -79,8 +70,7 @@ static void win32_translate_open_mode(int mode, } } -static voidpf win32_build_iowin(HANDLE hFile) -{ +static voidpf win32_build_iowin(HANDLE hFile) { voidpf ret=NULL; if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) @@ -98,8 +88,7 @@ static voidpf win32_build_iowin(HANDLE hFile) return ret; } -voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode) -{ +voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) { const char* mode_fopen = NULL; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = NULL; @@ -127,8 +116,7 @@ voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int } -voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode) -{ +voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) { const char* mode_fopen = NULL; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = NULL; @@ -151,8 +139,7 @@ voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int } -voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode) -{ +voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) { const char* mode_fopen = NULL; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = NULL; @@ -171,8 +158,7 @@ voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int } -voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode) -{ +voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) { const char* mode_fopen = NULL; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = NULL; @@ -200,8 +186,7 @@ voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mo } -uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size) -{ +uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) { uLong ret=0; HANDLE hFile = NULL; if (stream!=NULL) @@ -222,8 +207,7 @@ uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uL } -uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size) -{ +uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) { uLong ret=0; HANDLE hFile = NULL; if (stream!=NULL) @@ -243,8 +227,7 @@ uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* b return ret; } -static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) -{ +static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) { #ifdef IOWIN32_USING_WINRT_API return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); #else @@ -263,8 +246,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n #endif } -long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) -{ +long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) { long ret=-1; HANDLE hFile = NULL; if (stream!=NULL) @@ -286,8 +268,7 @@ long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) return ret; } -ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) -{ +ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) { ZPOS64_T ret= (ZPOS64_T)-1; HANDLE hFile = NULL; if (stream!=NULL) @@ -311,8 +292,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) } -long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin) -{ +long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) { DWORD dwMoveMethod=0xFFFFFFFF; HANDLE hFile = NULL; @@ -349,8 +329,7 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in return ret; } -long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin) -{ +long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { DWORD dwMoveMethod=0xFFFFFFFF; HANDLE hFile = NULL; long ret=-1; @@ -388,8 +367,7 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off return ret; } -int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) -{ +int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) { int ret=-1; if (stream!=NULL) @@ -406,8 +384,7 @@ int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) return ret; } -int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) -{ +int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) { int ret=-1; if (stream!=NULL) { @@ -416,8 +393,7 @@ int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) return ret; } -void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) -{ +void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = win32_open_file_func; pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func; @@ -428,8 +404,7 @@ void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) pzlib_filefunc_def->opaque = NULL; } -void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) -{ +void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen64_file = win32_open64_file_func; pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func; @@ -441,8 +416,7 @@ void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) } -void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) -{ +void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA; pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func; @@ -454,8 +428,7 @@ void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) } -void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) -{ +void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW; pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func; diff --git a/zlib/contrib/minizip/iowin32.h b/zlib/contrib/minizip/iowin32.h index 0ca0969a7..a23a65d43 100644 --- a/zlib/contrib/minizip/iowin32.h +++ b/zlib/contrib/minizip/iowin32.h @@ -18,10 +18,10 @@ extern "C" { #endif -void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); -void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); -void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); -void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); +void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def); +void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def); +void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def); +void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def); #ifdef __cplusplus } diff --git a/zlib/contrib/minizip/miniunz.c b/zlib/contrib/minizip/miniunz.c index 0dc9b5081..d627c4226 100644 --- a/zlib/contrib/minizip/miniunz.c +++ b/zlib/contrib/minizip/miniunz.c @@ -27,7 +27,7 @@ #endif #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions #define FOPEN_FUNC(filename, mode) fopen(filename, mode) #define FTELLO_FUNC(stream) ftello(stream) @@ -79,13 +79,9 @@ /* change_file_date : change the date/time of a file filename : the filename of the file where date/time must be modified - dosdate : the new date at the MSDos format (4 bytes) + dosdate : the new date at the MSDOS format (4 bytes) tmu_date : the SAME new date at the tm_unz format */ -static void change_file_date(filename,dosdate,tmu_date) - const char *filename; - uLong dosdate; - tm_unz tmu_date; -{ +static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) { #ifdef _WIN32 HANDLE hFile; FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; @@ -115,6 +111,10 @@ static void change_file_date(filename,dosdate,tmu_date) ut.actime=ut.modtime=mktime(&newdate); utime(filename,&ut); +#else + (void)filename; + (void)dosdate; + (void)tmu_date; #endif #endif } @@ -123,9 +123,7 @@ static void change_file_date(filename,dosdate,tmu_date) /* mymkdir and change_file_date are not 100 % portable As I don't know well Unix, I wait feedback for the unix portion */ -static int mymkdir(dirname) - const char* dirname; -{ +static int mymkdir(const char* dirname) { int ret=0; #ifdef _WIN32 ret = _mkdir(dirname); @@ -133,13 +131,13 @@ static int mymkdir(dirname) ret = mkdir (dirname,0775); #elif __APPLE__ ret = mkdir (dirname,0775); +#else + (void)dirname; #endif return ret; } -static int makedir (newdir) - const char *newdir; -{ +static int makedir(const char *newdir) { char *buffer ; char *p; size_t len = strlen(newdir); @@ -187,14 +185,12 @@ static int makedir (newdir) return 1; } -static void do_banner() -{ - printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); +static void do_banner(void) { + printf("MiniUnz 1.1, demo of zLib + Unz package written by Gilles Vollant\n"); printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); } -static void do_help() -{ +static void do_help(void) { printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ " -e Extract without pathname (junk paths)\n" \ " -x Extract with pathname\n" \ @@ -202,11 +198,10 @@ static void do_help() " -l list files\n" \ " -d directory to extract into\n" \ " -o overwrite files without prompting\n" \ - " -p extract crypted file using password\n\n"); + " -p extract encrypted file using password\n\n"); } -static void Display64BitsSize(ZPOS64_T n, int size_char) -{ +static void Display64BitsSize(ZPOS64_T n, int size_char) { /* to avoid compatibility problem , we do here the conversion */ char number[21]; int offset=19; @@ -233,9 +228,7 @@ static void Display64BitsSize(ZPOS64_T n, int size_char) printf("%s",&number[pos_string]); } -static int do_list(uf) - unzFile uf; -{ +static int do_list(unzFile uf) { uLong i; unz_global_info64 gi; int err; @@ -250,7 +243,7 @@ static int do_list(uf) char filename_inzip[256]; unz_file_info64 file_info; uLong ratio=0; - const char *string_method; + const char *string_method = ""; char charCrypt=' '; err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); if (err!=UNZ_OK) @@ -261,7 +254,7 @@ static int do_list(uf) if (file_info.uncompressed_size>0) ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size); - /* display a '*' if the file is crypted */ + /* display a '*' if the file is encrypted */ if ((file_info.flag & 1) != 0) charCrypt='*'; @@ -311,12 +304,7 @@ static int do_list(uf) } -static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) - unzFile uf; - const int* popt_extract_without_path; - int* popt_overwrite; - const char* password; -{ +static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) { char filename_inzip[256]; char* filename_withoutpath; char* p; @@ -368,6 +356,20 @@ static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,pa else write_filename = filename_withoutpath; + if (write_filename[0]!='\0') + { + const char* relative_check = write_filename; + while (relative_check[1]!='\0') + { + if (relative_check[0]=='.' && relative_check[1]=='.') + write_filename = relative_check; + relative_check++; + } + } + + while (write_filename[0]=='/' || write_filename[0]=='.') + write_filename++; + err = unzOpenCurrentFilePassword(uf,password); if (err!=UNZ_OK) { @@ -473,12 +475,7 @@ static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,pa } -static int do_extract(uf,opt_extract_without_path,opt_overwrite,password) - unzFile uf; - int opt_extract_without_path; - int opt_overwrite; - const char* password; -{ +static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) { uLong i; unz_global_info64 gi; int err; @@ -508,13 +505,7 @@ static int do_extract(uf,opt_extract_without_path,opt_overwrite,password) return 0; } -static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password) - unzFile uf; - const char* filename; - int opt_extract_without_path; - int opt_overwrite; - const char* password; -{ +static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) { if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) { printf("file %s not found in the zipfile\n",filename); @@ -530,10 +521,7 @@ static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite } -int main(argc,argv) - int argc; - char *argv[]; -{ +int main(int argc, char *argv[]) { const char *zipfilename=NULL; const char *filename_to_extract=NULL; const char *password=NULL; @@ -606,7 +594,7 @@ int main(argc,argv) # endif strncpy(filename_try, zipfilename,MAXFILENAME-1); - /* strncpy doesnt append the trailing NULL, of the string is too long. */ + /* strncpy doesn't append the trailing NULL, of the string is too long. */ filename_try[ MAXFILENAME ] = '\0'; # ifdef USEWIN32IOAPI diff --git a/zlib/contrib/minizip/minizip.c b/zlib/contrib/minizip/minizip.c index e8561b15f..26ee8d029 100644 --- a/zlib/contrib/minizip/minizip.c +++ b/zlib/contrib/minizip/minizip.c @@ -28,7 +28,7 @@ #endif #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions #define FOPEN_FUNC(filename, mode) fopen(filename, mode) #define FTELLO_FUNC(stream) ftello(stream) @@ -71,11 +71,9 @@ #define MAXFILENAME (256) #ifdef _WIN32 -static int filetime(f, tmzip, dt) - const char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ +/* f: name of file to get info on, tmzip: return value: access, + modification and creation times, dt: dostime */ +static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { int ret = 0; { FILETIME ftLocal; @@ -95,11 +93,9 @@ static int filetime(f, tmzip, dt) } #else #if defined(unix) || defined(__APPLE__) -static int filetime(f, tmzip, dt) - const char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ +/* f: name of file to get info on, tmzip: return value: access, + modification and creation times, dt: dostime */ +static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { (void)dt; int ret=0; struct stat s; /* results of stat() */ @@ -114,7 +110,7 @@ static int filetime(f, tmzip, dt) len = MAXFILENAME; strncpy(name, f,MAXFILENAME-1); - /* strncpy doesnt append the trailing NULL, of the string is too long. */ + /* strncpy doesn't append the trailing NULL, of the string is too long. */ name[ MAXFILENAME ] = '\0'; if (name[len - 1] == '/') @@ -138,11 +134,12 @@ static int filetime(f, tmzip, dt) return ret; } #else -uLong filetime(f, tmzip, dt) - const char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ +/* f: name of file to get info on, tmzip: return value: access, + modification and creation times, dt: dostime */ +static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { + (void)f; + (void)tmzip; + (void)dt; return 0; } #endif @@ -151,9 +148,7 @@ uLong filetime(f, tmzip, dt) -static int check_exist_file(filename) - const char* filename; -{ +static int check_exist_file(const char* filename) { FILE* ftestexist; int ret = 1; ftestexist = FOPEN_FUNC(filename,"rb"); @@ -164,14 +159,12 @@ static int check_exist_file(filename) return ret; } -static void do_banner() -{ +static void do_banner(void) { printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n"); printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n"); } -static void do_help() -{ +static void do_help(void) { printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \ " -o Overwrite existing file.zip\n" \ " -a Append to existing file.zip\n" \ @@ -183,8 +176,7 @@ static void do_help() /* calculate the CRC32 of a file, because to encrypt a file, we need known the CRC32 of the file before */ -static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) -{ +static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) { unsigned long calculate_crc=0; int err=ZIP_OK; FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); @@ -222,8 +214,7 @@ static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf, return err; } -static int isLargeFile(const char* filename) -{ +static int isLargeFile(const char* filename) { int largeFile = 0; ZPOS64_T pos = 0; FILE* pFile = FOPEN_FUNC(filename, "rb"); @@ -233,7 +224,7 @@ static int isLargeFile(const char* filename) FSEEKO_FUNC(pFile, 0, SEEK_END); pos = (ZPOS64_T)FTELLO_FUNC(pFile); - printf("File : %s is %lld bytes\n", filename, pos); + printf("File : %s is %llu bytes\n", filename, pos); if(pos >= 0xffffffff) largeFile = 1; @@ -244,10 +235,7 @@ static int isLargeFile(const char* filename) return largeFile; } -int main(argc,argv) - int argc; - char *argv[]; -{ +int main(int argc, char *argv[]) { int i; int opt_overwrite=0; int opt_compress_level=Z_DEFAULT_COMPRESSION; @@ -323,7 +311,7 @@ int main(argc,argv) zipok = 1 ; strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1); - /* strncpy doesnt append the trailing NULL, of the string is too long. */ + /* strncpy doesn't append the trailing NULL, of the string is too long. */ filename_try[ MAXFILENAME ] = '\0'; len=(int)strlen(filename_try); @@ -393,10 +381,10 @@ int main(argc,argv) ((argv[i][1]=='o') || (argv[i][1]=='O') || (argv[i][1]=='a') || (argv[i][1]=='A') || (argv[i][1]=='p') || (argv[i][1]=='P') || - ((argv[i][1]>='0') || (argv[i][1]<='9'))) && + ((argv[i][1]>='0') && (argv[i][1]<='9'))) && (strlen(argv[i]) == 2))) { - FILE * fin; + FILE * fin = NULL; size_t size_read; const char* filenameinzip = argv[i]; const char *savefilenameinzip; diff --git a/zlib/contrib/minizip/mztools.c b/zlib/contrib/minizip/mztools.c index 96891c2e0..c8d237561 100644 --- a/zlib/contrib/minizip/mztools.c +++ b/zlib/contrib/minizip/mztools.c @@ -27,13 +27,7 @@ WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ } while(0) -extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) -const char* file; -const char* fileOut; -const char* fileOutTmp; -uLong* nRecovered; -uLong* bytesRecovered; -{ +extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) { int err = Z_OK; FILE* fpZip = fopen(file, "rb"); FILE* fpOut = fopen(fileOut, "wb"); diff --git a/zlib/contrib/minizip/unzip.c b/zlib/contrib/minizip/unzip.c index 3036b470b..ea05b7d62 100644 --- a/zlib/contrib/minizip/unzip.c +++ b/zlib/contrib/minizip/unzip.c @@ -49,12 +49,12 @@ Copyright (C) 2007-2008 Even Rouault - Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). + Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G should only read the compressed/uncompressed size from the Zip64 format if the size from normal header was 0xFFFFFFFF - Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant - Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) + Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant + Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required) Patch created by Daniel Borca Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer @@ -77,8 +77,6 @@ #ifdef STDC # include -# include -# include #endif #ifdef NO_ERRNO_H extern int errno; @@ -111,9 +109,6 @@ #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif -#ifndef TRYFREE -# define TRYFREE(p) { free(p);} -#endif #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) @@ -122,7 +117,7 @@ const char unz_copyright[] = " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; -/* unz_file_info_interntal contain internal info about a file in zipfile*/ +/* unz_file_info64_internal contain internal info about a file in zipfile*/ typedef struct unz_file_info64_internal_s { ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */ @@ -153,7 +148,7 @@ typedef struct ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ zlib_filefunc64_32_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ + voidpf filestream; /* io structure of the zipfile */ uLong compression_method; /* compression method (0==store) */ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ int raw; @@ -166,7 +161,7 @@ typedef struct { zlib_filefunc64_32_def z_filefunc; int is64bitOpenFunction; - voidpf filestream; /* io structore of the zipfile */ + voidpf filestream; /* io structure of the zipfile */ unz_global_info64 gi; /* public global information */ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ ZPOS64_T num_file; /* number of the current file in the zipfile*/ @@ -197,29 +192,24 @@ typedef struct #include "crypt.h" #endif + /* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been successfully opened for reading. + Reads a long in LSB order from the given gz_stream. Sets */ - -local int unz64local_getByte OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - int *pi)); - -local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi) -{ - unsigned char c; - int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); - if (err==1) +local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX) { + unsigned char c[2]; + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,2); + if (err==2) { - *pi = (int)c; + *pX = c[0] | ((uLong)c[1] << 8); return UNZ_OK; } else { + *pX = 0; if (ZERROR64(*pzlib_filefunc_def,filestream)) return UNZ_ERRNO; else @@ -227,127 +217,50 @@ local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, v } } - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int unz64local_getShort OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, +local int unz64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, - uLong *pX) -{ - uLong x ; - int i = 0; - int err; - - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((uLong)i)<<8; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int unz64local_getLong OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX) -{ - uLong x ; - int i = 0; - int err; - - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((uLong)i)<<8; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((uLong)i)<<16; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<24; - - if (err==UNZ_OK) - *pX = x; + uLong *pX) { + unsigned char c[4]; + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,4); + if (err==4) + { + *pX = c[0] | ((uLong)c[1] << 8) | ((uLong)c[2] << 16) | ((uLong)c[3] << 24); + return UNZ_OK; + } else + { *pX = 0; - return err; + if (ZERROR64(*pzlib_filefunc_def,filestream)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } } -local int unz64local_getLong64 OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - ZPOS64_T *pX)); - - -local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - ZPOS64_T *pX) -{ - ZPOS64_T x ; - int i = 0; - int err; - - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (ZPOS64_T)i; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<8; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<16; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<24; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<32; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<40; - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<48; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<56; - - if (err==UNZ_OK) - *pX = x; +local int unz64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + ZPOS64_T *pX) { + unsigned char c[8]; + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,8); + if (err==8) + { + *pX = c[0] | ((ZPOS64_T)c[1] << 8) | ((ZPOS64_T)c[2] << 16) | ((ZPOS64_T)c[3] << 24) + | ((ZPOS64_T)c[4] << 32) | ((ZPOS64_T)c[5] << 40) | ((ZPOS64_T)c[6] << 48) | ((ZPOS64_T)c[7] << 56); + return UNZ_OK; + } else + { *pX = 0; - return err; + if (ZERROR64(*pzlib_filefunc_def,filestream)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } } /* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2) -{ +local int strcmpcasenosensitive_internal(const char* fileName1, const char* fileName2) { for (;;) { char c1=*(fileName1++); @@ -379,19 +292,17 @@ local int strcmpcasenosensitive_internal (const char* fileName1, const char* fil #endif /* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + Compare two filenames (fileName1,fileName2). + If iCaseSensitivity = 1, comparison is case sensitive (like strcmp) + If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + If iCaseSensitivity = 0, case sensitivity is default of your operating system (like 1 on Unix, 2 on Windows) */ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, - const char* fileName2, - int iCaseSensitivity) - -{ + const char* fileName2, + int iCaseSensitivity) { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; @@ -405,21 +316,23 @@ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, #define BUFREADCOMMENT (0x400) #endif +#ifndef CENTRALDIRINVALID +#define CENTRALDIRINVALID ((ZPOS64_T)(-1)) +#endif + /* Locate the Central directory of a zipfile (at the end, just before the global comment) */ -local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); -local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) -{ +local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ - ZPOS64_T uPosFound=0; + ZPOS64_T uPosFound=CENTRALDIRINVALID; if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; + return CENTRALDIRINVALID; uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); @@ -429,7 +342,7 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); if (buf==NULL) - return 0; + return CENTRALDIRINVALID; uBackRead = 4; while (uBackReadz_filefunc, s->filestream); - TRYFREE(s); + free(s); return UNZ_OK; } @@ -825,8 +727,7 @@ extern int ZEXPORT unzClose (unzFile file) Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info) -{ +extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64* pglobal_info) { unz64_s* s; if (file==NULL) return UNZ_PARAMERROR; @@ -835,8 +736,7 @@ extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_ return UNZ_OK; } -extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32) -{ +extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32) { unz64_s* s; if (file==NULL) return UNZ_PARAMERROR; @@ -847,10 +747,9 @@ extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info return UNZ_OK; } /* - Translate date/time from Dos format to tm_unz (readable more easilty) + Translate date/time from Dos format to tm_unz (readable more easily) */ -local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) -{ +local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz* ptm) { ZPOS64_T uDate; uDate = (ZPOS64_T)(ulDosDate>>16); ptm->tm_mday = (int)(uDate&0x1f) ; @@ -865,28 +764,16 @@ local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) /* Get Info about the current file in the zipfile, with internal only info */ -local int unz64local_GetCurrentFileInfoInternal OF((unzFile file, - unz_file_info64 *pfile_info, - unz_file_info64_internal - *pfile_info_internal, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -local int unz64local_GetCurrentFileInfoInternal (unzFile file, - unz_file_info64 *pfile_info, - unz_file_info64_internal - *pfile_info_internal, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize) -{ +local int unz64local_GetCurrentFileInfoInternal(unzFile file, + unz_file_info64 *pfile_info, + unz_file_info64_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize) { unz64_s* s; unz_file_info64 file_info; unz_file_info64_internal file_info_internal; @@ -1038,33 +925,31 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, /* ZIP64 extra fields */ if (headerId == 0x0001) { - uLong uL; - - if(file_info.uncompressed_size == MAXU32) - { - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; - } - - if(file_info.compressed_size == MAXU32) - { - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; - } - - if(file_info_internal.offset_curfile == MAXU32) - { - /* Relative Header offset */ - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; - } - - if(file_info.disk_num_start == MAXU32) - { - /* Disk Start Number */ - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) - err=UNZ_ERRNO; - } + if(file_info.uncompressed_size == MAXU32) + { + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info.compressed_size == MAXU32) + { + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info_internal.offset_curfile == MAXU32) + { + /* Relative Header offset */ + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info.disk_num_start == 0xffff) + { + /* Disk Start Number */ + if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + } } else @@ -1121,24 +1006,22 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, No preparation of the structure is needed return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file, - unz_file_info64 * pfile_info, - char * szFileName, uLong fileNameBufferSize, - void *extraField, uLong extraFieldBufferSize, - char* szComment, uLong commentBufferSize) -{ +extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, + unz_file_info64 * pfile_info, + char * szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char* szComment, uLong commentBufferSize) { return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); } -extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, - unz_file_info * pfile_info, - char * szFileName, uLong fileNameBufferSize, - void *extraField, uLong extraFieldBufferSize, - char* szComment, uLong commentBufferSize) -{ +extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, + unz_file_info * pfile_info, + char * szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char* szComment, uLong commentBufferSize) { int err; unz_file_info64 file_info64; err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, @@ -1162,7 +1045,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, pfile_info->internal_fa = file_info64.internal_fa; pfile_info->external_fa = file_info64.external_fa; - pfile_info->tmu_date = file_info64.tmu_date, + pfile_info->tmu_date = file_info64.tmu_date; pfile_info->compressed_size = (uLong)file_info64.compressed_size; @@ -1175,8 +1058,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ -extern int ZEXPORT unzGoToFirstFile (unzFile file) -{ +extern int ZEXPORT unzGoToFirstFile(unzFile file) { int err=UNZ_OK; unz64_s* s; if (file==NULL) @@ -1196,8 +1078,7 @@ extern int ZEXPORT unzGoToFirstFile (unzFile file) return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ -extern int ZEXPORT unzGoToNextFile (unzFile file) -{ +extern int ZEXPORT unzGoToNextFile(unzFile file) { unz64_s* s; int err; @@ -1229,8 +1110,7 @@ extern int ZEXPORT unzGoToNextFile (unzFile file) UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ -extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) -{ +extern int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity) { unz64_s* s; int err; @@ -1305,8 +1185,7 @@ typedef struct unz_file_pos_s } unz_file_pos; */ -extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) -{ +extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) { unz64_s* s; if (file==NULL || file_pos==NULL) @@ -1321,10 +1200,7 @@ extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) return UNZ_OK; } -extern int ZEXPORT unzGetFilePos( - unzFile file, - unz_file_pos* file_pos) -{ +extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos) { unz64_file_pos file_pos64; int err = unzGetFilePos64(file,&file_pos64); if (err==UNZ_OK) @@ -1335,8 +1211,7 @@ extern int ZEXPORT unzGetFilePos( return err; } -extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) -{ +extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) { unz64_s* s; int err; @@ -1357,10 +1232,7 @@ extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos return err; } -extern int ZEXPORT unzGoToFilePos( - unzFile file, - unz_file_pos* file_pos) -{ +extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) { unz64_file_pos file_pos64; if (file_pos == NULL) return UNZ_PARAMERROR; @@ -1382,10 +1254,9 @@ extern int ZEXPORT unzGoToFilePos( store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */ -local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar, - ZPOS64_T * poffset_local_extrafield, - uInt * psize_local_extrafield) -{ +local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar, + ZPOS64_T * poffset_local_extrafield, + uInt * psize_local_extrafield) { uLong uMagic,uData,uFlags; uLong size_filename; uLong size_extra_field; @@ -1469,9 +1340,8 @@ local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVa Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ -extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, - int* level, int raw, const char* password) -{ +extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method, + int* level, int raw, const char* password) { int err=UNZ_OK; uInt iSizeVar; unz64_s* s; @@ -1509,7 +1379,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, if (pfile_in_zip_read_info->read_buffer==NULL) { - TRYFREE(pfile_in_zip_read_info); + free(pfile_in_zip_read_info); return UNZ_INTERNALERROR; } @@ -1566,8 +1436,8 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; else { - TRYFREE(pfile_in_zip_read_info->read_buffer); - TRYFREE(pfile_in_zip_read_info); + free(pfile_in_zip_read_info->read_buffer); + free(pfile_in_zip_read_info); return err; } #else @@ -1587,8 +1457,8 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; else { - TRYFREE(pfile_in_zip_read_info->read_buffer); - TRYFREE(pfile_in_zip_read_info); + free(pfile_in_zip_read_info->read_buffer); + free(pfile_in_zip_read_info); return err; } /* windowBits is passed < 0 to tell that there is no zlib header. @@ -1640,25 +1510,21 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, return UNZ_OK; } -extern int ZEXPORT unzOpenCurrentFile (unzFile file) -{ +extern int ZEXPORT unzOpenCurrentFile(unzFile file) { return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); } -extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password) -{ +extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char* password) { return unzOpenCurrentFile3(file, NULL, NULL, 0, password); } -extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw) -{ +extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int* method, int* level, int raw) { return unzOpenCurrentFile3(file, method, level, raw, NULL); } /** Addition for GDAL : START */ -extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) -{ +extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; s=(unz64_s*)file; @@ -1678,13 +1544,12 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) buf contain buffer where data must be copied len the size of buf. - return the number of byte copied if somes bytes are copied + return the number of byte copied if some bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ -extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) -{ +extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { int err=UNZ_OK; uInt iRead = 0; unz64_s* s; @@ -1891,8 +1756,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) /* Give the current position in uncompressed data */ -extern z_off_t ZEXPORT unztell (unzFile file) -{ +extern z_off_t ZEXPORT unztell(unzFile file) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) @@ -1906,8 +1770,7 @@ extern z_off_t ZEXPORT unztell (unzFile file) return (z_off_t)pfile_in_zip_read_info->stream.total_out; } -extern ZPOS64_T ZEXPORT unztell64 (unzFile file) -{ +extern ZPOS64_T ZEXPORT unztell64(unzFile file) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; @@ -1926,8 +1789,7 @@ extern ZPOS64_T ZEXPORT unztell64 (unzFile file) /* return 1 if the end of file was reached, 0 elsewhere */ -extern int ZEXPORT unzeof (unzFile file) -{ +extern int ZEXPORT unzeof(unzFile file) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) @@ -1958,8 +1820,7 @@ more info in the local-header version than in the central-header) the return value is the number of bytes copied in buf, or (if <0) the error code */ -extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len) -{ +extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; uInt read_now; @@ -2006,8 +1867,7 @@ extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len) Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ -extern int ZEXPORT unzCloseCurrentFile (unzFile file) -{ +extern int ZEXPORT unzCloseCurrentFile(unzFile file) { int err=UNZ_OK; unz64_s* s; @@ -2029,7 +1889,7 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file) } - TRYFREE(pfile_in_zip_read_info->read_buffer); + free(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) inflateEnd(&pfile_in_zip_read_info->stream); @@ -2040,7 +1900,7 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file) pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); + free(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; @@ -2053,8 +1913,7 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file) uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ -extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf) -{ +extern int ZEXPORT unzGetGlobalComment(unzFile file, char * szComment, uLong uSizeBuf) { unz64_s* s; uLong uReadThis ; if (file==NULL) @@ -2081,8 +1940,7 @@ extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uS } /* Additions by RX '2004 */ -extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) -{ +extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) { unz64_s* s; if (file==NULL) @@ -2096,8 +1954,7 @@ extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) return s->pos_in_central_dir; } -extern uLong ZEXPORT unzGetOffset (unzFile file) -{ +extern uLong ZEXPORT unzGetOffset(unzFile file) { ZPOS64_T offset64; if (file==NULL) @@ -2106,8 +1963,7 @@ extern uLong ZEXPORT unzGetOffset (unzFile file) return (uLong)offset64; } -extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) -{ +extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) { unz64_s* s; int err; @@ -2124,7 +1980,6 @@ extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) return err; } -extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) -{ +extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) { return unzSetOffset64(file,pos); } diff --git a/zlib/contrib/minizip/unzip.h b/zlib/contrib/minizip/unzip.h index 6f95e94d7..5cfc9c627 100644 --- a/zlib/contrib/minizip/unzip.h +++ b/zlib/contrib/minizip/unzip.h @@ -150,21 +150,21 @@ typedef struct unz_file_info_s tm_unz tmu_date; } unz_file_info; -extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, - const char* fileName2, - int iCaseSensitivity)); +extern int ZEXPORT unzStringFileNameCompare(const char* fileName1, + const char* fileName2, + int iCaseSensitivity); /* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + Compare two filenames (fileName1,fileName2). + If iCaseSensitivity = 1, comparison is case sensitive (like strcmp) + If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + If iCaseSensitivity = 0, case sensitivity is default of your operating system (like 1 on Unix, 2 on Windows) */ -extern unzFile ZEXPORT unzOpen OF((const char *path)); -extern unzFile ZEXPORT unzOpen64 OF((const void *path)); +extern unzFile ZEXPORT unzOpen(const char *path); +extern unzFile ZEXPORT unzOpen64(const void *path); /* Open a Zip file. path contain the full pathname (by example, on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer @@ -181,41 +181,41 @@ extern unzFile ZEXPORT unzOpen64 OF((const void *path)); */ -extern unzFile ZEXPORT unzOpen2 OF((const char *path, - zlib_filefunc_def* pzlib_filefunc_def)); +extern unzFile ZEXPORT unzOpen2(const char *path, + zlib_filefunc_def* pzlib_filefunc_def); /* Open a Zip file, like unzOpen, but provide a set of file low level API for read/write the zip file (see ioapi.h) */ -extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, - zlib_filefunc64_def* pzlib_filefunc_def)); +extern unzFile ZEXPORT unzOpen2_64(const void *path, + zlib_filefunc64_def* pzlib_filefunc_def); /* Open a Zip file, like unz64Open, but provide a set of file low level API for read/write the zip file (see ioapi.h) */ -extern int ZEXPORT unzClose OF((unzFile file)); +extern int ZEXPORT unzClose(unzFile file); /* Close a ZipFile opened with unzOpen. If there is files inside the .Zip opened with unzOpenCurrentFile (see later), these files MUST be closed with unzCloseCurrentFile before call unzClose. return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); +extern int ZEXPORT unzGetGlobalInfo(unzFile file, + unz_global_info *pglobal_info); -extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, - unz_global_info64 *pglobal_info)); +extern int ZEXPORT unzGetGlobalInfo64(unzFile file, + unz_global_info64 *pglobal_info); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); +extern int ZEXPORT unzGetGlobalComment(unzFile file, + char *szComment, + uLong uSizeBuf); /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. @@ -226,22 +226,22 @@ extern int ZEXPORT unzGetGlobalComment OF((unzFile file, /***************************************************************************/ /* Unzip package allow you browse the directory of the zipfile */ -extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); +extern int ZEXPORT unzGoToFirstFile(unzFile file); /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ -extern int ZEXPORT unzGoToNextFile OF((unzFile file)); +extern int ZEXPORT unzGoToNextFile(unzFile file); /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ -extern int ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); +extern int ZEXPORT unzLocateFile(unzFile file, + const char *szFileName, + int iCaseSensitivity); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare @@ -285,28 +285,28 @@ extern int ZEXPORT unzGoToFilePos64( /* ****************************************** */ -extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, - unz_file_info64 *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); +extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, + unz_file_info64 *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize); + +extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize); /* Get Info about the current file - if pfile_info!=NULL, the *pfile_info structure will contain somes info about + if pfile_info!=NULL, the *pfile_info structure will contain some info about the current file - if szFileName!=NULL, the filemane string will be copied in szFileName + if szFileName!=NULL, the filename string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). @@ -318,7 +318,7 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, /** Addition for GDAL : START */ -extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); +extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file); /** Addition for GDAL : END */ @@ -328,24 +328,24 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); from it, and close it (you can close it before reading all the file) */ -extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); +extern int ZEXPORT unzOpenCurrentFile(unzFile file); /* Open for reading data the current file in the zipfile. If there is no error, the return value is UNZ_OK. */ -extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, - const char* password)); +extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, + const char* password); /* Open for reading data the current file in the zipfile. password is a crypting password If there is no error, the return value is UNZ_OK. */ -extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, - int* method, - int* level, - int raw)); +extern int ZEXPORT unzOpenCurrentFile2(unzFile file, + int* method, + int* level, + int raw); /* Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) if raw==1 @@ -355,11 +355,11 @@ extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, but you CANNOT set method parameter as NULL */ -extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, - int* method, - int* level, - int raw, - const char* password)); +extern int ZEXPORT unzOpenCurrentFile3(unzFile file, + int* method, + int* level, + int raw, + const char* password); /* Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) if raw==1 @@ -370,41 +370,41 @@ extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, */ -extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); +extern int ZEXPORT unzCloseCurrentFile(unzFile file); /* Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ -extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); +extern int ZEXPORT unzReadCurrentFile(unzFile file, + voidp buf, + unsigned len); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied len the size of buf. - return the number of byte copied if somes bytes are copied + return the number of byte copied if some bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ -extern z_off_t ZEXPORT unztell OF((unzFile file)); +extern z_off_t ZEXPORT unztell(unzFile file); -extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); +extern ZPOS64_T ZEXPORT unztell64(unzFile file); /* Give the current position in uncompressed data */ -extern int ZEXPORT unzeof OF((unzFile file)); +extern int ZEXPORT unzeof(unzFile file); /* return 1 if the end of file was reached, 0 elsewhere */ -extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); +extern int ZEXPORT unzGetLocalExtrafield(unzFile file, + voidp buf, + unsigned len); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is diff --git a/zlib/contrib/minizip/zip.c b/zlib/contrib/minizip/zip.c index 66d693f85..60bdffac3 100644 --- a/zlib/contrib/minizip/zip.c +++ b/zlib/contrib/minizip/zip.c @@ -14,7 +14,7 @@ Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data - It is used when recreting zip archive with RAW when deleting items from a zip. + It is used when recreating zip archive with RAW when deleting items from a zip. ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed. Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer @@ -25,14 +25,13 @@ #include #include #include +#include #include #include "zlib.h" #include "zip.h" #ifdef STDC # include -# include -# include #endif #ifdef NO_ERRNO_H extern int errno; @@ -47,7 +46,7 @@ /* compile with -Dlocal if your debugger can't find static symbols */ #ifndef VERSIONMADEBY -# define VERSIONMADEBY (0x0) /* platform depedent */ +# define VERSIONMADEBY (0x0) /* platform dependent */ #endif #ifndef Z_BUFSIZE @@ -61,9 +60,6 @@ #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif /* #define SIZECENTRALDIRITEM (0x2e) @@ -138,20 +134,20 @@ typedef struct uInt pos_in_buffered_data; /* last written byte in buffered_data */ ZPOS64_T pos_local_header; /* offset of the local header of the file - currenty writing */ + currently writing */ char* central_header; /* central header data for the current file */ uLong size_centralExtra; uLong size_centralheader; /* size of the central header for cur file */ uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ uLong flag; /* flag of the file currently writing */ - int method; /* compression method of file currenty wr.*/ + int method; /* compression method of file currently wr.*/ int raw; /* 1 for directly writing raw data */ Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ uLong dosDate; uLong crc32; int encrypt; - int zip64; /* Add ZIP64 extened information in the extra field */ + int zip64; /* Add ZIP64 extended information in the extra field */ ZPOS64_T pos_zip64extrainfo; ZPOS64_T totalCompressedData; ZPOS64_T totalUncompressedData; @@ -165,10 +161,10 @@ typedef struct typedef struct { zlib_filefunc64_32_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ + voidpf filestream; /* io structure of the zipfile */ linkedlist_data central_dir;/* datablock with central dir in construction*/ int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ - curfile64_info ci; /* info on the file curretly writing */ + curfile64_info ci; /* info on the file currently writing */ ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ ZPOS64_T add_position_when_writing_offset; @@ -186,8 +182,7 @@ typedef struct #include "crypt.h" #endif -local linkedlist_datablock_internal* allocate_new_datablock() -{ +local linkedlist_datablock_internal* allocate_new_datablock(void) { linkedlist_datablock_internal* ldi; ldi = (linkedlist_datablock_internal*) ALLOC(sizeof(linkedlist_datablock_internal)); @@ -200,30 +195,26 @@ local linkedlist_datablock_internal* allocate_new_datablock() return ldi; } -local void free_datablock(linkedlist_datablock_internal* ldi) -{ +local void free_datablock(linkedlist_datablock_internal* ldi) { while (ldi!=NULL) { linkedlist_datablock_internal* ldinext = ldi->next_datablock; - TRYFREE(ldi); + free(ldi); ldi = ldinext; } } -local void init_linkedlist(linkedlist_data* ll) -{ +local void init_linkedlist(linkedlist_data* ll) { ll->first_block = ll->last_block = NULL; } -local void free_linkedlist(linkedlist_data* ll) -{ +local void free_linkedlist(linkedlist_data* ll) { free_datablock(ll->first_block); ll->first_block = ll->last_block = NULL; } -local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) -{ +local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) { linkedlist_datablock_internal* ldi; const unsigned char* from_copy; @@ -238,7 +229,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) } ldi = ll->last_block; - from_copy = (unsigned char*)buf; + from_copy = (const unsigned char*)buf; while (len>0) { @@ -283,9 +274,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) */ -local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); -local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) -{ +local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) { unsigned char buf[8]; int n; for (n = 0; n < nbByte; n++) @@ -307,9 +296,7 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, return ZIP_OK; } -local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); -local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) -{ +local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) { unsigned char* buf=(unsigned char*)dest; int n; for (n = 0; n < nbByte; n++) { @@ -329,8 +316,7 @@ local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) /****************************************************************************/ -local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) -{ +local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) { uLong year = (uLong)ptm->tm_year; if (year>=1980) year-=1980; @@ -344,10 +330,7 @@ local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) /****************************************************************************/ -local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); - -local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi) -{ +local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int* pi) { unsigned char c; int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); if (err==1) @@ -368,10 +351,7 @@ local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,vo /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ -local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); - -local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) -{ +local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { uLong x ; int i = 0; int err; @@ -390,10 +370,7 @@ local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, return err; } -local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); - -local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) -{ +local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { uLong x ; int i = 0; int err; @@ -420,11 +397,8 @@ local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, return err; } -local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)); - -local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) -{ +local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) { ZPOS64_T x; int i = 0; int err; @@ -475,10 +449,7 @@ local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def Locate the Central directory of a zipfile (at the end, just before the global comment) */ -local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); - -local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) -{ +local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; @@ -529,7 +500,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f if (uPosFound!=0) break; } - TRYFREE(buf); + free(buf); return uPosFound; } @@ -537,10 +508,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before the global comment) */ -local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); - -local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) -{ +local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; @@ -595,7 +563,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib break; } - TRYFREE(buf); + free(buf); if (uPosFound == 0) return 0; @@ -607,7 +575,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) return 0; - /* number of the disk with the start of the zip64 end of central directory */ + /* number of the disk with the start of the zip64 end of central directory */ if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) return 0; if (uL != 0) @@ -637,8 +605,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib return relativeOffset; } -local int LoadCentralDirectoryRecord(zip64_internal* pziinit) -{ +local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { int err=ZIP_OK; ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ @@ -647,10 +614,10 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) ZPOS64_T central_pos; uLong uL; - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ + uLong number_disk; /* number of the current disk, used for + spanning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number of the disk with central dir, used + for spanning ZIP, unsupported, always 0*/ ZPOS64_T number_entry; ZPOS64_T number_entry_CD; /* total number of entries in the central dir @@ -830,7 +797,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) size_central_dir_to_read-=read_this; } - TRYFREE(buf_read); + free(buf_read); } pziinit->begin_pos = byte_before_the_zipfile; pziinit->number_entry = number_entry_CD; @@ -846,8 +813,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) /************************************************************/ -extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) -{ +extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) { zip64_internal ziinit; zip64_internal* zi; int err=ZIP_OK; @@ -905,9 +871,9 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl if (err != ZIP_OK) { # ifndef NO_ADDFILEINEXISTINGZIP - TRYFREE(ziinit.globalcomment); + free(ziinit.globalcomment); # endif /* !NO_ADDFILEINEXISTINGZIP*/ - TRYFREE(zi); + free(zi); return NULL; } else @@ -917,8 +883,7 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl } } -extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) -{ +extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) { if (pzlib_filefunc32_def != NULL) { zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; @@ -929,8 +894,7 @@ extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* gl return zipOpen3(pathname, append, globalcomment, NULL); } -extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) -{ +extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) { if (pzlib_filefunc_def != NULL) { zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; @@ -945,18 +909,15 @@ extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* -extern zipFile ZEXPORT zipOpen (const char* pathname, int append) -{ +extern zipFile ZEXPORT zipOpen(const char* pathname, int append) { return zipOpen3((const void*)pathname,append,NULL,NULL); } -extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) -{ +extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) { return zipOpen3(pathname,append,NULL,NULL); } -local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) -{ +local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) { /* write the local header */ int err; uInt size_filename = (uInt)strlen(filename); @@ -1052,14 +1013,13 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize unnecessary allocations. */ -extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, - uLong versionMadeBy, uLong flagBase, int zip64) -{ +extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, + uLong versionMadeBy, uLong flagBase, int zip64) { zip64_internal* zi; uInt size_filename; uInt size_comment; @@ -1083,6 +1043,17 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, return ZIP_PARAMERROR; #endif + // The filename and comment length must fit in 16 bits. + if ((filename!=NULL) && (strlen(filename)>0xffff)) + return ZIP_PARAMERROR; + if ((comment!=NULL) && (strlen(comment)>0xffff)) + return ZIP_PARAMERROR; + // The extra field length must fit in 16 bits. If the member also requires + // a Zip64 extra block, that will also need to fit within that 16-bit + // length, but that will be checked for later. + if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff)) + return ZIP_PARAMERROR; + zi = (zip64_internal*)file; if (zi->in_opened_file_inzip == 1) @@ -1262,35 +1233,33 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, return err; } -extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, - uLong versionMadeBy, uLong flagBase) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, versionMadeBy, flagBase, 0); +extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, + uLong versionMadeBy, uLong flagBase) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, versionMadeBy, flagBase, 0); } -extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, VERSIONMADEBY, 0, 0); +extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, VERSIONMADEBY, 0, 0); } extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, @@ -1298,70 +1267,64 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, c const void* extrafield_global, uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, VERSIONMADEBY, 0, zip64); + const char* password, uLong crcForCrypting, int zip64) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, VERSIONMADEBY, 0, zip64); } extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, 0); + const char* comment, int method, int level, int raw) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, 0); } extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, zip64); + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, int zip64) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, zip64); } -extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void*extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, 0, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, zip64); +extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void*extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int zip64) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, zip64); } -extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void*extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, 0, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, 0); +extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void*extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, 0); } -local int zip64FlushWriteBuffer(zip64_internal* zi) -{ +local int zip64FlushWriteBuffer(zip64_internal* zi) { int err=ZIP_OK; if (zi->ci.encrypt != 0) @@ -1399,8 +1362,7 @@ local int zip64FlushWriteBuffer(zip64_internal* zi) return err; } -extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) -{ +extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) { zip64_internal* zi; int err=ZIP_OK; @@ -1450,7 +1412,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in else #endif { - zi->ci.stream.next_in = (Bytef*)buf; + zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf; zi->ci.stream.avail_in = len; while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) @@ -1501,13 +1463,11 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in return err; } -extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) -{ +extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) { return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); } -extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) -{ +extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32) { zip64_internal* zi; ZPOS64_T compressed_size; uLong invalidValue = 0xffffffff; @@ -1648,7 +1608,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree) { - // we can not write more data to the buffer that we have room for. + // we cannot write more data to the buffer that we have room for. return ZIP_BADZIPFILE; } @@ -1742,13 +1702,11 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s return err; } -extern int ZEXPORT zipCloseFileInZip (zipFile file) -{ +extern int ZEXPORT zipCloseFileInZip(zipFile file) { return zipCloseFileInZipRaw (file,0,0); } -local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) -{ +local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) { int err = ZIP_OK; ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; @@ -1769,8 +1727,7 @@ local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T z return err; } -local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) -{ +local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { int err = ZIP_OK; uLong Zip64DataSize = 44; @@ -1808,8 +1765,8 @@ local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_ } return err; } -local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) -{ + +local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { int err = ZIP_OK; /*signature*/ @@ -1856,8 +1813,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr return err; } -local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) -{ +local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) { int err = ZIP_OK; uInt size_global_comment = 0; @@ -1874,8 +1830,7 @@ local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) return err; } -extern int ZEXPORT zipClose (zipFile file, const char* global_comment) -{ +extern int ZEXPORT zipClose(zipFile file, const char* global_comment) { zip64_internal* zi; int err = 0; uLong size_centraldir = 0; @@ -1917,7 +1872,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment) free_linkedlist(&(zi->central_dir)); pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; - if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) + if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF) { ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); @@ -1936,15 +1891,14 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment) err = ZIP_ERRNO; #ifndef NO_ADDFILEINEXISTINGZIP - TRYFREE(zi->globalcomment); + free(zi->globalcomment); #endif - TRYFREE(zi); + free(zi); return err; } -extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) -{ +extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader) { char* p = pData; int size = 0; char* pNewHeader; @@ -1996,7 +1950,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe else retVal = ZIP_ERRNO; - TRYFREE(pNewHeader); + free(pNewHeader); return retVal; } diff --git a/zlib/contrib/minizip/zip.h b/zlib/contrib/minizip/zip.h index 7e4509d77..3e230d340 100644 --- a/zlib/contrib/minizip/zip.h +++ b/zlib/contrib/minizip/zip.h @@ -113,8 +113,8 @@ typedef const char* zipcharpc; #define APPEND_STATUS_CREATEAFTER (1) #define APPEND_STATUS_ADDINZIP (2) -extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); -extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); +extern zipFile ZEXPORT zipOpen(const char *pathname, int append); +extern zipFile ZEXPORT zipOpen64(const void *pathname, int append); /* Create a zipfile. pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on @@ -131,55 +131,55 @@ extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); /* Note : there is no delete function into a zipfile. If you want delete file into a zipfile, you must open a zipfile, and create another - Of couse, you can use RAW reading and writing to copy the file you did not want delte + Of course, you can use RAW reading and writing to copy the file you did not want delete */ -extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, - int append, - zipcharpc* globalcomment, - zlib_filefunc_def* pzlib_filefunc_def)); +extern zipFile ZEXPORT zipOpen2(const char *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc_def* pzlib_filefunc_def); -extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, +extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, - zlib_filefunc64_def* pzlib_filefunc_def)); - -extern zipFile ZEXPORT zipOpen3 OF((const void *pathname, - int append, - zipcharpc* globalcomment, - zlib_filefunc64_32_def* pzlib_filefunc64_32_def)); - -extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level)); - -extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int zip64)); + zlib_filefunc64_def* pzlib_filefunc_def); + +extern zipFile ZEXPORT zipOpen3(const void *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc64_32_def* pzlib_filefunc64_32_def); + +extern int ZEXPORT zipOpenNewFileInZip(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level); + +extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int zip64); /* Open a file in the ZIP for writing. filename : the filename in zip (if NULL, '-' without quote will be used *zipfi contain supplemental information if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local - contains the extrafield data the the local header + contains the extrafield data for the local header if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global - contains the extrafield data the the local header + contains the extrafield data for the global header if comment != NULL, comment contain the comment string method contain the compression method (0 for store, Z_DEFLATED for deflate) level contain the level of compression (can be Z_DEFAULT_COMPRESSION) @@ -189,70 +189,69 @@ extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, */ -extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw)); - - -extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int zip64)); +extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw); + + +extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int zip64); /* Same than zipOpenNewFileInZip, except if raw=1, we write raw file */ -extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting)); - -extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - int zip64 - )); +extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting); + +extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + int zip64); /* Same than zipOpenNewFileInZip2, except @@ -261,47 +260,45 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, crcForCrypting : crc of file to compress (needed for crypting) */ -extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - uLong versionMadeBy, - uLong flagBase - )); - - -extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - uLong versionMadeBy, - uLong flagBase, - int zip64 - )); +extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + uLong versionMadeBy, + uLong flagBase); + + +extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + uLong versionMadeBy, + uLong flagBase, + int zip64); /* Same than zipOpenNewFileInZip4, except versionMadeBy : value for Version made by field @@ -309,25 +306,25 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, */ -extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, - const void* buf, - unsigned len)); +extern int ZEXPORT zipWriteInFileInZip(zipFile file, + const void* buf, + unsigned len); /* Write data in the zipfile */ -extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); +extern int ZEXPORT zipCloseFileInZip(zipFile file); /* Close the current file in the zipfile */ -extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, - uLong uncompressed_size, - uLong crc32)); +extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, + uLong uncompressed_size, + uLong crc32); -extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, - ZPOS64_T uncompressed_size, - uLong crc32)); +extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, + ZPOS64_T uncompressed_size, + uLong crc32); /* Close the current file in the zipfile, for file opened with @@ -335,14 +332,14 @@ extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, uncompressed_size and crc32 are value for the uncompressed size */ -extern int ZEXPORT zipClose OF((zipFile file, - const char* global_comment)); +extern int ZEXPORT zipClose(zipFile file, + const char* global_comment); /* Close the zipfile */ -extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); +extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader); /* zipRemoveExtraInfoBlock - Added by Mathias Svensson diff --git a/zlib/crc32.c b/zlib/crc32.c index f8357b083..6c38f5c04 100644 --- a/zlib/crc32.c +++ b/zlib/crc32.c @@ -103,19 +103,6 @@ # define ARMCRC32 #endif -/* Local functions. */ -local z_crc_t multmodp OF((z_crc_t a, z_crc_t b)); -local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); - -#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) - local z_word_t byte_swap OF((z_word_t word)); -#endif - -#if defined(W) && !defined(ARMCRC32) - local z_crc_t crc_word OF((z_word_t data)); - local z_word_t crc_word_big OF((z_word_t data)); -#endif - #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) /* Swap the bytes in a z_word_t to convert between little and big endian. Any @@ -123,9 +110,7 @@ local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); instruction, if one is available. This assumes that word_t is either 32 bits or 64 bits. */ -local z_word_t byte_swap(word) - z_word_t word; -{ +local z_word_t byte_swap(z_word_t word) { # if W == 8 return (word & 0xff00000000000000) >> 56 | @@ -146,24 +131,77 @@ local z_word_t byte_swap(word) } #endif +#ifdef DYNAMIC_CRC_TABLE +/* ========================================================================= + * Table of powers of x for combining CRC-32s, filled in by make_crc_table() + * below. + */ + local z_crc_t FAR x2n_table[32]; +#else +/* ========================================================================= + * Tables for byte-wise and braided CRC-32 calculations, and a table of powers + * of x for combining CRC-32s, all made by make_crc_table(). + */ +# include "crc32.h" +#endif + /* CRC polynomial. */ #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ -#ifdef DYNAMIC_CRC_TABLE +/* + Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, + reflected. For speed, this requires that a not be zero. + */ +local z_crc_t multmodp(z_crc_t a, z_crc_t b) { + z_crc_t m, p; + + m = (z_crc_t)1 << 31; + p = 0; + for (;;) { + if (a & m) { + p ^= b; + if ((a & (m - 1)) == 0) + break; + } + m >>= 1; + b = b & 1 ? (b >> 1) ^ POLY : b >> 1; + } + return p; +} +/* + Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been + initialized. + */ +local z_crc_t x2nmodp(z_off64_t n, unsigned k) { + z_crc_t p; + + p = (z_crc_t)1 << 31; /* x^0 == 1 */ + while (n) { + if (n & 1) + p = multmodp(x2n_table[k & 31], p); + n >>= 1; + k++; + } + return p; +} + +#ifdef DYNAMIC_CRC_TABLE +/* ========================================================================= + * Build the tables for byte-wise and braided CRC-32 calculations, and a table + * of powers of x for combining CRC-32s. + */ local z_crc_t FAR crc_table[256]; -local z_crc_t FAR x2n_table[32]; -local void make_crc_table OF((void)); #ifdef W local z_word_t FAR crc_big_table[256]; local z_crc_t FAR crc_braid_table[W][256]; local z_word_t FAR crc_braid_big_table[W][256]; - local void braid OF((z_crc_t [][256], z_word_t [][256], int, int)); + local void braid(z_crc_t [][256], z_word_t [][256], int, int); #endif #ifdef MAKECRCH - local void write_table OF((FILE *, const z_crc_t FAR *, int)); - local void write_table32hi OF((FILE *, const z_word_t FAR *, int)); - local void write_table64 OF((FILE *, const z_word_t FAR *, int)); + local void write_table(FILE *, const z_crc_t FAR *, int); + local void write_table32hi(FILE *, const z_word_t FAR *, int); + local void write_table64(FILE *, const z_word_t FAR *, int); #endif /* MAKECRCH */ /* @@ -176,7 +214,6 @@ local void make_crc_table OF((void)); /* Definition of once functionality. */ typedef struct once_s once_t; -local void once OF((once_t *, void (*)(void))); /* Check for the availability of atomics. */ #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ @@ -196,10 +233,7 @@ struct once_s { invoke once() at the same time. The state must be a once_t initialized with ONCE_INIT. */ -local void once(state, init) - once_t *state; - void (*init)(void); -{ +local void once(once_t *state, void (*init)(void)) { if (!atomic_load(&state->done)) { if (atomic_flag_test_and_set(&state->begun)) while (!atomic_load(&state->done)) @@ -222,10 +256,7 @@ struct once_s { /* Test and set. Alas, not atomic, but tries to minimize the period of vulnerability. */ -local int test_and_set OF((int volatile *)); -local int test_and_set(flag) - int volatile *flag; -{ +local int test_and_set(int volatile *flag) { int was; was = *flag; @@ -234,10 +265,7 @@ local int test_and_set(flag) } /* Run the provided init() function once. This is not thread-safe. */ -local void once(state, init) - once_t *state; - void (*init)(void); -{ +local void once(once_t *state, void (*init)(void)) { if (!state->done) { if (test_and_set(&state->begun)) while (!state->done) @@ -279,8 +307,7 @@ local once_t made = ONCE_INIT; combinations of CRC register values and incoming bytes. */ -local void make_crc_table() -{ +local void make_crc_table(void) { unsigned i, j, n; z_crc_t p; @@ -447,11 +474,7 @@ local void make_crc_table() Write the 32-bit values in table[0..k-1] to out, five per line in hexadecimal separated by commas. */ -local void write_table(out, table, k) - FILE *out; - const z_crc_t FAR *table; - int k; -{ +local void write_table(FILE *out, const z_crc_t FAR *table, int k) { int n; for (n = 0; n < k; n++) @@ -464,11 +487,7 @@ local void write_table(out, table, k) Write the high 32-bits of each value in table[0..k-1] to out, five per line in hexadecimal separated by commas. */ -local void write_table32hi(out, table, k) -FILE *out; -const z_word_t FAR *table; -int k; -{ +local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) { int n; for (n = 0; n < k; n++) @@ -484,11 +503,7 @@ int k; bits. If not, then the type cast and format string can be adjusted accordingly. */ -local void write_table64(out, table, k) - FILE *out; - const z_word_t FAR *table; - int k; -{ +local void write_table64(FILE *out, const z_word_t FAR *table, int k) { int n; for (n = 0; n < k; n++) @@ -498,8 +513,7 @@ local void write_table64(out, table, k) } /* Actually do the deed. */ -int main() -{ +int main(void) { make_crc_table(); return 0; } @@ -511,12 +525,7 @@ int main() Generate the little and big-endian braid tables for the given n and z_word_t size w. Each array must have room for w blocks of 256 elements. */ -local void braid(ltl, big, n, w) - z_crc_t ltl[][256]; - z_word_t big[][256]; - int n; - int w; -{ +local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) { int k; z_crc_t i, p, q; for (k = 0; k < w; k++) { @@ -531,69 +540,13 @@ local void braid(ltl, big, n, w) } #endif -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables for byte-wise and braided CRC-32 calculations, and a table of powers - * of x for combining CRC-32s, all made by make_crc_table(). - */ -#include "crc32.h" #endif /* DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Routines used for CRC calculation. Some are also required for the table - * generation above. - */ - -/* - Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, - reflected. For speed, this requires that a not be zero. - */ -local z_crc_t multmodp(a, b) - z_crc_t a; - z_crc_t b; -{ - z_crc_t m, p; - - m = (z_crc_t)1 << 31; - p = 0; - for (;;) { - if (a & m) { - p ^= b; - if ((a & (m - 1)) == 0) - break; - } - m >>= 1; - b = b & 1 ? (b >> 1) ^ POLY : b >> 1; - } - return p; -} - -/* - Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been - initialized. - */ -local z_crc_t x2nmodp(n, k) - z_off64_t n; - unsigned k; -{ - z_crc_t p; - - p = (z_crc_t)1 << 31; /* x^0 == 1 */ - while (n) { - if (n & 1) - p = multmodp(x2n_table[k & 31], p); - n >>= 1; - k++; - } - return p; -} - /* ========================================================================= * This function can be used by asm versions of crc32(), and to force the * generation of the CRC tables in a threaded application. */ -const z_crc_t FAR * ZEXPORT get_crc_table() -{ +const z_crc_t FAR * ZEXPORT get_crc_table(void) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ @@ -619,11 +572,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table() #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ #define Z_BATCH_MIN 800 /* fewest words in a final batch */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, + z_size_t len) { z_crc_t val; z_word_t crc1, crc2; const z_word_t *word; @@ -723,18 +673,14 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) least-significant byte of the word as the first byte of data, without any pre or post conditioning. This is used to combine the CRCs of each braid. */ -local z_crc_t crc_word(data) - z_word_t data; -{ +local z_crc_t crc_word(z_word_t data) { int k; for (k = 0; k < W; k++) data = (data >> 8) ^ crc_table[data & 0xff]; return (z_crc_t)data; } -local z_word_t crc_word_big(data) - z_word_t data; -{ +local z_word_t crc_word_big(z_word_t data) { int k; for (k = 0; k < W; k++) data = (data << 8) ^ @@ -745,11 +691,8 @@ local z_word_t crc_word_big(data) #endif /* ========================================================================= */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, + z_size_t len) { /* Return initial CRC, if requested. */ if (buf == Z_NULL) return 0; @@ -781,8 +724,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) words = (z_word_t const *)buf; /* Do endian check at execution time instead of compile time, since ARM - processors can change the endianess at execution time. If the - compiler knows what the endianess will be, it can optimize out the + processors can change the endianness at execution time. If the + compiler knows what the endianness will be, it can optimize out the check and the unused branch. */ endian = 1; if (*(unsigned char *)&endian) { @@ -1069,20 +1012,13 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) #endif /* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ +unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, + uInt len) { return crc32_z(crc, buf, len); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ +uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ @@ -1090,18 +1026,12 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2) } /* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ +uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) { return crc32_combine64(crc1, crc2, (z_off64_t)len2); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_gen64(len2) - z_off64_t len2; -{ +uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ @@ -1109,17 +1039,11 @@ uLong ZEXPORT crc32_combine_gen64(len2) } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_gen(len2) - z_off_t len2; -{ +uLong ZEXPORT crc32_combine_gen(z_off_t len2) { return crc32_combine_gen64((z_off64_t)len2); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_op(crc1, crc2, op) - uLong crc1; - uLong crc2; - uLong op; -{ +uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) { return multmodp(op, crc1) ^ (crc2 & 0xffffffff); } diff --git a/zlib/deflate.c b/zlib/deflate.c index 4a689db35..012ea8148 100644 --- a/zlib/deflate.c +++ b/zlib/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.13 Copyright 1995-2022 Jean-loup Gailly and Mark Adler "; + " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -60,9 +60,6 @@ const char deflate_copyright[] = copyright string in the executable of your product. */ -/* =========================================================================== - * Function prototypes. - */ typedef enum { need_more, /* block not completed, need more input or more output */ block_done, /* block flush performed */ @@ -70,29 +67,16 @@ typedef enum { finish_done /* finish done, accept no more input or output */ } block_state; -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +typedef block_state (*compress_func)(deflate_state *s, int flush); /* Compression function. Returns the block state after the call. */ -local int deflateStateCheck OF((z_streamp strm)); -local void slide_hash OF((deflate_state *s)); -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); +local block_state deflate_stored(deflate_state *s, int flush); +local block_state deflate_fast(deflate_state *s, int flush); #ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local block_state deflate_rle OF((deflate_state *s, int flush)); -local block_state deflate_huff OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -local uInt longest_match OF((deflate_state *s, IPos cur_match)); - -#ifdef ZLIB_DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); +local block_state deflate_slow(deflate_state *s, int flush); #endif +local block_state deflate_rle(deflate_state *s, int flush); +local block_state deflate_huff(deflate_state *s, int flush); /* =========================================================================== * Local data @@ -195,9 +179,12 @@ local const config configuration_table[10] = { * bit values at the expense of memory usage). We slide even when level == 0 to * keep the hash table consistent if we switch back to level > 0 later. */ -local void slide_hash(s) - deflate_state *s; -{ +#if defined(__has_feature) +# if __has_feature(memory_sanitizer) + __attribute__((no_sanitize("memory"))) +# endif +#endif +local void slide_hash(deflate_state *s) { unsigned n, m; Posf *p; uInt wsize = s->w_size; @@ -221,30 +208,177 @@ local void slide_hash(s) #endif } +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) { + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + zmemcpy(buf, strm->next_in, len); + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, buf, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, buf, len); + } +#endif + strm->next_in += len; + strm->total_in += len; + + return len; +} + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(deflate_state *s) { + unsigned n; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize + MAX_DIST(s)) { + + zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + if (s->insert > s->strstart) + s->insert = s->strstart; + slide_hash(s); + more += wsize; + } + if (s->strm->avail_in == 0) break; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead + s->insert >= MIN_MATCH) { + uInt str = s->strstart - s->insert; + s->ins_h = s->window[str]; + UPDATE_HASH(s, s->ins_h, s->window[str + 1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + while (s->insert) { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + s->insert--; + if (s->lookahead + s->insert < MIN_MATCH) + break; + } + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + zmemzero(s->window + curr, (unsigned)init); + s->high_water = curr + init; + } + else if (s->high_water < (ulg)curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = (ulg)curr + WIN_INIT - s->high_water; + if (init > s->window_size - s->high_water) + init = s->window_size - s->high_water; + zmemzero(s->window + s->high_water, (unsigned)init); + s->high_water += init; + } + } + + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + "not enough room for search"); +} + /* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ +int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, + int stream_size) { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); /* To do: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ +int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, int strategy, + const char *version, int stream_size) { deflate_state *s; int wrap = 1; static const char my_version[] = ZLIB_VERSION; @@ -359,7 +493,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, * symbols from which it is being constructed. */ - s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4); + s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS); s->pending_buf_size = (ulg)s->lit_bufsize * 4; if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || @@ -369,8 +503,14 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, deflateEnd (strm); return Z_MEM_ERROR; } +#ifdef LIT_MEM + s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1)); + s->l_buf = s->pending_buf + (s->lit_bufsize << 2); + s->sym_end = s->lit_bufsize - 1; +#else s->sym_buf = s->pending_buf + s->lit_bufsize; s->sym_end = (s->lit_bufsize - 1) * 3; +#endif /* We avoid equality with lit_bufsize*3 because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. @@ -386,9 +526,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, /* ========================================================================= * Check for a valid deflate stream state. Return 0 if ok, 1 if not. */ -local int deflateStateCheck(strm) - z_streamp strm; -{ +local int deflateStateCheck(z_streamp strm) { deflate_state *s; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) @@ -409,11 +547,8 @@ local int deflateStateCheck(strm) } /* ========================================================================= */ -int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ +int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, + uInt dictLength) { deflate_state *s; uInt str, n; int wrap; @@ -478,11 +613,8 @@ int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) } /* ========================================================================= */ -int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) - z_streamp strm; - Bytef *dictionary; - uInt *dictLength; -{ +int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, + uInt *dictLength) { deflate_state *s; uInt len; @@ -500,9 +632,7 @@ int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) } /* ========================================================================= */ -int ZEXPORT deflateResetKeep(strm) - z_streamp strm; -{ +int ZEXPORT deflateResetKeep(z_streamp strm) { deflate_state *s; if (deflateStateCheck(strm)) { @@ -537,10 +667,32 @@ int ZEXPORT deflateResetKeep(strm) return Z_OK; } +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init(deflate_state *s) { + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->insert = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +} + /* ========================================================================= */ -int ZEXPORT deflateReset(strm) - z_streamp strm; -{ +int ZEXPORT deflateReset(z_streamp strm) { int ret; ret = deflateResetKeep(strm); @@ -550,10 +702,7 @@ int ZEXPORT deflateReset(strm) } /* ========================================================================= */ -int ZEXPORT deflateSetHeader(strm, head) - z_streamp strm; - gz_headerp head; -{ +int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) { if (deflateStateCheck(strm) || strm->state->wrap != 2) return Z_STREAM_ERROR; strm->state->gzhead = head; @@ -561,11 +710,7 @@ int ZEXPORT deflateSetHeader(strm, head) } /* ========================================================================= */ -int ZEXPORT deflatePending(strm, pending, bits) - unsigned *pending; - int *bits; - z_streamp strm; -{ +int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) { if (deflateStateCheck(strm)) return Z_STREAM_ERROR; if (pending != Z_NULL) *pending = strm->state->pending; @@ -575,19 +720,21 @@ int ZEXPORT deflatePending(strm, pending, bits) } /* ========================================================================= */ -int ZEXPORT deflatePrime(strm, bits, value) - z_streamp strm; - int bits; - int value; -{ +int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { deflate_state *s; int put; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; +#ifdef LIT_MEM + if (bits < 0 || bits > 16 || + (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3)) + return Z_BUF_ERROR; +#else if (bits < 0 || bits > 16 || s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; +#endif do { put = Buf_size - s->bi_valid; if (put > bits) @@ -602,11 +749,7 @@ int ZEXPORT deflatePrime(strm, bits, value) } /* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ +int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { deflate_state *s; compress_func func; @@ -651,13 +794,8 @@ int ZEXPORT deflateParams(strm, level, strategy) } /* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ +int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, + int nice_length, int max_chain) { deflate_state *s; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -693,10 +831,7 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) * * Shifts are used to approximate divisions, for speed. */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ +uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { deflate_state *s; uLong fixedlen, storelen, wraplen; @@ -752,7 +887,8 @@ uLong ZEXPORT deflateBound(strm, sourceLen) /* if not default parameters, return one of the conservative bounds */ if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen; + return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) + + wraplen; /* default settings: return tight bound for that case -- ~0.03% overhead plus a small constant */ @@ -765,10 +901,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen) * IN assertion: the stream state is correct and there is enough room in * pending_buf. */ -local void putShortMSB(s, b) - deflate_state *s; - uInt b; -{ +local void putShortMSB(deflate_state *s, uInt b) { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); } @@ -779,9 +912,7 @@ local void putShortMSB(s, b) * applications may wish to modify it to avoid allocating a large * strm->next_out buffer and copying into it. (See also read_buf()). */ -local void flush_pending(strm) - z_streamp strm; -{ +local void flush_pending(z_streamp strm) { unsigned len; deflate_state *s = strm->state; @@ -812,10 +943,7 @@ local void flush_pending(strm) } while (0) /* ========================================================================= */ -int ZEXPORT deflate(strm, flush) - z_streamp strm; - int flush; -{ +int ZEXPORT deflate(z_streamp strm, int flush) { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; @@ -1127,9 +1255,7 @@ int ZEXPORT deflate(strm, flush) } /* ========================================================================= */ -int ZEXPORT deflateEnd(strm) - z_streamp strm; -{ +int ZEXPORT deflateEnd(z_streamp strm) { int status; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1153,11 +1279,10 @@ int ZEXPORT deflateEnd(strm) * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */ -int ZEXPORT deflateCopy(dest, source) - z_streamp dest; - z_streamp source; -{ +int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { #ifdef MAXSEG_64K + (void)dest; + (void)source; return Z_STREAM_ERROR; #else deflate_state *ds; @@ -1181,7 +1306,7 @@ int ZEXPORT deflateCopy(dest, source) ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4); + ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS); if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { @@ -1192,10 +1317,15 @@ int ZEXPORT deflateCopy(dest, source) zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); +#ifdef LIT_MEM + ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1)); + ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2); +#else ds->sym_buf = ds->pending_buf + ds->lit_bufsize; +#endif ds->l_desc.dyn_tree = ds->dyn_ltree; ds->d_desc.dyn_tree = ds->dyn_dtree; @@ -1205,66 +1335,6 @@ int ZEXPORT deflateCopy(dest, source) #endif /* MAXSEG_64K */ } -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local unsigned read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - zmemcpy(buf, strm->next_in, len); - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, buf, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, buf, len); - } -#endif - strm->next_in += len; - strm->total_in += len; - - return len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init(s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->insert = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -} - #ifndef FASTEST /* =========================================================================== * Set match_start to the longest match starting at the given string and @@ -1275,10 +1345,7 @@ local void lm_init(s) * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 * OUT assertion: the match length is not greater than s->lookahead. */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ +local uInt longest_match(deflate_state *s, IPos cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ @@ -1426,10 +1493,7 @@ local uInt longest_match(s, cur_match) /* --------------------------------------------------------------------------- * Optimized version for FASTEST only */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ +local uInt longest_match(deflate_state *s, IPos cur_match) { register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ @@ -1490,19 +1554,23 @@ local uInt longest_match(s, cur_match) /* =========================================================================== * Check that the match at match_start is indeed a match. */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ +local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); + Bytef *back = s->window + (int)match, *here = s->window + start; + IPos len = length; + if (match == (IPos)-1) { + /* match starts one byte before the current window -- just compare the + subsequent length-1 bytes */ + back++; + here++; + len--; + } + if (zmemcmp(back, here, len) != EQUAL) { + fprintf(stderr, " start %u, match %d, length %d\n", + start, (int)match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); + fprintf(stderr, "(%02x %02x)", *back++, *here++); + } while (--len != 0); z_error("invalid match"); } if (z_verbose > 1) { @@ -1514,137 +1582,6 @@ local void check_match(s, start, match, length) # define check_match(s, start, match, length) #endif /* ZLIB_DEBUG */ -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - unsigned n; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize + MAX_DIST(s)) { - - zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - if (s->insert > s->strstart) - s->insert = s->strstart; - slide_hash(s); - more += wsize; - } - if (s->strm->avail_in == 0) break; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead + s->insert >= MIN_MATCH) { - uInt str = s->strstart - s->insert; - s->ins_h = s->window[str]; - UPDATE_HASH(s, s->ins_h, s->window[str + 1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - while (s->insert) { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - s->insert--; - if (s->lookahead + s->insert < MIN_MATCH) - break; - } - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - if (s->high_water < s->window_size) { - ulg curr = s->strstart + (ulg)(s->lookahead); - ulg init; - - if (s->high_water < curr) { - /* Previous high water mark below current data -- zero WIN_INIT - * bytes or up to end of window, whichever is less. - */ - init = s->window_size - curr; - if (init > WIN_INIT) - init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); - s->high_water = curr + init; - } - else if (s->high_water < (ulg)curr + WIN_INIT) { - /* High water mark at or above current data, but below current data - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - * to end of window, whichever is less. - */ - init = (ulg)curr + WIN_INIT - s->high_water; - if (init > s->window_size - s->high_water) - init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); - s->high_water += init; - } - } - - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, - "not enough room for search"); -} - /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. @@ -1687,10 +1624,7 @@ local void fill_window(s) * copied. It is most efficient with large input and output buffers, which * maximizes the opportunities to have a single copy from next_in to next_out. */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_stored(deflate_state *s, int flush) { /* Smallest worthy block size when not flushing or finishing. By default * this is 32K. This can be as small as 507 bytes for memLevel == 1. For * large input and output buffers, the stored block size will be larger. @@ -1874,10 +1808,7 @@ local block_state deflate_stored(s, flush) * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_fast(deflate_state *s, int flush) { IPos hash_head; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ @@ -1976,10 +1907,7 @@ local block_state deflate_fast(s, flush) * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_slow(deflate_state *s, int flush) { IPos hash_head; /* head of hash chain */ int bflush; /* set if current block must be flushed */ @@ -2107,10 +2035,7 @@ local block_state deflate_slow(s, flush) * one. Do not maintain a hash table. (It will be regenerated if this run of * deflate switches away from Z_RLE.) */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_rle(deflate_state *s, int flush) { int bflush; /* set if current block must be flushed */ uInt prev; /* byte at distance one to match */ Bytef *scan, *strend; /* scan goes up to strend for length of run */ @@ -2181,10 +2106,7 @@ local block_state deflate_rle(s, flush) * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. * (It will be regenerated if this run of deflate switches away from Huffman.) */ -local block_state deflate_huff(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_huff(deflate_state *s, int flush) { int bflush; /* set if current block must be flushed */ for (;;) { diff --git a/zlib/deflate.h b/zlib/deflate.h index 1a06cd5f2..300c6ada6 100644 --- a/zlib/deflate.h +++ b/zlib/deflate.h @@ -1,5 +1,5 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2018 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -23,6 +23,10 @@ # define GZIP #endif +/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at + the cost of a larger memory footprint */ +/* #define LIT_MEM */ + /* =========================================================================== * Internal compression state. */ @@ -217,7 +221,14 @@ typedef struct internal_state { /* Depth of each subtree used as tie breaker for trees of equal frequency */ +#ifdef LIT_MEM +# define LIT_BUFS 5 + ushf *d_buf; /* buffer for distances */ + uchf *l_buf; /* buffer for literals/lengths */ +#else +# define LIT_BUFS 4 uchf *sym_buf; /* buffer for distances and literals/lengths */ +#endif uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for @@ -239,7 +250,7 @@ typedef struct internal_state { * - I can't count above 4 */ - uInt sym_next; /* running index in sym_buf */ + uInt sym_next; /* running index in symbol buffer */ uInt sym_end; /* symbol table full when sym_next reaches this */ ulg opt_len; /* bit length of current block with optimal trees */ @@ -291,14 +302,14 @@ typedef struct internal_state { memory checker errors from longest match routines */ /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); +void ZLIB_INTERNAL _tr_init(deflate_state *s); +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last); +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); +void ZLIB_INTERNAL _tr_align(deflate_state *s); +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last); #define d_code(dist) \ ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) @@ -318,6 +329,25 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, extern const uch ZLIB_INTERNAL _dist_code[]; #endif +#ifdef LIT_MEM +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->sym_next] = 0; \ + s->l_buf[s->sym_next++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ + s->d_buf[s->sym_next] = dist; \ + s->l_buf[s->sym_next++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +#else # define _tr_tally_lit(s, c, flush) \ { uch cc = (c); \ s->sym_buf[s->sym_next++] = 0; \ @@ -337,6 +367,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, s->dyn_dtree[d_code(dist)].Freq++; \ flush = (s->sym_next == s->sym_end); \ } +#endif #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) # define _tr_tally_dist(s, distance, length, flush) \ diff --git a/zlib/gzclose.c b/zlib/gzclose.c index caeb99a31..48d6a86f0 100644 --- a/zlib/gzclose.c +++ b/zlib/gzclose.c @@ -8,9 +8,7 @@ /* gzclose() is in a separate file so that it is linked in only if it is used. That way the other gzclose functions can be used instead to avoid linking in unneeded compression or decompression routines. */ -int ZEXPORT gzclose(file) - gzFile file; -{ +int ZEXPORT gzclose(gzFile file) { #ifndef NO_GZCOMPRESS gz_statep state; diff --git a/zlib/gzguts.h b/zlib/gzguts.h index 57faf3716..eba72085b 100644 --- a/zlib/gzguts.h +++ b/zlib/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -7,9 +7,8 @@ # ifndef _LARGEFILE_SOURCE # define _LARGEFILE_SOURCE 1 # endif -# ifdef _FILE_OFFSET_BITS -# undef _FILE_OFFSET_BITS -# endif +# undef _FILE_OFFSET_BITS +# undef _TIME_BITS #endif #ifdef HAVE_HIDDEN @@ -119,8 +118,8 @@ /* gz* functions always use library allocation functions */ #ifndef STDC - extern voidp malloc OF((uInt size)); - extern void free OF((voidpf ptr)); + extern voidp malloc(uInt size); + extern void free(voidpf ptr); #endif /* get errno and strerror definition */ @@ -138,10 +137,10 @@ /* provide prototypes for these when building zlib without LFS */ #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); #endif /* default memLevel */ @@ -203,17 +202,13 @@ typedef struct { typedef gz_state FAR *gz_statep; /* shared functions */ -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); +void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); #if defined UNDER_CE -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); +char ZLIB_INTERNAL *gz_strwinerror(DWORD error); #endif /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t value -- needed when comparing unsigned to z_off64_t, which is signed (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else -unsigned ZLIB_INTERNAL gz_intmax OF((void)); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif +unsigned ZLIB_INTERNAL gz_intmax(void); +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) diff --git a/zlib/gzlib.c b/zlib/gzlib.c index 55da46a45..983153cc8 100644 --- a/zlib/gzlib.c +++ b/zlib/gzlib.c @@ -1,5 +1,5 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -15,10 +15,6 @@ #endif #endif -/* Local functions */ -local void gz_reset OF((gz_statep)); -local gzFile gz_open OF((const void *, int, const char *)); - #if defined UNDER_CE /* Map the Windows error number in ERROR to a locale-dependent error message @@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *)); The gz_strwinerror function does not change the current setting of GetLastError. */ -char ZLIB_INTERNAL *gz_strwinerror(error) - DWORD error; -{ +char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { static char buf[1024]; wchar_t *msgbuf; @@ -72,9 +66,7 @@ char ZLIB_INTERNAL *gz_strwinerror(error) #endif /* UNDER_CE */ /* Reset gzip file state */ -local void gz_reset(state) - gz_statep state; -{ +local void gz_reset(gz_statep state) { state->x.have = 0; /* no output data available */ if (state->mode == GZ_READ) { /* for reading ... */ state->eof = 0; /* not at end of file */ @@ -90,11 +82,7 @@ local void gz_reset(state) } /* Open a gzip file either by name or file descriptor. */ -local gzFile gz_open(path, fd, mode) - const void *path; - int fd; - const char *mode; -{ +local gzFile gz_open(const void *path, int fd, const char *mode) { gz_statep state; z_size_t len; int oflag; @@ -269,26 +257,17 @@ local gzFile gz_open(path, fd, mode) } /* -- see zlib.h -- */ -gzFile ZEXPORT gzopen(path, mode) - const char *path; - const char *mode; -{ +gzFile ZEXPORT gzopen(const char *path, const char *mode) { return gz_open(path, -1, mode); } /* -- see zlib.h -- */ -gzFile ZEXPORT gzopen64(path, mode) - const char *path; - const char *mode; -{ +gzFile ZEXPORT gzopen64(const char *path, const char *mode) { return gz_open(path, -1, mode); } /* -- see zlib.h -- */ -gzFile ZEXPORT gzdopen(fd, mode) - int fd; - const char *mode; -{ +gzFile ZEXPORT gzdopen(int fd, const char *mode) { char *path; /* identifier for error messages */ gzFile gz; @@ -306,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode) /* -- see zlib.h -- */ #ifdef WIDECHAR -gzFile ZEXPORT gzopen_w(path, mode) - const wchar_t *path; - const char *mode; -{ +gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { return gz_open(path, -2, mode); } #endif /* -- see zlib.h -- */ -int ZEXPORT gzbuffer(file, size) - gzFile file; - unsigned size; -{ +int ZEXPORT gzbuffer(gzFile file, unsigned size) { gz_statep state; /* get internal structure and check integrity */ @@ -335,16 +308,14 @@ int ZEXPORT gzbuffer(file, size) /* check and set requested size */ if ((size << 1) < size) return -1; /* need to be able to double it */ - if (size < 2) - size = 2; /* need two bytes to check magic header */ + if (size < 8) + size = 8; /* needed to behave well with flushing */ state->want = size; return 0; } /* -- see zlib.h -- */ -int ZEXPORT gzrewind(file) - gzFile file; -{ +int ZEXPORT gzrewind(gzFile file) { gz_statep state; /* get internal structure */ @@ -365,11 +336,7 @@ int ZEXPORT gzrewind(file) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gzseek64(file, offset, whence) - gzFile file; - z_off64_t offset; - int whence; -{ +z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { unsigned n; z_off64_t ret; gz_statep state; @@ -442,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gzseek(file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ +z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { z_off64_t ret; ret = gzseek64(file, (z_off64_t)offset, whence); @@ -454,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gztell64(file) - gzFile file; -{ +z_off64_t ZEXPORT gztell64(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -471,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gztell(file) - gzFile file; -{ +z_off_t ZEXPORT gztell(gzFile file) { z_off64_t ret; ret = gztell64(file); @@ -481,9 +440,7 @@ z_off_t ZEXPORT gztell(file) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gzoffset64(file) - gzFile file; -{ +z_off64_t ZEXPORT gzoffset64(gzFile file) { z_off64_t offset; gz_statep state; @@ -504,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gzoffset(file) - gzFile file; -{ +z_off_t ZEXPORT gzoffset(gzFile file) { z_off64_t ret; ret = gzoffset64(file); @@ -514,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file) } /* -- see zlib.h -- */ -int ZEXPORT gzeof(file) - gzFile file; -{ +int ZEXPORT gzeof(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -531,10 +484,7 @@ int ZEXPORT gzeof(file) } /* -- see zlib.h -- */ -const char * ZEXPORT gzerror(file, errnum) - gzFile file; - int *errnum; -{ +const char * ZEXPORT gzerror(gzFile file, int *errnum) { gz_statep state; /* get internal structure and check integrity */ @@ -552,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum) } /* -- see zlib.h -- */ -void ZEXPORT gzclearerr(file) - gzFile file; -{ +void ZEXPORT gzclearerr(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -578,11 +526,7 @@ void ZEXPORT gzclearerr(file) memory). Simply save the error message as a static string. If there is an allocation failure constructing the error message, then convert the error to out of memory. */ -void ZLIB_INTERNAL gz_error(state, err, msg) - gz_statep state; - int err; - const char *msg; -{ +void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { /* free previously allocated message and clear */ if (state->msg != NULL) { if (state->err != Z_MEM_ERROR) @@ -619,21 +563,20 @@ void ZLIB_INTERNAL gz_error(state, err, msg) #endif } -#ifndef INT_MAX /* portably return maximum value for an int (when limits.h presumed not available) -- we need to do this to cover cases where 2's complement not used, since C standard permits 1's complement and sign-bit representations, otherwise we could just use ((unsigned)-1) >> 1 */ -unsigned ZLIB_INTERNAL gz_intmax() -{ - unsigned p, q; - - p = 1; +unsigned ZLIB_INTERNAL gz_intmax(void) { +#ifdef INT_MAX + return INT_MAX; +#else + unsigned p = 1, q; do { q = p; p <<= 1; p++; } while (p > q); return q >> 1; -} #endif +} diff --git a/zlib/gzread.c b/zlib/gzread.c index dd7738159..4168cbc88 100644 --- a/zlib/gzread.c +++ b/zlib/gzread.c @@ -5,25 +5,12 @@ #include "gzguts.h" -/* Local functions */ -local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); -local int gz_avail OF((gz_statep)); -local int gz_look OF((gz_statep)); -local int gz_decomp OF((gz_statep)); -local int gz_fetch OF((gz_statep)); -local int gz_skip OF((gz_statep, z_off64_t)); -local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); - /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from state->fd, and update state->eof, state->err, and state->msg as appropriate. This function needs to loop on read(), since read() is not guaranteed to read the number of bytes requested, depending on the type of descriptor. */ -local int gz_load(state, buf, len, have) - gz_statep state; - unsigned char *buf; - unsigned len; - unsigned *have; -{ +local int gz_load(gz_statep state, unsigned char *buf, unsigned len, + unsigned *have) { int ret; unsigned get, max = ((unsigned)-1 >> 2) + 1; @@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have) If strm->avail_in != 0, then the current data is moved to the beginning of the input buffer, and then the remainder of the buffer is loaded with the available data from the input file. */ -local int gz_avail(state) - gz_statep state; -{ +local int gz_avail(gz_statep state) { unsigned got; z_streamp strm = &(state->strm); @@ -88,9 +73,7 @@ local int gz_avail(state) case, all further file reads will be directly to either the output buffer or a user buffer. If decompressing, the inflate state will be initialized. gz_look() will return 0 on success or -1 on failure. */ -local int gz_look(state) - gz_statep state; -{ +local int gz_look(gz_statep state) { z_streamp strm = &(state->strm); /* allocate read buffers and inflate memory */ @@ -170,9 +153,7 @@ local int gz_look(state) data. If the gzip stream completes, state->how is reset to LOOK to look for the next gzip stream or raw data, once state->x.have is depleted. Returns 0 on success, -1 on failure. */ -local int gz_decomp(state) - gz_statep state; -{ +local int gz_decomp(gz_statep state) { int ret = Z_OK; unsigned had; z_streamp strm = &(state->strm); @@ -224,9 +205,7 @@ local int gz_decomp(state) looked for to determine whether to copy or decompress. Returns -1 on error, otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the end of the input file has been reached and all data has been processed. */ -local int gz_fetch(state) - gz_statep state; -{ +local int gz_fetch(gz_statep state) { z_streamp strm = &(state->strm); do { @@ -254,10 +233,7 @@ local int gz_fetch(state) } /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ -local int gz_skip(state, len) - gz_statep state; - z_off64_t len; -{ +local int gz_skip(gz_statep state, z_off64_t len) { unsigned n; /* skip over len bytes or reach end-of-file, whichever comes first */ @@ -289,11 +265,7 @@ local int gz_skip(state, len) input. Return the number of bytes read. If zero is returned, either the end of file was reached, or there was an error. state->err must be consulted in that case to determine which. */ -local z_size_t gz_read(state, buf, len) - gz_statep state; - voidp buf; - z_size_t len; -{ +local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) { z_size_t got; unsigned n; @@ -370,11 +342,7 @@ local z_size_t gz_read(state, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzread(file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ +int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { gz_statep state; /* get internal structure */ @@ -406,12 +374,7 @@ int ZEXPORT gzread(file, buf, len) } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfread(buf, size, nitems, file) - voidp buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ +z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { z_size_t len; gz_statep state; @@ -442,9 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file) #else # undef gzgetc #endif -int ZEXPORT gzgetc(file) - gzFile file; -{ +int ZEXPORT gzgetc(gzFile file) { unsigned char buf[1]; gz_statep state; @@ -469,17 +430,12 @@ int ZEXPORT gzgetc(file) return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; } -int ZEXPORT gzgetc_(file) -gzFile file; -{ +int ZEXPORT gzgetc_(gzFile file) { return gzgetc(file); } /* -- see zlib.h -- */ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ +int ZEXPORT gzungetc(int c, gzFile file) { gz_statep state; /* get internal structure */ @@ -487,6 +443,10 @@ int ZEXPORT gzungetc(c, file) return -1; state = (gz_statep)file; + /* in case this was just opened, set up the input buffer */ + if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) + (void)gz_look(state); + /* check that we're reading and that there's no (serious) error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) @@ -536,11 +496,7 @@ int ZEXPORT gzungetc(c, file) } /* -- see zlib.h -- */ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ +char * ZEXPORT gzgets(gzFile file, char *buf, int len) { unsigned left, n; char *str; unsigned char *eol; @@ -600,9 +556,7 @@ char * ZEXPORT gzgets(file, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzdirect(file) - gzFile file; -{ +int ZEXPORT gzdirect(gzFile file) { gz_statep state; /* get internal structure */ @@ -620,9 +574,7 @@ int ZEXPORT gzdirect(file) } /* -- see zlib.h -- */ -int ZEXPORT gzclose_r(file) - gzFile file; -{ +int ZEXPORT gzclose_r(gzFile file) { int ret, err; gz_statep state; diff --git a/zlib/gzwrite.c b/zlib/gzwrite.c index eb8a0e589..435b4621b 100644 --- a/zlib/gzwrite.c +++ b/zlib/gzwrite.c @@ -5,18 +5,10 @@ #include "gzguts.h" -/* Local functions */ -local int gz_init OF((gz_statep)); -local int gz_comp OF((gz_statep, int)); -local int gz_zero OF((gz_statep, z_off64_t)); -local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); - /* Initialize state for writing a gzip file. Mark initialization by setting state->size to non-zero. Return -1 on a memory allocation failure, or 0 on success. */ -local int gz_init(state) - gz_statep state; -{ +local int gz_init(gz_statep state) { int ret; z_streamp strm = &(state->strm); @@ -70,10 +62,7 @@ local int gz_init(state) deflate() flush value. If flush is Z_FINISH, then the deflate() state is reset to start a new gzip stream. If gz->direct is true, then simply write to the output file without compressing, and ignore flush. */ -local int gz_comp(state, flush) - gz_statep state; - int flush; -{ +local int gz_comp(gz_statep state, int flush) { int ret, writ; unsigned have, put, max = ((unsigned)-1 >> 2) + 1; z_streamp strm = &(state->strm); @@ -151,10 +140,7 @@ local int gz_comp(state, flush) /* Compress len zeros to output. Return -1 on a write error or memory allocation failure by gz_comp(), or 0 on success. */ -local int gz_zero(state, len) - gz_statep state; - z_off64_t len; -{ +local int gz_zero(gz_statep state, z_off64_t len) { int first; unsigned n; z_streamp strm = &(state->strm); @@ -184,11 +170,7 @@ local int gz_zero(state, len) /* Write len bytes from buf to file. Return the number of bytes written. If the returned value is less than len, then there was an error. */ -local z_size_t gz_write(state, buf, len) - gz_statep state; - voidpc buf; - z_size_t len; -{ +local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { z_size_t put = len; /* if len is zero, avoid unnecessary operations */ @@ -252,11 +234,7 @@ local z_size_t gz_write(state, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzwrite(file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ +int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { gz_statep state; /* get internal structure */ @@ -280,12 +258,8 @@ int ZEXPORT gzwrite(file, buf, len) } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) - voidpc buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ +z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, + gzFile file) { z_size_t len; gz_statep state; @@ -310,10 +284,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) } /* -- see zlib.h -- */ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ +int ZEXPORT gzputc(gzFile file, int c) { unsigned have; unsigned char buf[1]; gz_statep state; @@ -358,10 +329,7 @@ int ZEXPORT gzputc(file, c) } /* -- see zlib.h -- */ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ +int ZEXPORT gzputs(gzFile file, const char *s) { z_size_t len, put; gz_statep state; @@ -388,8 +356,7 @@ int ZEXPORT gzputs(file, s) #include /* -- see zlib.h -- */ -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) -{ +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { int len; unsigned left; char *next; @@ -460,8 +427,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) return len; } -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) -{ +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { va_list va; int ret; @@ -474,13 +440,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) #else /* !STDC && !Z_HAVE_STDARG_H */ /* -- see zlib.h -- */ -int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ +int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, + int a4, int a5, int a6, int a7, int a8, int a9, int a10, + int a11, int a12, int a13, int a14, int a15, int a16, + int a17, int a18, int a19, int a20) { unsigned len, left; char *next; gz_statep state; @@ -562,10 +525,7 @@ int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, #endif /* -- see zlib.h -- */ -int ZEXPORT gzflush(file, flush) - gzFile file; - int flush; -{ +int ZEXPORT gzflush(gzFile file, int flush) { gz_statep state; /* get internal structure */ @@ -594,11 +554,7 @@ int ZEXPORT gzflush(file, flush) } /* -- see zlib.h -- */ -int ZEXPORT gzsetparams(file, level, strategy) - gzFile file; - int level; - int strategy; -{ +int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { gz_statep state; z_streamp strm; @@ -609,7 +565,7 @@ int ZEXPORT gzsetparams(file, level, strategy) strm = &(state->strm); /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) + if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct) return Z_STREAM_ERROR; /* if no change is requested, then do nothing */ @@ -636,9 +592,7 @@ int ZEXPORT gzsetparams(file, level, strategy) } /* -- see zlib.h -- */ -int ZEXPORT gzclose_w(file) - gzFile file; -{ +int ZEXPORT gzclose_w(gzFile file) { int ret = Z_OK; gz_statep state; diff --git a/zlib/infback.c b/zlib/infback.c index babeaf180..e7b25b307 100644 --- a/zlib/infback.c +++ b/zlib/infback.c @@ -15,9 +15,6 @@ #include "inflate.h" #include "inffast.h" -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - /* strm provides memory allocation functions in zalloc and zfree, or Z_NULL to use the library memory allocation functions. @@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state)); windowBits is in the range 8..15, and window is a user-supplied window and output buffer that is 2**windowBits bytes. */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ +int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, const char *version, + int stream_size) { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || @@ -80,9 +73,7 @@ int stream_size; used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ +local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; @@ -248,13 +239,8 @@ struct inflate_state FAR *state; inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is Z_NULL or the state was not initialized. */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ +int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc) { struct inflate_state FAR *state; z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ @@ -632,9 +618,7 @@ void FAR *out_desc; return ret; } -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ +int ZEXPORT inflateBackEnd(z_streamp strm) { if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; ZFREE(strm, strm->state); diff --git a/zlib/inffast.c b/zlib/inffast.c index 1fec7f363..9354676e7 100644 --- a/zlib/inffast.c +++ b/zlib/inffast.c @@ -47,10 +47,7 @@ requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ -void ZLIB_INTERNAL inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) { struct inflate_state FAR *state; z_const unsigned char FAR *in; /* local strm->next_in */ z_const unsigned char FAR *last; /* have enough input while in < last */ diff --git a/zlib/inffast.h b/zlib/inffast.h index e5c1aa4ca..49c6d156c 100644 --- a/zlib/inffast.h +++ b/zlib/inffast.h @@ -8,4 +8,4 @@ subject to change. Applications should only use zlib.h. */ -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); diff --git a/zlib/inflate.c b/zlib/inflate.c index 8acbef44e..94ecff015 100644 --- a/zlib/inflate.c +++ b/zlib/inflate.c @@ -91,20 +91,7 @@ # endif #endif -/* function prototypes */ -local int inflateStateCheck OF((z_streamp strm)); -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, - unsigned copy)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, - unsigned len)); - -local int inflateStateCheck(strm) -z_streamp strm; -{ +local int inflateStateCheck(z_streamp strm) { struct inflate_state FAR *state; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) @@ -116,9 +103,7 @@ z_streamp strm; return 0; } -int ZEXPORT inflateResetKeep(strm) -z_streamp strm; -{ +int ZEXPORT inflateResetKeep(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -142,9 +127,7 @@ z_streamp strm; return Z_OK; } -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ +int ZEXPORT inflateReset(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -155,10 +138,7 @@ z_streamp strm; return inflateResetKeep(strm); } -int ZEXPORT inflateReset2(strm, windowBits) -z_streamp strm; -int windowBits; -{ +int ZEXPORT inflateReset2(z_streamp strm, int windowBits) { int wrap; struct inflate_state FAR *state; @@ -195,12 +175,8 @@ int windowBits; return inflateReset(strm); } -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ +int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size) { int ret; struct inflate_state FAR *state; @@ -239,22 +215,17 @@ int stream_size; return ret; } -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ +int ZEXPORT inflateInit_(z_streamp strm, const char *version, + int stream_size) { return inflateInit2_(strm, DEF_WBITS, version, stream_size); } -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ +int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + if (bits == 0) + return Z_OK; state = (struct inflate_state FAR *)strm->state; if (bits < 0) { state->hold = 0; @@ -278,9 +249,7 @@ int value; used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ +local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; @@ -342,7 +311,7 @@ struct inflate_state FAR *state; a.out > inffixed.h */ -void makefixed() +void makefixed(void) { unsigned low, size; struct inflate_state state; @@ -396,11 +365,7 @@ void makefixed() output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -local int updatewindow(strm, end, copy) -z_streamp strm; -const Bytef *end; -unsigned copy; -{ +local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) { struct inflate_state FAR *state; unsigned dist; @@ -622,10 +587,7 @@ unsigned copy; will return Z_BUF_ERROR if it has not reached the end of the stream. */ -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ +int ZEXPORT inflate(z_streamp strm, int flush) { struct inflate_state FAR *state; z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ @@ -1301,9 +1263,7 @@ int flush; return ret; } -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ +int ZEXPORT inflateEnd(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1315,11 +1275,8 @@ z_streamp strm; return Z_OK; } -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) -z_streamp strm; -Bytef *dictionary; -uInt *dictLength; -{ +int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, + uInt *dictLength) { struct inflate_state FAR *state; /* check state */ @@ -1338,11 +1295,8 @@ uInt *dictLength; return Z_OK; } -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ +int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, + uInt dictLength) { struct inflate_state FAR *state; unsigned long dictid; int ret; @@ -1373,10 +1327,7 @@ uInt dictLength; return Z_OK; } -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ +int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) { struct inflate_state FAR *state; /* check state */ @@ -1401,11 +1352,8 @@ gz_headerp head; called again with more data and the *have state. *have is initialized to zero for the first call. */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -const unsigned char FAR *buf; -unsigned len; -{ +local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, + unsigned len) { unsigned got; unsigned next; @@ -1424,9 +1372,7 @@ unsigned len; return next; } -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ +int ZEXPORT inflateSync(z_streamp strm) { unsigned len; /* number of bytes to look at or looked at */ int flags; /* temporary to save header status */ unsigned long in, out; /* temporary to save total_in and total_out */ @@ -1441,7 +1387,7 @@ z_streamp strm; /* if first time, start search in bit buffer */ if (state->mode != SYNC) { state->mode = SYNC; - state->hold <<= state->bits & 7; + state->hold >>= state->bits & 7; state->bits -= state->bits & 7; len = 0; while (state->bits >= 8) { @@ -1482,9 +1428,7 @@ z_streamp strm; block. When decompressing, PPP checks that at the end of input packet, inflate is waiting for these length bytes. */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ +int ZEXPORT inflateSyncPoint(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1492,10 +1436,7 @@ z_streamp strm; return state->mode == STORED && state->bits == 0; } -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ +int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { struct inflate_state FAR *state; struct inflate_state FAR *copy; unsigned char FAR *window; @@ -1539,10 +1480,7 @@ z_streamp source; return Z_OK; } -int ZEXPORT inflateUndermine(strm, subvert) -z_streamp strm; -int subvert; -{ +int ZEXPORT inflateUndermine(z_streamp strm, int subvert) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1557,10 +1495,7 @@ int subvert; #endif } -int ZEXPORT inflateValidate(strm, check) -z_streamp strm; -int check; -{ +int ZEXPORT inflateValidate(z_streamp strm, int check) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1572,9 +1507,7 @@ int check; return Z_OK; } -long ZEXPORT inflateMark(strm) -z_streamp strm; -{ +long ZEXPORT inflateMark(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) @@ -1585,9 +1518,7 @@ z_streamp strm; (state->mode == MATCH ? state->was - state->length : 0)); } -unsigned long ZEXPORT inflateCodesUsed(strm) -z_streamp strm; -{ +unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return (unsigned long)-1; state = (struct inflate_state FAR *)strm->state; diff --git a/zlib/inftrees.c b/zlib/inftrees.c index 57d2793be..98cfe1644 100644 --- a/zlib/inftrees.c +++ b/zlib/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2022 Mark Adler + * Copyright (C) 1995-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.13 Copyright 1995-2022 Mark Adler "; + " inflate 1.3.1 Copyright 1995-2024 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -29,14 +29,9 @@ const char inflate_copyright[] = table index bits. It will differ if the request is greater than the longest code or if it is less than the shortest code. */ -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work) { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ unsigned min, max; /* minimum and maximum code lengths */ @@ -62,7 +57,7 @@ unsigned short FAR *work; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 194, 65}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, diff --git a/zlib/inftrees.h b/zlib/inftrees.h index f53665311..396f74b5d 100644 --- a/zlib/inftrees.h +++ b/zlib/inftrees.h @@ -41,8 +41,8 @@ typedef struct { examples/enough.c found in the zlib distribution. The arguments to that program are the number of symbols, the initial root table size, and the maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the + returns 852, and "enough 30 6 15" for distance codes returns 592. The + initial root table size (9 or 6) is found in the fifth argument of the inflate_table() calls in inflate.c and infback.c. If the root table size is changed, then these maximum sizes would be need to be recalculated and updated. */ @@ -57,6 +57,6 @@ typedef enum { DISTS } codetype; -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work); diff --git a/zlib/resync_zlib b/zlib/resync_zlib index 2516582c0..8b0612ef1 100755 --- a/zlib/resync_zlib +++ b/zlib/resync_zlib @@ -10,8 +10,8 @@ git checkout -- zlib mv zlib zlib.old -tar -xzvf ../../Downloads/zlib-1.2.13.tar.gz -mv zlib-1.2.13 zlib +tar -xzvf ../../Downloads/zlib-1.3.1.tar.gz +mv zlib-1.3.1 zlib cd zlib mv doc/algorithm.txt . @@ -32,10 +32,12 @@ rm -f configure rm -f CMakeLists.txt rm -f INDEX rm -f Makefile +rm -f Makefile.in rm -f make_vms.com rm -f treebuild.xml rm -f zlib2ansi rm -f zconf.h.cmakein +rm -f zconf.h.in rm -f zlib.3.pdf rm -f zlib.map rm -f zlib.pc.cmakein @@ -49,6 +51,7 @@ rm -fr contrib/infback9 rm -fr contrib/iostream rm -fr contrib/iostream2 rm -fr contrib/iostream3 +rm -fr contrib/nuget rm -fr contrib/pascal rm -fr contrib/puff rm -fr contrib/README.contrib @@ -63,15 +66,6 @@ cd .. find zlib | sort > zlib.new.list find zlib.old | sort > zlib.old.list -# copy patches -cp -p zlib.old/contrib/minizip/ioapi.c.patch zlib/contrib/minizip - -# apply patches -cd zlib/contrib/minizip -patch < ioapi.c.patch -cd ../.. - -cd .. cp resync_zlib zlib echo "you must manually edit README.gpsbabel" diff --git a/zlib/trees.c b/zlib/trees.c index 5f305c472..6a523ef34 100644 --- a/zlib/trees.c +++ b/zlib/trees.c @@ -1,5 +1,5 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2021 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -122,39 +122,116 @@ struct static_tree_desc_s { int max_length; /* max bit length for the codes */ }; -local const static_tree_desc static_l_desc = +#ifdef NO_INIT_GLOBAL_POINTERS +# define TCONST +#else +# define TCONST const +#endif + +local TCONST static_tree_desc static_l_desc = {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; -local const static_tree_desc static_d_desc = +local TCONST static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; -local const static_tree_desc static_bl_desc = +local TCONST static_tree_desc static_bl_desc = {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; /* =========================================================================== - * Local (static) routines in this file. + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 */ +local unsigned bi_reverse(unsigned code, int len) { + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, const ct_data *ltree, - const ct_data *dtree)); -local int detect_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned code, int len)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(deflate_state *s) { + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(deflate_state *s) { + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef ZLIB_DEBUG + s->bits_sent = (s->bits_sent + 7) & ~7; +#endif +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) { + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + unsigned code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + code = (code + bl_count[bits - 1]) << 1; + next_code[bits] = (ush)code; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, + "inconsistent bit counts"); + Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); + + for (n = 0; n <= max_code; n++) { + int len = tree[n].Len; + if (len == 0) continue; + /* Now reverse the bits */ + tree[n].Code = (ush)bi_reverse(next_code[len]++, len); + + Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", + n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); + } +} #ifdef GEN_TREES_H -local void gen_trees_header OF((void)); +local void gen_trees_header(void); #endif #ifndef ZLIB_DEBUG @@ -167,27 +244,12 @@ local void gen_trees_header OF((void)); send_bits(s, tree[c].Code, tree[c].Len); } #endif -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ #ifdef ZLIB_DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ +local void send_bits(deflate_state *s, int value, int length) { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); s->bits_sent += (ulg)length; @@ -229,8 +291,7 @@ local void send_bits(s, value, length) /* =========================================================================== * Initialize the various 'constant' tables. */ -local void tr_static_init() -{ +local void tr_static_init(void) { #if defined(GEN_TREES_H) || !defined(STDC) static int static_init_done = 0; int n; /* iterates over tree elements */ @@ -323,8 +384,7 @@ local void tr_static_init() ((i) == (last)? "\n};\n\n" : \ ((i) % (width) == (width) - 1 ? ",\n" : ", ")) -void gen_trees_header() -{ +void gen_trees_header(void) { FILE *header = fopen("trees.h", "w"); int i; @@ -373,12 +433,26 @@ void gen_trees_header() } #endif /* GEN_TREES_H */ +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(deflate_state *s) { + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->sym_next = s->matches = 0; +} + /* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ -void ZLIB_INTERNAL _tr_init(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_init(deflate_state *s) { tr_static_init(); s->l_desc.dyn_tree = s->dyn_ltree; @@ -401,24 +475,6 @@ void ZLIB_INTERNAL _tr_init(s) init_block(s); } -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->sym_next = s->matches = 0; -} - #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ @@ -448,11 +504,7 @@ local void init_block(s) * when the heap property is re-established (each father smaller than its * two sons). */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ +local void pqdownheap(deflate_state *s, ct_data *tree, int k) { int v = s->heap[k]; int j = k << 1; /* left son of k */ while (j <= s->heap_len) { @@ -483,10 +535,7 @@ local void pqdownheap(s, tree, k) * The length opt_len is updated; static_len is also updated if stree is * not null. */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ +local void gen_bitlen(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; int max_code = desc->max_code; const ct_data *stree = desc->stat_desc->static_tree; @@ -561,48 +610,9 @@ local void gen_bitlen(s, desc) } } -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes(tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - unsigned code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - code = (code + bl_count[bits - 1]) << 1; - next_code[bits] = (ush)code; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, - "inconsistent bit counts"); - Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); - - for (n = 0; n <= max_code; n++) { - int len = tree[n].Len; - if (len == 0) continue; - /* Now reverse the bits */ - tree[n].Code = (ush)bi_reverse(next_code[len]++, len); - - Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", - n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); - } -} +#ifdef DUMP_BL_TREE +# include +#endif /* =========================================================================== * Construct one Huffman tree and assigns the code bit strings and lengths. @@ -612,10 +622,7 @@ local void gen_codes(tree, max_code, bl_count) * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. */ -local void build_tree(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ +local void build_tree(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; const ct_data *stree = desc->stat_desc->static_tree; int elems = desc->stat_desc->elems; @@ -700,11 +707,7 @@ local void build_tree(s, desc) * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. */ -local void scan_tree(s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ +local void scan_tree(deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ @@ -745,11 +748,7 @@ local void scan_tree(s, tree, max_code) * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ -local void send_tree(s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ +local void send_tree(deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ @@ -796,9 +795,7 @@ local void send_tree(s, tree, max_code) * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ -local int build_bl_tree(s) - deflate_state *s; -{ +local int build_bl_tree(deflate_state *s) { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ @@ -831,10 +828,8 @@ local int build_bl_tree(s) * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ +local void send_all_trees(deflate_state *s, int lcodes, int dcodes, + int blcodes) { int rank; /* index in bl_order */ Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); @@ -860,12 +855,8 @@ local void send_all_trees(s, lcodes, dcodes, blcodes) /* =========================================================================== * Send a stored block */ -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last) { send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ bi_windup(s); /* align on byte boundary */ put_short(s, (ush)stored_len); @@ -884,9 +875,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) /* =========================================================================== * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) */ -void ZLIB_INTERNAL _tr_flush_bits(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { bi_flush(s); } @@ -894,9 +883,7 @@ void ZLIB_INTERNAL _tr_flush_bits(s) * Send one empty static block to give enough lookahead for inflate. * This takes 10 bits, of which 7 may remain in the bit buffer. */ -void ZLIB_INTERNAL _tr_align(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_align(deflate_state *s) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef ZLIB_DEBUG @@ -905,16 +892,108 @@ void ZLIB_INTERNAL _tr_align(s) bi_flush(s); } +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(deflate_state *s, const ct_data *ltree, + const ct_data *dtree) { + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned sx = 0; /* running index in symbol buffers */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->sym_next != 0) do { +#ifdef LIT_MEM + dist = s->d_buf[sx]; + lc = s->l_buf[sx++]; +#else + dist = s->sym_buf[sx++] & 0xff; + dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; + lc = s->sym_buf[sx++]; +#endif + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code + LITERALS + 1, ltree); /* send length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= (unsigned)base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check for no overlay of pending_buf on needed symbols */ +#ifdef LIT_MEM + Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow"); +#else + Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); +#endif + + } while (sx < s->sym_next); + + send_code(s, END_BLOCK, ltree); +} + +/* =========================================================================== + * Check if the data type is TEXT or BINARY, using the following algorithm: + * - TEXT if the two conditions below are satisfied: + * a) There are no non-portable control characters belonging to the + * "block list" (0..6, 14..25, 28..31). + * b) There is at least one printable character belonging to the + * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). + * - BINARY otherwise. + * - The following partially-portable control characters form a + * "gray list" that is ignored in this detection algorithm: + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). + * IN assertion: the fields Freq of dyn_ltree are set. + */ +local int detect_data_type(deflate_state *s) { + /* block_mask is the bit mask of block-listed bytes + * set bits 0..6, 14..25, and 28..31 + * 0xf3ffc07f = binary 11110011111111111100000001111111 + */ + unsigned long block_mask = 0xf3ffc07fUL; + int n; + + /* Check for non-textual ("block-listed") bytes. */ + for (n = 0; n <= 31; n++, block_mask >>= 1) + if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) + return Z_BINARY; + + /* Check for textual ("allow-listed") bytes. */ + if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 + || s->dyn_ltree[13].Freq != 0) + return Z_TEXT; + for (n = 32; n < LITERALS; n++) + if (s->dyn_ltree[n].Freq != 0) + return Z_TEXT; + + /* There are no "block-listed" or "allow-listed" bytes: + * this stream either is empty or has tolerated ("gray-listed") bytes only. + */ + return Z_BINARY; +} + /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and write out the encoded block. */ -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ @@ -1011,14 +1090,15 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ -int ZLIB_INTERNAL _tr_tally(s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */ -{ +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { +#ifdef LIT_MEM + s->d_buf[s->sym_next] = (ush)dist; + s->l_buf[s->sym_next++] = (uch)lc; +#else s->sym_buf[s->sym_next++] = (uch)dist; s->sym_buf[s->sym_next++] = (uch)(dist >> 8); s->sym_buf[s->sym_next++] = (uch)lc; +#endif if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; @@ -1035,147 +1115,3 @@ int ZLIB_INTERNAL _tr_tally(s, dist, lc) } return (s->sym_next == s->sym_end); } - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - const ct_data *ltree; /* literal tree */ - const ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned sx = 0; /* running index in sym_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->sym_next != 0) do { - dist = s->sym_buf[sx++] & 0xff; - dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; - lc = s->sym_buf[sx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code + LITERALS + 1, ltree); /* send length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= (unsigned)base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and sym_buf is ok: */ - Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); - - } while (sx < s->sym_next); - - send_code(s, END_BLOCK, ltree); -} - -/* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "block list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local int detect_data_type(s) - deflate_state *s; -{ - /* block_mask is the bit mask of block-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - unsigned long block_mask = 0xf3ffc07fUL; - int n; - - /* Check for non-textual ("block-listed") bytes. */ - for (n = 0; n <= 31; n++, block_mask >>= 1) - if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) - return Z_BINARY; - - /* Check for textual ("allow-listed") bytes. */ - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 - || s->dyn_ltree[13].Freq != 0) - return Z_TEXT; - for (n = 32; n < LITERALS; n++) - if (s->dyn_ltree[n].Freq != 0) - return Z_TEXT; - - /* There are no "block-listed" or "allow-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef ZLIB_DEBUG - s->bits_sent = (s->bits_sent + 7) & ~7; -#endif -} diff --git a/zlib/uncompr.c b/zlib/uncompr.c index f9532f46c..5e256663b 100644 --- a/zlib/uncompr.c +++ b/zlib/uncompr.c @@ -24,12 +24,8 @@ Z_DATA_ERROR if the input data was corrupted, including if the input data is an incomplete zlib stream. */ -int ZEXPORT uncompress2(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong *sourceLen; -{ +int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong *sourceLen) { z_stream stream; int err; const uInt max = (uInt)-1; @@ -83,11 +79,7 @@ int ZEXPORT uncompress2(dest, destLen, source, sourceLen) err; } -int ZEXPORT uncompress(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ +int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen) { return uncompress2(dest, destLen, source, &sourceLen); } diff --git a/zlib/zconf.h b/zlib/zconf.h index bf977d3e7..62adc8d84 100644 --- a/zlib/zconf.h +++ b/zlib/zconf.h @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -241,7 +241,11 @@ #endif #ifdef Z_SOLO - typedef unsigned long z_size_t; +# ifdef _WIN64 + typedef unsigned long long z_size_t; +# else + typedef unsigned long z_size_t; +# endif #else # define z_longlong long long # if defined(NO_SIZE_T) @@ -296,14 +300,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have @@ -520,7 +516,7 @@ typedef uLong FAR uLongf; #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# if defined(_WIN32) && !defined(__GNUC__) # define z_off64_t __int64 # else # define z_off64_t z_off_t diff --git a/zlib/zconf.h.in b/zlib/zconf.h.in deleted file mode 100644 index bf977d3e7..000000000 --- a/zlib/zconf.h.in +++ /dev/null @@ -1,547 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols and init macros */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define adler32_z z_adler32_z -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define crc32_combine_gen z_crc32_combine_gen -# define crc32_combine_gen64 z_crc32_combine_gen64 -# define crc32_combine_op z_crc32_combine_op -# define crc32_z z_crc32_z -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateGetDictionary z_deflateGetDictionary -# define deflateInit z_deflateInit -# define deflateInit2 z_deflateInit2 -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzfread z_gzfread -# define gzfwrite z_gzfwrite -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzvprintf z_gzvprintf -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit z_inflateBackInit -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCodesUsed z_inflateCodesUsed -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetDictionary z_inflateGetDictionary -# define inflateGetHeader z_inflateGetHeader -# define inflateInit z_inflateInit -# define inflateInit2 z_inflateInit2 -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateResetKeep z_inflateResetKeep -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateValidate z_inflateValidate -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# define uncompress2 z_uncompress2 -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -#ifdef Z_SOLO - typedef unsigned long z_size_t; -#else -# define z_longlong long long -# if defined(NO_SIZE_T) - typedef unsigned NO_SIZE_T z_size_t; -# elif defined(STDC) -# include - typedef size_t z_size_t; -# else - typedef unsigned long z_size_t; -# endif -# undef z_longlong -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus about 7 kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#ifndef Z_HAVE_UNISTD_H -# ifdef __WATCOMC__ -# define Z_HAVE_UNISTD_H -# endif -#endif -#ifndef Z_HAVE_UNISTD_H -# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32) -# define Z_HAVE_UNISTD_H -# endif -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/zlib/zlib.3 b/zlib/zlib.3 index 6f6e91404..c716020ea 100644 --- a/zlib/zlib.3 +++ b/zlib/zlib.3 @@ -1,4 +1,4 @@ -.TH ZLIB 3 "13 Oct 2022" +.TH ZLIB 3 "22 Jan 2024" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS @@ -105,9 +105,9 @@ before asking for help. Send questions and/or comments to zlib@gzip.org, or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). .SH AUTHORS AND LICENSE -Version 1.2.13 +Version 1.3.1 .LP -Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler +Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler .LP This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/zlib/zlib.h b/zlib/zlib.h index 953cb5012..8d4b932ea 100644 --- a/zlib/zlib.h +++ b/zlib/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.13, October 13th, 2022 + version 1.3.1, January 22nd, 2024 - Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.13" -#define ZLIB_VERNUM 0x12d0 +#define ZLIB_VERSION "1.3.1" +#define ZLIB_VERNUM 0x1310 #define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 13 +#define ZLIB_VER_MINOR 3 +#define ZLIB_VER_REVISION 1 #define ZLIB_VER_SUBREVISION 0 /* @@ -78,8 +78,8 @@ extern "C" { even in the case of corrupted input. */ -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); +typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); +typedef void (*free_func)(voidpf opaque, voidpf address); struct internal_state; @@ -217,7 +217,7 @@ typedef gz_header FAR *gz_headerp; /* basic functions */ -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +ZEXTERN const char * ZEXPORT zlibVersion(void); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check @@ -225,12 +225,12 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); */ /* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); +ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. + allocation functions. total_in, total_out, adler, and msg are initialized. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all @@ -247,7 +247,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); */ -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -320,8 +320,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. + avail_out is greater than six when the flush marker begins, in order to avoid + repeated flush markers upon calling deflate() again when avail_out == 0. If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was @@ -360,7 +360,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -375,7 +375,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateInit(z_streamp strm); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by @@ -383,7 +383,8 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); read or consumed. The allocation of a sliding window will be deferred to the first call of inflate (if the decompression does not complete on the first call). If zalloc and zfree are set to Z_NULL, inflateInit updates - them to use default allocation functions. + them to use default allocation functions. total_in, total_out, adler, and + msg are initialized. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the @@ -397,7 +398,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); */ -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -517,7 +518,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -535,12 +536,12 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); */ /* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); +ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy); This is another version of deflateInit with more compression options. The fields zalloc, zfree and opaque must be initialized before by the caller. @@ -607,9 +608,9 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. When using the zlib format, this @@ -651,9 +652,9 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, not perform any compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); +ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); /* Returns the sliding dictionary being maintained by deflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied @@ -673,8 +674,8 @@ ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, stream state is inconsistent. */ -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); +ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, + z_streamp source); /* Sets the destination stream as a complete copy of the source stream. @@ -691,20 +692,20 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateReset(z_streamp strm); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state. The stream will leave the compression level and any other attributes that may have been - set unchanged. + set unchanged. total_in, total_out, adler, and msg are initialized. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); +ZEXTERN int ZEXPORT deflateParams(z_streamp strm, + int level, + int strategy); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2(). This can be @@ -729,7 +730,7 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, Then no more input data should be provided before the deflateParams() call. If this is done, the old level and strategy will be applied to the data compressed before deflateParams(), and the new level and strategy will be - applied to the the data compressed after deflateParams(). + applied to the data compressed after deflateParams(). deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if @@ -740,11 +741,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, retried with more output space. */ -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); +ZEXTERN int ZEXPORT deflateTune(z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for @@ -757,8 +758,8 @@ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); +ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, + uLong sourceLen); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or @@ -772,9 +773,9 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, than Z_FINISH or Z_NO_FLUSH are used. */ -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); +ZEXTERN int ZEXPORT deflatePending(z_streamp strm, + unsigned *pending, + int *bits); /* deflatePending() returns the number of bytes and bits of output that have been generated, but not yet provided in the available output. The bytes not @@ -787,9 +788,9 @@ ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, stream state was inconsistent. */ -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); +ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, + int bits, + int value); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits @@ -804,8 +805,8 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, source stream state was inconsistent. */ -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); +ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, + gz_headerp head); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called @@ -821,16 +822,17 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gzip file" and give up. If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). + the time set to zero, and os set to the current operating system, with no + extra, name, or comment fields. The gzip header is returned to the default + state by deflateReset(). deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); +ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, + int windowBits); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized @@ -883,9 +885,9 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, deferred until inflate() is called. */ -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, @@ -906,9 +908,9 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, inflate(). */ -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); +ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); /* Returns the sliding dictionary being maintained by inflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied @@ -921,7 +923,7 @@ ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, stream state is inconsistent. */ -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateSync(z_streamp strm); /* Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all @@ -934,14 +936,14 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); inflateSync returns Z_OK if a possible full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. + In the success case, the application may save the current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. */ -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); +ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, + z_streamp source); /* Sets the destination stream as a complete copy of the source stream. @@ -956,18 +958,19 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateReset(z_streamp strm); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. + total_in, total_out, adler, and msg are initialized. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); +ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, + int windowBits); /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted @@ -980,9 +983,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, the windowBits parameter is invalid. */ -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); +ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, + int bits, + int value); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the @@ -1001,7 +1004,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, stream state was inconsistent. */ -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +ZEXTERN long ZEXPORT inflateMark(z_streamp strm); /* This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the @@ -1029,8 +1032,8 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); source stream state was inconsistent. */ -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); +ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, + gz_headerp head); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after @@ -1070,8 +1073,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, */ /* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); +ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, + unsigned char FAR *window); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized @@ -1091,13 +1094,13 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, the version of the header file. */ -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); +typedef unsigned (*in_func)(void FAR *, + z_const unsigned char FAR * FAR *); +typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); +ZEXTERN int ZEXPORT inflateBack(z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is potentially more efficient than @@ -1165,7 +1168,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, cannot return Z_OK. */ -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); /* All memory allocated by inflateBackInit() is freed. @@ -1173,7 +1176,7 @@ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); state was inconsistent. */ -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +ZEXTERN uLong ZEXPORT zlibCompileFlags(void); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: @@ -1226,8 +1229,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); you need special options. */ -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1241,9 +1244,9 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, buffer. */ -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); +ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte @@ -1257,15 +1260,15 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, Z_STREAM_ERROR if the level parameter is invalid. */ -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1282,8 +1285,8 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, buffer with the uncompressed data up to that point. */ -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong *sourceLen)); +ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen); /* Same as uncompress, except that sourceLen is a pointer, where the length of the source is *sourceLen. On return, *sourceLen is the number of @@ -1302,7 +1305,7 @@ ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ /* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); Open the gzip (.gz) file at path for reading and decompressing, or compressing and writing. The mode parameter is as in fopen ("rb" or "wb") @@ -1339,7 +1342,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); file could not be opened. */ -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); /* Associate a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (if the file has @@ -1362,7 +1365,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); will not detect if fd is invalid (unless fd is -1). */ -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); /* Set the internal buffer size used by this library's functions for file to size. The default buffer size is 8192 bytes. This function must be called @@ -1378,7 +1381,7 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); too late. */ -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); /* Dynamically update the compression level and strategy for file. See the description of deflateInit2 for the meaning of these parameters. Previously @@ -1389,7 +1392,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); or Z_MEM_ERROR if there is a memory allocation error. */ -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); /* Read and decompress up to len uncompressed bytes from file into buf. If the input file is not in gzip format, gzread copies the given number of @@ -1419,8 +1422,8 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); Z_STREAM_ERROR. */ -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, - gzFile file)); +ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, + gzFile file); /* Read and decompress up to nitems items of size size from file into buf, otherwise operating as gzread() does. This duplicates the interface of @@ -1445,14 +1448,14 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, file, resetting and retrying on end-of-file, when size is not 1. */ -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); +ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); /* Compress and write the len uncompressed bytes at buf to file. gzwrite returns the number of uncompressed bytes written or 0 in case of error. */ -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, - z_size_t nitems, gzFile file)); +ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, + z_size_t nitems, gzFile file); /* Compress and write nitems items of size size from buf to file, duplicating the interface of stdio's fwrite(), with size_t request and return types. If @@ -1465,7 +1468,7 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, is returned, and the error state is set to Z_STREAM_ERROR. */ -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); /* Convert, format, compress, and write the arguments (...) to file under control of the string format, as in fprintf. gzprintf returns the number of @@ -1480,7 +1483,7 @@ ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); This can be determined using zlibCompileFlags(). */ -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); /* Compress and write the given null-terminated string s to file, excluding the terminating null character. @@ -1488,7 +1491,7 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); gzputs returns the number of characters written, or -1 in case of error. */ -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); /* Read and decompress bytes from file into buf, until len-1 characters are read, or until a newline character is read and transferred to buf, or an @@ -1502,13 +1505,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); buf are indeterminate. */ -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +ZEXTERN int ZEXPORT gzputc(gzFile file, int c); /* Compress and write c, converted to an unsigned char, into file. gzputc returns the value that was written, or -1 in case of error. */ -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +ZEXTERN int ZEXPORT gzgetc(gzFile file); /* Read and decompress one byte from file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. @@ -1517,7 +1520,7 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); points to has been clobbered or not. */ -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); /* Push c back onto the stream for file to be read as the first character on the next read. At least one character of push-back is always allowed. @@ -1529,7 +1532,7 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); gzseek() or gzrewind(). */ -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); /* Flush all pending output to file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function @@ -1545,8 +1548,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); */ /* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); +ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, + z_off_t offset, int whence); Set the starting position to offset relative to whence for the next gzread or gzwrite on file. The offset represents a number of bytes in the @@ -1564,7 +1567,7 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, would be before the current position. */ -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +ZEXTERN int ZEXPORT gzrewind(gzFile file); /* Rewind file. This function is supported only for reading. @@ -1572,7 +1575,7 @@ ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); */ /* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gztell(gzFile file); Return the starting position for the next gzread or gzwrite on file. This position represents a number of bytes in the uncompressed data stream, @@ -1583,7 +1586,7 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); */ /* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); Return the current compressed (actual) read or write offset of file. This offset includes the count of bytes that precede the gzip stream, for example @@ -1592,7 +1595,7 @@ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); be used for a progress indicator. On error, gzoffset() returns -1. */ -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +ZEXTERN int ZEXPORT gzeof(gzFile file); /* Return true (1) if the end-of-file indicator for file has been set while reading, false (0) otherwise. Note that the end-of-file indicator is set @@ -1607,7 +1610,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); has grown since the previous end of file was detected. */ -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +ZEXTERN int ZEXPORT gzdirect(gzFile file); /* Return true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. @@ -1628,7 +1631,7 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); gzip file reading and decompression, which may not be desired.) */ -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose(gzFile file); /* Flush all pending output for file, if necessary, close file and deallocate the (de)compression state. Note that once file is closed, you @@ -1641,8 +1644,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); last read ended in the middle of a gzip stream, or Z_OK on success. */ -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_r(gzFile file); +ZEXTERN int ZEXPORT gzclose_w(gzFile file); /* Same as gzclose(), but gzclose_r() is only for use when reading, and gzclose_w() is only for use when writing or appending. The advantage to @@ -1653,7 +1656,7 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); zlib library. */ -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); /* Return the error message for the last error which occurred on file. errnum is set to zlib error number. If an error occurred in the file system @@ -1669,7 +1672,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); functions above that do not distinguish those cases in their return values. */ -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +ZEXTERN void ZEXPORT gzclearerr(gzFile file); /* Clear the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip @@ -1686,7 +1689,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); library. */ -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. An Adler-32 value is in the range of a 32-bit @@ -1706,15 +1709,15 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); if (adler != original_adler) error(); */ -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); +ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, + z_size_t len); /* Same as adler32(), but with a size_t length. */ /* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); +ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, + z_off_t len2); Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for @@ -1724,7 +1727,7 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, negative, the result has no meaning or utility. */ -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. @@ -1742,30 +1745,30 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); if (crc != original_crc) error(); */ -ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, - z_size_t len)); +ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, + z_size_t len); /* Same as crc32(), but with a size_t length. */ /* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); +ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. + len2. len2 must be non-negative. */ /* -ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); +ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); Return the operator corresponding to length len2, to be used with - crc32_combine_op(). + crc32_combine_op(). len2 must be non-negative. */ -ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); +ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); /* Give the same result as crc32_combine(), using op in place of len2. op is is generated from len2 by crc32_combine_gen(). This will be faster than @@ -1778,20 +1781,20 @@ ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); +ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, + const char *version, int stream_size); +ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size); +ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size); #ifdef Z_PREFIX_SET # define z_deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) @@ -1836,7 +1839,7 @@ struct gzFile_s { unsigned char *next; z_off64_t pos; }; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ #ifdef Z_PREFIX_SET # undef z_gzgetc # define z_gzgetc(g) \ @@ -1853,13 +1856,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ * without large file support, _LFS64_LARGEFILE must also be true */ #ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); #endif #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) @@ -1881,50 +1884,50 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ # define crc32_combine_gen crc32_combine_gen64 # endif # ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); # endif #else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); + ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif #else /* Z_SOLO */ - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif /* !Z_SOLO */ /* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); -ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); +ZEXTERN const char * ZEXPORT zError(int); +ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); +ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); +ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); +ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); +ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); #if defined(_WIN32) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); +ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, + const char *mode); #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); +ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, + const char *format, + va_list va); # endif #endif diff --git a/zlib/zutil.c b/zlib/zutil.c index 9543ae825..b1c5d2d3c 100644 --- a/zlib/zutil.c +++ b/zlib/zutil.c @@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = { }; -const char * ZEXPORT zlibVersion() -{ +const char * ZEXPORT zlibVersion(void) { return ZLIB_VERSION; } -uLong ZEXPORT zlibCompileFlags() -{ +uLong ZEXPORT zlibCompileFlags(void) { uLong flags; flags = 0; @@ -121,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags() # endif int ZLIB_INTERNAL z_verbose = verbose; -void ZLIB_INTERNAL z_error(m) - char *m; -{ +void ZLIB_INTERNAL z_error(char *m) { fprintf(stderr, "%s\n", m); exit(1); } @@ -132,9 +128,7 @@ void ZLIB_INTERNAL z_error(m) /* exported to allow conversion of error code to string for compress() and * uncompress() */ -const char * ZEXPORT zError(err) - int err; -{ +const char * ZEXPORT zError(int err) { return ERR_MSG(err); } @@ -148,22 +142,14 @@ const char * ZEXPORT zError(err) #ifndef HAVE_MEMCPY -void ZLIB_INTERNAL zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ +void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { if (len == 0) return; do { *dest++ = *source++; /* ??? to be unrolled */ } while (--len != 0); } -int ZLIB_INTERNAL zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ +int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { uInt j; for (j = 0; j < len; j++) { @@ -172,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp(s1, s2, len) return 0; } -void ZLIB_INTERNAL zmemzero(dest, len) - Bytef* dest; - uInt len; -{ +void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { if (len == 0) return; do { *dest++ = 0; /* ??? to be unrolled */ @@ -216,8 +199,7 @@ local ptr_table table[MAX_PTR]; * a protected system like OS/2. Use Microsoft C instead. */ -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { voidpf buf; ulg bsize = (ulg)items*size; @@ -242,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) return buf; } -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { int n; (void)opaque; @@ -279,14 +260,12 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) # define _hfree hfree #endif -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) { (void)opaque; return _halloc((long)items, size); } -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { (void)opaque; _hfree(ptr); } @@ -299,25 +278,18 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); +extern voidp malloc(uInt size); +extern voidp calloc(uInt items, uInt size); +extern void free(voidpf ptr); #endif -voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { (void)opaque; return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } -void ZLIB_INTERNAL zcfree(opaque, ptr) - voidpf opaque; - voidpf ptr; -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { (void)opaque; free(ptr); } diff --git a/zlib/zutil.h b/zlib/zutil.h index 0bc7f4ecd..48dd7feba 100644 --- a/zlib/zutil.h +++ b/zlib/zutil.h @@ -1,5 +1,5 @@ /* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -56,7 +56,7 @@ typedef unsigned long ulg; extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] +#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)] #define ERR_RETURN(strm,err) \ return (strm->msg = ERR_MSG(err), (err)) @@ -137,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif #endif -#if defined(MACOS) || defined(TARGET_OS_MAC) +#if defined(MACOS) # define OS_CODE 7 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif #endif #ifdef __acorn @@ -170,18 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define OS_CODE 19 #endif -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - #if defined(__BORLANDC__) && !defined(MSDOS) #pragma warn -8004 #pragma warn -8008 @@ -191,9 +170,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \ (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); #endif /* common defaults */ @@ -232,16 +211,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define zmemzero(dest, len) memset(dest, 0, len) # endif #else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); + void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); + int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); + void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); #endif /* Diagnostic functions */ #ifdef ZLIB_DEBUG # include extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); + extern void ZLIB_INTERNAL z_error(char *m); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} @@ -258,9 +237,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif #ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); + voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, + unsigned size); + void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); #endif #define ZALLOC(strm, items, size) \ From 10b8fd46ebb8a7c5fa57db8d54129e0e5754d96d Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:42:01 -0700 Subject: [PATCH 068/132] clang tidy 18 fixes readability-redundant-casting (#1262) --- jeeps/gpssend.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeeps/gpssend.cc b/jeeps/gpssend.cc index 55eaa5752..c36894529 100644 --- a/jeeps/gpssend.cc +++ b/jeeps/gpssend.cc @@ -193,7 +193,7 @@ bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec) { UC data[2]; - GPS_Util_Put_Short(data,(US)rec->type); + GPS_Util_Put_Short(data,rec->type); GPS_Make_Packet(tra,LINK_ID[0].Pid_Ack_Byte,data,2); if (!GPS_Write_Packet(fd,*tra)) { GPS_Error("Error acknowledging packet"); From 7617c21cb4ff0ced9881a1819d3657bbed6c8fa9 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 11 Apr 2024 06:24:55 -0600 Subject: [PATCH 069/132] update macos github workflow (#1265) * update github macos runners. macos-11 runner is now deprecated. * update xcode versions for github * update XML_CATALOG_FILES for macos-14 runner * work around macos-14 runner brew locations * find homebrew gsed on apple silicon * generalize brew location detection in macos workflow * update python version for arm availability * push xcode versions to latest minor levels. --- .github/workflows/macos.yml | 20 ++++++++++---------- tools/fixdoc | 7 ++++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index adb6086ba..5244f8741 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -19,25 +19,25 @@ jobs: matrix: include: - QT_VERSION: '5.15.2' - XCODE_VERSION: '12.5.1' + XCODE_VERSION: '13.4.1' GENERATOR: 'Ninja' RELEASE: false - os: macos-11 + os: macos-12 - QT_VERSION: '6.2.4' - XCODE_VERSION: '13.4.1' + XCODE_VERSION: '14.3.1' GENERATOR: 'Xcode' RELEASE: false - os: macos-12 + os: macos-13 - QT_VERSION: '6.2.4' - XCODE_VERSION: '13.4.1' + XCODE_VERSION: '14.3.1' GENERATOR: 'Ninja' RELEASE: true - os: macos-12 + os: macos-13 - QT_VERSION: '6.5.3' - XCODE_VERSION: '14.2' + XCODE_VERSION: '15.3' GENERATOR: 'Ninja' RELEASE: false - os: macos-12 + os: macos-14 steps: - name: Checkout repository @@ -54,7 +54,7 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.12' - name: Qt install if: steps.cache.outputs.cache-hit != 'true' @@ -82,7 +82,7 @@ jobs: - name: Script env: - XML_CATALOG_FILES: /usr/local/etc/xml/catalog + XML_CATALOG_FILES: ${{ runner.arch == 'ARM64' && '/opt/homebrew/etc/xml/catalog' || '/usr/local/etc/xml/catalog' }} run: | source ${HOME}/Cache/qt-${{ matrix.QT_VERSION }}.env sudo xcode-select --switch /Applications/Xcode_${{ matrix.XCODE_VERSION }}.app diff --git a/tools/fixdoc b/tools/fixdoc index 4b10980de..e53749c3c 100755 --- a/tools/fixdoc +++ b/tools/fixdoc @@ -12,9 +12,10 @@ DIR=$1 TITLE=$2 SED="sed" -# MacOS using Homebrew -[ -f /usr/local/bin/gsed ] && SED=/usr/local/bin/gsed -[ -f /opt/local/bin/gsed ] && SED=/opt/local/bin/gsed +# macOS using Homebrew may be /usr/local (macOS intel) or /opt/homebrew (apple silicion) ... +if command -v gsed >/dev/null 2>&1; then + SED=$(command -v gsed) +fi [ ! -d "$DIR/tpl" ] && mkdir -p "$DIR/tpl" From 62db7c8ad10d6c60bc41aef188779a5263a5d90e Mon Sep 17 00:00:00 2001 From: GPSBabel <12013583+GPSBabelDeveloper@users.noreply.github.com> Date: Sun, 14 Apr 2024 03:12:11 -0500 Subject: [PATCH 070/132] Add test coverage for ozi color setting options. (#1266) * Unit test ozi color commandline options. Improves test coverage. Co-authored-by: Robert Lipe --- reference/ozi-color.wpt | 13 +++++++++++++ testo.d/ozi.test | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 reference/ozi-color.wpt diff --git a/reference/ozi-color.wpt b/reference/ozi-color.wpt new file mode 100644 index 000000000..bfab3ad7c --- /dev/null +++ b/reference/ozi-color.wpt @@ -0,0 +1,13 @@ +OziExplorer Waypoint File Version 1.1 +WGS 84 +Reserved 2 +Reserved 3 +1,GCEBB,35.972033,-87.134700,,0,1,3,222,255,Mountain Bike Heaven by susy1313,0,0,0,0,6,0,17 +2,GC1A37,36.090683,-86.679550,,0,1,3,222,255,The Troll by a182pilot & Family,0,0,0,0,6,0,17 +3,GC1C2B,35.996267,-86.620117,,0,1,3,222,255,Dive Bomber by JoGPS & family,0,0,0,0,6,0,17 +4,GC25A9,36.038483,-86.648617,,0,1,3,222,255,FOSTER by JoGPS & Family,0,0,0,0,6,0,17 +5,GC2723,36.112183,-86.741767,,0,1,3,222,255,Logan Lighthouse by JoGps & Family,0,0,0,0,6,0,17 +6,GC2B71,36.064083,-86.790517,,0,1,3,222,255,Ganier Cache by Susy1313,0,0,0,0,6,0,17 +7,GC309F,36.087767,-86.809733,,0,1,3,222,255,Shy's Hill by FireFighterEng33,0,0,0,0,6,0,17 +8,GC317A,36.057500,-86.892000,,0,1,3,222,255,GittyUp by JoGPS / Warner Parks,0,0,0,0,6,0,17 +9,GC317D,36.082800,-86.867283,,0,1,3,222,255,Inlighting by JoGPS / Warner Parks,0,0,0,0,6,0,17 diff --git a/testo.d/ozi.test b/testo.d/ozi.test index 51903441d..1a94e465e 100644 --- a/testo.d/ozi.test +++ b/testo.d/ozi.test @@ -5,6 +5,10 @@ gpsbabel -i ozi -f ${REFERENCE}/ozi.wpt -o ozi -F ${TMPDIR}/oz.wpt gpsbabel -i ozi -f ${TMPDIR}/oz.wpt -o ozi -F ${TMPDIR}/ozi.wpt compare ${TMPDIR}/ozi.wpt ${REFERENCE} +# Same, but with colors set +gpsbabel -i geo -f ${REFERENCE}/geocaching.loc -o ozi,wptfgcolor=#de0000,wptbgcolor=red -F ${TMPDIR}/ozi-color.wpt +compare ${TMPDIR}/ozi-color.wpt ${REFERENCE} + # Test Ozi routes. gpsbabel -i ozi -f ${REFERENCE}/route/ozi.rte -o gpx -F ${TMPDIR}/ozi~gpx.gpx compare ${TMPDIR}/ozi~gpx.gpx ${REFERENCE}/route/ From 9cc7b932b1c1d58861ac97c8cdbce97fdcea0b7e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 16 Apr 2024 07:35:04 -0600 Subject: [PATCH 071/132] work around homebrew python linking issues (#1267) * debug python brew issues * dbg2 * dbg3 * dbg4 * insulate workflow from homebrew location. --- .github/workflows/macos.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 5244f8741..3538c98fa 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -73,6 +73,12 @@ jobs: # https://github.com/actions/runner-images/issues/6507 # https://github.com/actions/runner-images/issues/2322 # brew update # skip update for now to avoid link issues AND many slow dependency upGRADES. + brew list -1 | grep python + ls -l $(brew --prefix)/bin | grep -i python + # workaround for https://github.com/actions/setup-python/issues/577 + brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done + brew list -1 | grep python + ls -l $(brew --prefix)/bin | grep -i python brew install ninja brew install docbook docbook-xsl fop gnu-sed # brew install is taking forever on macos-11, skip jing-trang and all it's dependencies. From 66710b17b028dc9b679425b0e8f03c366821b290 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:09:53 -0600 Subject: [PATCH 072/132] update libusb to 1.0.27 (#1259) --- mac/libusb/README | 2 +- mac/libusb/Xcode/config.h | 6 - mac/libusb/core.c | 550 +++++++++++++++-------- mac/libusb/descriptor.c | 292 +++++++++++- mac/libusb/hotplug.c | 9 +- mac/libusb/io.c | 133 +++--- mac/libusb/libusb.h | 321 +++++++++---- mac/libusb/libusbi.h | 48 +- mac/libusb/os/darwin_usb.c | 821 ++++++++++++++++++++++------------ mac/libusb/os/darwin_usb.h | 159 ++----- mac/libusb/os/events_posix.c | 40 ++ mac/libusb/os/events_posix.h | 3 + mac/libusb/os/threads_posix.c | 6 +- mac/libusb/strerror.c | 10 +- mac/libusb/sync.c | 43 +- mac/libusb/version.h | 2 +- mac/libusb/version_nano.h | 2 +- 17 files changed, 1659 insertions(+), 788 deletions(-) diff --git a/mac/libusb/README b/mac/libusb/README index 47aaf8106..8e7ea725a 100644 --- a/mac/libusb/README +++ b/mac/libusb/README @@ -1,4 +1,4 @@ -This is libusb-1.0.26 from https://libusb.info/. +This is libusb-1.0.27 from https://libusb.info/. Since we have such problems with people getting libusb successfully built - between the Universal Build issues and the fact that we have to work hard to go find where it's installed diff --git a/mac/libusb/Xcode/config.h b/mac/libusb/Xcode/config.h index 59f346335..c589a0fba 100644 --- a/mac/libusb/Xcode/config.h +++ b/mac/libusb/Xcode/config.h @@ -8,12 +8,6 @@ /* Define to 1 to enable message logging. */ #define ENABLE_LOGGING 1 -/* On 10.12 and later, use newly available clock_*() functions */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 -/* Define to 1 if you have the `clock_gettime' function. */ -#define HAVE_CLOCK_GETTIME 1 -#endif - /* On 10.6 and later, use newly available pthread_threadid_np() function */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 /* Define to 1 if you have the 'pthread_threadid_np' function. */ diff --git a/mac/libusb/core.c b/mac/libusb/core.c index ec429b7cf..ffe33b775 100644 --- a/mac/libusb/core.c +++ b/mac/libusb/core.c @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */ /* * Core functions for libusb - * Copyright © 2012-2013 Nathan Hjelm + * Copyright © 2012-2023 Nathan Hjelm * Copyright © 2007-2008 Daniel Drake * Copyright © 2001 Johannes Erdfelt * @@ -34,7 +34,7 @@ static const struct libusb_version libusb_version_internal = { LIBUSB_MAJOR, LIBUSB_MINOR, LIBUSB_MICRO, LIBUSB_NANO, - LIBUSB_RC, "http://libusb.info" }; + LIBUSB_RC, "https://libusb.info" }; static struct timespec timestamp_origin; #if defined(ENABLE_LOGGING) && !defined(USE_SYSTEM_LOGGING_FACILITY) static libusb_log_cb log_handler; @@ -43,6 +43,9 @@ static libusb_log_cb log_handler; struct libusb_context *usbi_default_context; struct libusb_context *usbi_fallback_context; static int default_context_refcnt; +#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) +static usbi_atomic_t default_debug_level = -1; +#endif static usbi_mutex_static_t default_context_lock = USBI_MUTEX_INITIALIZER; static struct usbi_option default_context_options[LIBUSB_OPTION_MAX]; @@ -57,12 +60,12 @@ struct list_head active_contexts_list; * * libusb is an open source library that allows you to communicate with USB * devices from user space. For more info, see the - * libusb homepage. + * libusb homepage. * * This documentation is aimed at application developers wishing to * communicate with USB peripherals from their own software. After reviewing * this documentation, feedback and questions can be sent to the - * libusb-devel mailing list. + * libusb-devel mailing list. * * This documentation assumes knowledge of how to operate USB devices from * a software standpoint (descriptors, configurations, interfaces, endpoints, @@ -111,17 +114,18 @@ struct list_head active_contexts_list; * libusb uses stderr for all logging. By default, logging is set to NONE, * which means that no output will be produced. However, unless the library * has been compiled with logging disabled, then any application calls to - * libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level), or the setting of the - * environmental variable LIBUSB_DEBUG outside of the application, can result - * in logging being produced. Your application should therefore not close - * stderr, but instead direct it to the null device if its output is - * undesirable. - * - * The libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level) function can be - * used to enable logging of certain messages. Under standard configuration, - * libusb doesn't really log much so you are advised to use this function - * to enable all error/warning/ informational messages. It will help debug - * problems with your software. + * libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level), + * libusb_init_context, or the setting of the environmental variable + * LIBUSB_DEBUG outside of the application, can result in logging being + * produced. Your application should therefore not close stderr, but instead + * direct it to the null device if its output is undesirable. + * + * The libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level) or + * libusb_init_context functions can be used to enable logging of certain + * messages. With the default configuration, libusb will not log much so if + * you are advised to use one of these functions to enable all + * error/warning/informational messages. It will help debug problems with your + * software. * * The logged messages are unstructured. There is no one-to-one correspondence * between messages being logged and success or failure return codes from @@ -137,19 +141,19 @@ struct list_head active_contexts_list; * The LIBUSB_DEBUG environment variable can be used to enable message logging * at run-time. This environment variable should be set to a log level number, * which is interpreted the same as the - * libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level) parameter. When this - * environment variable is set, the message logging verbosity level is fixed - * and libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level) effectively does - * nothing. + * libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level), or + * libusb_init_context(&ctx, &(struct libusb_init_option){.option = LIBUSB_OPTION_LOG_LEVEL, .value = {.ival = level}}, 0). + * When the environment variable is set, the message logging verbosity level is + * fixed and setting the LIBUSB_OPTION_LOG_LEVEL option has no effect. * * libusb can be compiled without any logging functions, useful for embedded - * systems. In this case, libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level) - * and the LIBUSB_DEBUG environment variable have no effects. + * systems. In this case, neither the LIBUSB_OPTION_LOG_LEVEL option, nor the + * LIBUSB_DEBUG environment variable will have any effect. * * libusb can also be compiled with verbose debugging messages always. When * the library is compiled in this way, all messages of all verbosities are - * always logged. libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level) and - * the LIBUSB_DEBUG environment variable have no effects. + * always logged. Again, in this case, neither the LIBUSB_OPTION_LOG_LEVEL + * option, nor the LIBUSB_DEBUG environment variable will have any effect. * * \section remarks Other remarks * @@ -327,23 +331,23 @@ if (cfg != desired) * developed modules may both use libusb. * * libusb is written to allow for these multiple user scenarios. The two - * "instances" of libusb will not interfere: libusb_set_option() calls - * from one user will not affect the same settings for other users, other - * users can continue using libusb after one of them calls libusb_exit(), etc. + * "instances" of libusb will not interfere: an option set by one user will have + * no effect the same option for other users, other users can continue using + * libusb after one of them calls libusb_exit(), etc. * * This is made possible through libusb's context concept. When you - * call libusb_init(), you are (optionally) given a context. You can then pass + * call libusb_init_context(), you are (optionally) given a context. You can then pass * this context pointer back into future libusb functions. * * In order to keep things simple for more simplistic applications, it is * legal to pass NULL to all functions requiring a context pointer (as long as * you're sure no other code will attempt to use libusb from the same process). * When you pass NULL, the default context will be used. The default context - * is created the first time a process calls libusb_init() when no other + * is created the first time a process calls libusb_init_context() when no other * context is alive. Contexts are destroyed during libusb_exit(). * * The default context is reference-counted and can be shared. That means that - * if libusb_init(NULL) is called twice within the same process, the two + * if libusb_init_context(NULL, x, y) is called twice within the same process, the two * users end up sharing the same context. The deinitialization and freeing of * the default context will only happen when the last user calls libusb_exit(). * In other words, the default context is created and initialized when its @@ -413,6 +417,7 @@ if (cfg != desired) * - libusb_get_device_speed() * - libusb_get_iso_packet_buffer() * - libusb_get_iso_packet_buffer_simple() + * - libusb_get_max_alt_packet_size() * - libusb_get_max_iso_packet_size() * - libusb_get_max_packet_size() * - libusb_get_next_timeout() @@ -436,6 +441,7 @@ if (cfg != desired) * - libusb_hotplug_deregister_callback() * - libusb_hotplug_register_callback() * - libusb_init() + * - libusb_init_context() * - libusb_interrupt_event_handler() * - libusb_interrupt_transfer() * - libusb_kernel_driver_active() @@ -931,13 +937,13 @@ uint8_t API_EXPORTED libusb_get_port_number(libusb_device *dev) /** \ingroup libusb_dev * Get the list of all port numbers from root for the specified device * - * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 + * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 * \param dev a device * \param port_numbers the array that should contain the port numbers * \param port_numbers_len the maximum length of the array. As per the USB 3.0 * specs, the current maximum limit for the depth is 7. * \returns the number of elements filled - * \returns LIBUSB_ERROR_OVERFLOW if the array is too small + * \returns \ref LIBUSB_ERROR_OVERFLOW if the array is too small */ int API_EXPORTED libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len) @@ -1049,8 +1055,8 @@ static const struct libusb_endpoint_descriptor *find_endpoint( * \param dev a device * \param endpoint address of the endpoint in question * \returns the wMaxPacketSize value - * \returns LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist - * \returns LIBUSB_ERROR_OTHER on other failure + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist + * \returns \ref LIBUSB_ERROR_OTHER on other failure */ int API_EXPORTED libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint) @@ -1079,6 +1085,65 @@ int API_EXPORTED libusb_get_max_packet_size(libusb_device *dev, return r; } +static const struct libusb_endpoint_descriptor *find_alt_endpoint( + struct libusb_config_descriptor *config, + int iface_idx, int altsetting_idx, unsigned char endpoint) +{ + if (iface_idx >= config->bNumInterfaces) { + return NULL; + } + + const struct libusb_interface *iface = &config->interface[iface_idx]; + + if (altsetting_idx >= iface->num_altsetting) { + return NULL; + } + + const struct libusb_interface_descriptor *altsetting + = &iface->altsetting[altsetting_idx]; + int ep_idx; + + for (ep_idx = 0; ep_idx < altsetting->bNumEndpoints; ep_idx++) { + const struct libusb_endpoint_descriptor *ep = + &altsetting->endpoint[ep_idx]; + if (ep->bEndpointAddress == endpoint) + return ep; + } + return NULL; +} + +static int get_endpoint_max_packet_size(libusb_device *dev, + const struct libusb_endpoint_descriptor *ep) +{ + struct libusb_ss_endpoint_companion_descriptor *ss_ep_cmp; + enum libusb_endpoint_transfer_type ep_type; + uint16_t val; + int r = 0; + int speed; + + speed = libusb_get_device_speed(dev); + if (speed >= LIBUSB_SPEED_SUPER) { + r = libusb_get_ss_endpoint_companion_descriptor(dev->ctx, ep, &ss_ep_cmp); + if (r == LIBUSB_SUCCESS) { + r = ss_ep_cmp->wBytesPerInterval; + libusb_free_ss_endpoint_companion_descriptor(ss_ep_cmp); + } + } + + /* If the device isn't a SuperSpeed device or retrieving the SS endpoint didn't worked. */ + if (speed < LIBUSB_SPEED_SUPER || r < 0) { + val = ep->wMaxPacketSize; + ep_type = (enum libusb_endpoint_transfer_type) (ep->bmAttributes & 0x3); + + r = val & 0x07ff; + if (ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS + || ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT) + r *= (1 + ((val >> 11) & 3)); + } + + return r; +} + /** \ingroup libusb_dev * Calculate the maximum packet size which a specific endpoint is capable is * sending or receiving in the duration of 1 microframe @@ -1099,24 +1164,25 @@ int API_EXPORTED libusb_get_max_packet_size(libusb_device *dev, * libusb_set_iso_packet_lengths() in order to set the length field of every * isochronous packet in a transfer. * + * This function only considers the first alternate setting of the interface. + * If the endpoint has different maximum packet sizes for different alternate + * settings, you probably want libusb_get_max_alt_packet_size() instead. + * * Since v1.0.3. * * \param dev a device * \param endpoint address of the endpoint in question * \returns the maximum packet size which can be sent/received on this endpoint - * \returns LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist - * \returns LIBUSB_ERROR_OTHER on other failure + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist + * \returns \ref LIBUSB_ERROR_OTHER on other failure + * \see libusb_get_max_alt_packet_size */ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoint) { struct libusb_config_descriptor *config; const struct libusb_endpoint_descriptor *ep; - struct libusb_ss_endpoint_companion_descriptor *ss_ep_cmp; - enum libusb_endpoint_transfer_type ep_type; - uint16_t val; int r; - int speed; r = libusb_get_active_config_descriptor(dev, &config); if (r < 0) { @@ -1131,26 +1197,68 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev, goto out; } - speed = libusb_get_device_speed(dev); - if (speed >= LIBUSB_SPEED_SUPER) { - r = libusb_get_ss_endpoint_companion_descriptor(dev->ctx, ep, &ss_ep_cmp); - if (r == LIBUSB_SUCCESS) { - r = ss_ep_cmp->wBytesPerInterval; - libusb_free_ss_endpoint_companion_descriptor(ss_ep_cmp); - } - } + r = get_endpoint_max_packet_size(dev, ep); - /* If the device isn't a SuperSpeed device or retrieving the SS endpoint didn't worked. */ - if (speed < LIBUSB_SPEED_SUPER || r < 0) { - val = ep->wMaxPacketSize; - ep_type = (enum libusb_endpoint_transfer_type) (ep->bmAttributes & 0x3); +out: + libusb_free_config_descriptor(config); + return r; +} - r = val & 0x07ff; - if (ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS - || ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT) - r *= (1 + ((val >> 11) & 3)); +/** \ingroup libusb_dev + * Calculate the maximum packet size which a specific endpoint is capable of + * sending or receiving in the duration of 1 microframe + * + * Only the active configuration is examined. The calculation is based on the + * wMaxPacketSize field in the endpoint descriptor as described in section + * 9.6.6 in the USB 2.0 specifications. + * + * If acting on an isochronous or interrupt endpoint, this function will + * multiply the value found in bits 0:10 by the number of transactions per + * microframe (determined by bits 11:12). Otherwise, this function just + * returns the numeric value found in bits 0:10. For USB 3.0 device, it + * will attempts to retrieve the Endpoint Companion Descriptor to return + * wBytesPerInterval. + * + * This function is useful for setting up isochronous transfers, for example + * you might pass the return value from this function to + * libusb_set_iso_packet_lengths() in order to set the length field of every + * isochronous packet in a transfer. + * + * Since version 1.0.27, \ref LIBUSB_API_VERSION >= 0x0100010A + * + * \param dev a device + * \param interface_number the bInterfaceNumber of the interface + * the endpoint belongs to + * \param alternate_setting the bAlternateSetting of the interface + * \param endpoint address of the endpoint in question + * \returns the maximum packet size which can be sent/received on this endpoint + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist + * \returns \ref LIBUSB_ERROR_OTHER on other failure + * \see libusb_get_max_iso_packet_size + */ +int API_EXPORTED libusb_get_max_alt_packet_size(libusb_device *dev, + int interface_number, int alternate_setting, unsigned char endpoint) +{ + struct libusb_config_descriptor *config; + const struct libusb_endpoint_descriptor *ep; + int r; + + r = libusb_get_active_config_descriptor(dev, &config); + if (r < 0) { + usbi_err(DEVICE_CTX(dev), + "could not retrieve active config descriptor"); + return LIBUSB_ERROR_OTHER; + } + + ep = find_alt_endpoint(config, interface_number, + alternate_setting, endpoint); + if (!ep) { + r = LIBUSB_ERROR_NOT_FOUND; + goto out; } + r = get_endpoint_max_packet_size(dev, ep); + out: libusb_free_config_descriptor(config); return r; @@ -1209,10 +1317,10 @@ void API_EXPORTED libusb_unref_device(libusb_device *dev) * handle for the underlying device. The handle allows you to use libusb to * perform I/O on the device in question. * - * Call libusb_set_option(NULL, LIBUSB_OPTION_NO_DEVICE_DISCOVERY) before - * libusb_init() if you want to skip enumeration of USB devices. In particular, - * this might be needed on Android if you don't have authority to access USB - * devices in general. + * Call libusb_init_context with the LIBUSB_OPTION_NO_DEVICE_DISCOVERY + * option if you want to skip enumeration of USB devices. In particular, this + * might be needed on Android if you don't have authority to access USB + * devices in general. Setting this option with libusb_set_option is deprecated. * * On Linux, the system device handle must be a valid file descriptor opened * on the device node. @@ -1233,9 +1341,9 @@ void API_EXPORTED libusb_unref_device(libusb_device *dev) * \param dev_handle output location for the returned device handle pointer. Only * populated when the return code is 0. * \returns 0 on success - * \returns LIBUSB_ERROR_NO_MEM on memory allocation failure - * \returns LIBUSB_ERROR_ACCESS if the user has insufficient permissions - * \returns LIBUSB_ERROR_NOT_SUPPORTED if the operation is not supported on this + * \returns \ref LIBUSB_ERROR_NO_MEM on memory allocation failure + * \returns \ref LIBUSB_ERROR_ACCESS if the user has insufficient permissions + * \returns \ref LIBUSB_ERROR_NOT_SUPPORTED if the operation is not supported on this * platform * \returns another LIBUSB_ERROR code on other failure */ @@ -1289,9 +1397,9 @@ int API_EXPORTED libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, * \param dev_handle output location for the returned device handle pointer. Only * populated when the return code is 0. * \returns 0 on success - * \returns LIBUSB_ERROR_NO_MEM on memory allocation failure - * \returns LIBUSB_ERROR_ACCESS if the user has insufficient permissions - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NO_MEM on memory allocation failure + * \returns \ref LIBUSB_ERROR_ACCESS if the user has insufficient permissions + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ int API_EXPORTED libusb_open(libusb_device *dev, @@ -1397,20 +1505,22 @@ static void do_close(struct libusb_context *ctx, for_each_transfer_safe(ctx, itransfer, tmp) { struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); + uint32_t state_flags; if (transfer->dev_handle != dev_handle) continue; usbi_mutex_lock(&itransfer->lock); - if (!(itransfer->state_flags & USBI_TRANSFER_DEVICE_DISAPPEARED)) { + state_flags = itransfer->state_flags; + usbi_mutex_unlock(&itransfer->lock); + if (!(state_flags & USBI_TRANSFER_DEVICE_DISAPPEARED)) { usbi_err(ctx, "Device handle closed while transfer was still being processed, but the device is still connected as far as we know"); - if (itransfer->state_flags & USBI_TRANSFER_CANCELLING) + if (state_flags & USBI_TRANSFER_CANCELLING) usbi_warn(ctx, "A cancellation for an in-flight transfer hasn't completed but closing the device handle"); else usbi_err(ctx, "A cancellation hasn't even been scheduled on the transfer for which the device is closing"); } - usbi_mutex_unlock(&itransfer->lock); /* remove from the list of in-flight transfers and make sure * we don't accidentally use the device handle in the future @@ -1424,7 +1534,7 @@ static void do_close(struct libusb_context *ctx, * the device handle is invalid */ usbi_dbg(ctx, "Removed transfer %p from the in-flight list because device handle %p closed", - transfer, dev_handle); + (void *) transfer, (void *) dev_handle); } usbi_mutex_unlock(&ctx->flying_transfers_lock); @@ -1533,7 +1643,7 @@ libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle) * \param config output location for the bConfigurationValue of the active * configuration (only valid for return code 0) * \returns 0 on success - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ int API_EXPORTED libusb_get_configuration(libusb_device_handle *dev_handle, @@ -1584,7 +1694,7 @@ int API_EXPORTED libusb_get_configuration(libusb_device_handle *dev_handle, * endpoint halts cleared, toggles reset). * * Not all backends support setting the configuration from user space, which - * will be indicated by the return code LIBUSB_ERROR_NOT_SUPPORTED. As this + * will be indicated by the return code \ref LIBUSB_ERROR_NOT_SUPPORTED. As this * suggests that the platform is handling the device configuration itself, * this error should generally be safe to ignore. * @@ -1615,11 +1725,11 @@ int API_EXPORTED libusb_get_configuration(libusb_device_handle *dev_handle, * wish to activate, or -1 if you wish to put the device in an unconfigured * state * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the requested configuration does not exist - * \returns LIBUSB_ERROR_BUSY if interfaces are currently claimed - * \returns LIBUSB_ERROR_NOT_SUPPORTED if setting or changing the configuration + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the requested configuration does not exist + * \returns \ref LIBUSB_ERROR_BUSY if interfaces are currently claimed + * \returns \ref LIBUSB_ERROR_NOT_SUPPORTED if setting or changing the configuration * is not supported by the backend - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure * \see libusb_set_auto_detach_kernel_driver() */ @@ -1653,10 +1763,10 @@ int API_EXPORTED libusb_set_configuration(libusb_device_handle *dev_handle, * \param interface_number the bInterfaceNumber of the interface you * wish to claim * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the requested interface does not exist - * \returns LIBUSB_ERROR_BUSY if another program or driver has claimed the + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the requested interface does not exist + * \returns \ref LIBUSB_ERROR_BUSY if another program or driver has claimed the * interface - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns a LIBUSB_ERROR code on other failure * \see libusb_set_auto_detach_kernel_driver() */ @@ -1699,8 +1809,8 @@ int API_EXPORTED libusb_claim_interface(libusb_device_handle *dev_handle, * \param interface_number the bInterfaceNumber of the * previously-claimed interface * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the interface was not claimed - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the interface was not claimed + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure * \see libusb_set_auto_detach_kernel_driver() */ @@ -1744,9 +1854,9 @@ int API_EXPORTED libusb_release_interface(libusb_device_handle *dev_handle, * \param alternate_setting the bAlternateSetting of the alternate * setting to activate * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the interface was not claimed, or the + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the interface was not claimed, or the * requested alternate setting does not exist - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ int API_EXPORTED libusb_set_interface_alt_setting(libusb_device_handle *dev_handle, @@ -1760,7 +1870,6 @@ int API_EXPORTED libusb_set_interface_alt_setting(libusb_device_handle *dev_hand return LIBUSB_ERROR_INVALID_PARAM; if (!usbi_atomic_load(&dev_handle->dev->attached)) { - usbi_mutex_unlock(&dev_handle->lock); return LIBUSB_ERROR_NO_DEVICE; } @@ -1787,8 +1896,8 @@ int API_EXPORTED libusb_set_interface_alt_setting(libusb_device_handle *dev_hand * \param dev_handle a device handle * \param endpoint the endpoint to clear halt status * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ int API_EXPORTED libusb_clear_halt(libusb_device_handle *dev_handle, @@ -1809,14 +1918,14 @@ int API_EXPORTED libusb_clear_halt(libusb_device_handle *dev_handle, * If the reset fails, the descriptors change, or the previous state cannot be * restored, the device will appear to be disconnected and reconnected. This * means that the device handle is no longer valid (you should close it) and - * rediscover the device. A return code of LIBUSB_ERROR_NOT_FOUND indicates + * rediscover the device. A return code of \ref LIBUSB_ERROR_NOT_FOUND indicates * when this is the case. * * This is a blocking function which usually incurs a noticeable delay. * * \param dev_handle a handle of the device to reset * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if re-enumeration is required, or if the + * \returns \ref LIBUSB_ERROR_NOT_FOUND if re-enumeration is required, or if the * device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ @@ -1881,7 +1990,7 @@ int API_EXPORTED libusb_alloc_streams(libusb_device_handle *dev_handle, * \param dev_handle a device handle * \param endpoints array of endpoints to free streams on * \param num_endpoints length of the endpoints array - * \returns LIBUSB_SUCCESS, or a LIBUSB_ERROR code on failure + * \returns \ref LIBUSB_SUCCESS, or a LIBUSB_ERROR code on failure */ int API_EXPORTED libusb_free_streams(libusb_device_handle *dev_handle, unsigned char *endpoints, int num_endpoints) @@ -1944,7 +2053,7 @@ unsigned char * LIBUSB_CALL libusb_dev_mem_alloc(libusb_device_handle *dev_handl * \param dev_handle a device handle * \param buffer pointer to the previously allocated memory * \param length size of previously allocated memory - * \returns LIBUSB_SUCCESS, or a LIBUSB_ERROR code on failure + * \returns \ref LIBUSB_SUCCESS, or a LIBUSB_ERROR code on failure */ int API_EXPORTED libusb_dev_mem_free(libusb_device_handle *dev_handle, unsigned char *buffer, size_t length) @@ -1966,8 +2075,8 @@ int API_EXPORTED libusb_dev_mem_free(libusb_device_handle *dev_handle, * \param interface_number the interface to check * \returns 0 if no kernel driver is active * \returns 1 if a kernel driver is active - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected - * \returns LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality * is not available * \returns another LIBUSB_ERROR code on other failure * \see libusb_detach_kernel_driver() @@ -1997,15 +2106,15 @@ int API_EXPORTED libusb_kernel_driver_active(libusb_device_handle *dev_handle, * * Note that libusb itself also talks to the device through a special kernel * driver, if this driver is already attached to the device, this call will - * not detach it and return LIBUSB_ERROR_NOT_FOUND. + * not detach it and return \ref LIBUSB_ERROR_NOT_FOUND. * * \param dev_handle a device handle * \param interface_number the interface to detach the driver from * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if no kernel driver was active - * \returns LIBUSB_ERROR_INVALID_PARAM if the interface does not exist - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected - * \returns LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality + * \returns \ref LIBUSB_ERROR_NOT_FOUND if no kernel driver was active + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the interface does not exist + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality * is not available * \returns another LIBUSB_ERROR code on other failure * \see libusb_kernel_driver_active() @@ -2036,12 +2145,12 @@ int API_EXPORTED libusb_detach_kernel_driver(libusb_device_handle *dev_handle, * \param dev_handle a device handle * \param interface_number the interface to attach the driver from * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if no kernel driver was active - * \returns LIBUSB_ERROR_INVALID_PARAM if the interface does not exist - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected - * \returns LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality + * \returns \ref LIBUSB_ERROR_NOT_FOUND if no kernel driver was active + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the interface does not exist + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality * is not available - * \returns LIBUSB_ERROR_BUSY if the driver cannot be attached because the + * \returns \ref LIBUSB_ERROR_BUSY if the driver cannot be attached because the * interface is claimed by a program or driver * \returns another LIBUSB_ERROR code on other failure * \see libusb_kernel_driver_active() @@ -2072,14 +2181,14 @@ int API_EXPORTED libusb_attach_kernel_driver(libusb_device_handle *dev_handle, * handles by default. * * On platforms which do not have LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER - * this function will return LIBUSB_ERROR_NOT_SUPPORTED, and libusb will + * this function will return \ref LIBUSB_ERROR_NOT_SUPPORTED, and libusb will * continue as if this function was never called. * * \param dev_handle a device handle * \param enable whether to enable or disable auto kernel driver detachment * - * \returns LIBUSB_SUCCESS on success - * \returns LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality + * \returns \ref LIBUSB_SUCCESS on success + * \returns \ref LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality * is not available * \see libusb_claim_interface() * \see libusb_release_interface() @@ -2096,20 +2205,34 @@ int API_EXPORTED libusb_set_auto_detach_kernel_driver( } /** \ingroup libusb_lib - * \deprecated Use libusb_set_option() instead using the - * \ref LIBUSB_OPTION_LOG_LEVEL option. + * Deprecated. Use libusb_set_option() or libusb_init_context() instead, + * with the \ref LIBUSB_OPTION_LOG_LEVEL option. */ void API_EXPORTED libusb_set_debug(libusb_context *ctx, int level) { -#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) - ctx = usbi_get_context(ctx); - if (!ctx->debug_fixed) { - level = CLAMP(level, LIBUSB_LOG_LEVEL_NONE, LIBUSB_LOG_LEVEL_DEBUG); - ctx->debug = (enum libusb_log_level)level; + libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, level); +} + +static void libusb_set_log_cb_internal(libusb_context *ctx, libusb_log_cb cb, + int mode) +{ +#if defined(ENABLE_LOGGING) && (!defined(ENABLE_DEBUG_LOGGING) || !defined(USE_SYSTEM_LOGGING_FACILITY)) +#if !defined(USE_SYSTEM_LOGGING_FACILITY) + if (mode & LIBUSB_LOG_CB_GLOBAL) + log_handler = cb; +#endif +#if !defined(ENABLE_DEBUG_LOGGING) + if (mode & LIBUSB_LOG_CB_CONTEXT) { + ctx = usbi_get_context(ctx); + ctx->log_handler = cb; } #else UNUSED(ctx); - UNUSED(level); +#endif +#else + UNUSED(ctx); + UNUSED(cb); + UNUSED(mode); #endif } @@ -2139,24 +2262,7 @@ void API_EXPORTED libusb_set_debug(libusb_context *ctx, int level) void API_EXPORTED libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode) { -#if defined(ENABLE_LOGGING) && (!defined(ENABLE_DEBUG_LOGGING) || !defined(USE_SYSTEM_LOGGING_FACILITY)) -#if !defined(USE_SYSTEM_LOGGING_FACILITY) - if (mode & LIBUSB_LOG_CB_GLOBAL) - log_handler = cb; -#endif -#if !defined(ENABLE_DEBUG_LOGGING) - if (mode & LIBUSB_LOG_CB_CONTEXT) { - ctx = usbi_get_context(ctx); - ctx->log_handler = cb; - } -#else - UNUSED(ctx); -#endif -#else - UNUSED(ctx); - UNUSED(cb); - UNUSED(mode); -#endif + libusb_set_log_cb_internal(ctx, cb, mode); } /** \ingroup libusb_lib @@ -2176,72 +2282,95 @@ void API_EXPORTED libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, * \param option which option to set * \param ... any required arguments for the specified option * - * \returns LIBUSB_SUCCESS on success - * \returns LIBUSB_ERROR_INVALID_PARAM if the option or arguments are invalid - * \returns LIBUSB_ERROR_NOT_SUPPORTED if the option is valid but not supported + * \returns \ref LIBUSB_SUCCESS on success + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the option or arguments are invalid + * \returns \ref LIBUSB_ERROR_NOT_SUPPORTED if the option is valid but not supported * on this platform - * \returns LIBUSB_ERROR_NOT_FOUND if LIBUSB_OPTION_USE_USBDK is valid on this platform but UsbDk is not available + * \returns \ref LIBUSB_ERROR_NOT_FOUND if LIBUSB_OPTION_USE_USBDK is valid on this platform but UsbDk is not available */ -int API_EXPORTED libusb_set_option(libusb_context *ctx, +int API_EXPORTEDV libusb_set_option(libusb_context *ctx, enum libusb_option option, ...) { int arg = 0, r = LIBUSB_SUCCESS; + libusb_log_cb log_cb = NULL; va_list ap; +#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) + int is_default_context = (NULL == ctx); +#endif va_start(ap, option); + if (LIBUSB_OPTION_LOG_LEVEL == option) { arg = va_arg(ap, int); if (arg < LIBUSB_LOG_LEVEL_NONE || arg > LIBUSB_LOG_LEVEL_DEBUG) { r = LIBUSB_ERROR_INVALID_PARAM; } } - va_end(ap); - - if (LIBUSB_SUCCESS != r) { - return r; + if (LIBUSB_OPTION_LOG_CB == option) { + log_cb = (libusb_log_cb) va_arg(ap, libusb_log_cb); } - if (option >= LIBUSB_OPTION_MAX) { - return LIBUSB_ERROR_INVALID_PARAM; - } + do { + if (LIBUSB_SUCCESS != r) { + break; + } - if (NULL == ctx) { - usbi_mutex_static_lock(&default_context_lock); - default_context_options[option].is_set = 1; - if (LIBUSB_OPTION_LOG_LEVEL == option) { - default_context_options[option].arg.ival = arg; + if (option >= LIBUSB_OPTION_MAX) { + r = LIBUSB_ERROR_INVALID_PARAM; + break; } - usbi_mutex_static_unlock(&default_context_lock); - } - ctx = usbi_get_context(ctx); - if (NULL == ctx) { - return LIBUSB_SUCCESS; - } + if (NULL == ctx) { + usbi_mutex_static_lock(&default_context_lock); + default_context_options[option].is_set = 1; + if (LIBUSB_OPTION_LOG_LEVEL == option) { + default_context_options[option].arg.ival = arg; + } else if (LIBUSB_OPTION_LOG_CB == option) { + default_context_options[option].arg.log_cbval = log_cb; + libusb_set_log_cb_internal(NULL, log_cb, LIBUSB_LOG_CB_GLOBAL); + } + usbi_mutex_static_unlock(&default_context_lock); + } - switch (option) { - case LIBUSB_OPTION_LOG_LEVEL: + ctx = usbi_get_context(ctx); + if (NULL == ctx) + break; + + switch (option) { + case LIBUSB_OPTION_LOG_LEVEL: #if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) - if (!ctx->debug_fixed) - ctx->debug = (enum libusb_log_level)arg; + if (!ctx->debug_fixed) { + ctx->debug = (enum libusb_log_level)arg; + if (is_default_context) + usbi_atomic_store(&default_debug_level, CLAMP(arg, LIBUSB_LOG_LEVEL_NONE, LIBUSB_LOG_LEVEL_DEBUG)); + } #endif - break; + break; - /* Handle all backend-specific options here */ - case LIBUSB_OPTION_USE_USBDK: - case LIBUSB_OPTION_NO_DEVICE_DISCOVERY: - if (usbi_backend.set_option) - return usbi_backend.set_option(ctx, option, ap); + /* Handle all backend-specific options here */ + case LIBUSB_OPTION_USE_USBDK: + case LIBUSB_OPTION_NO_DEVICE_DISCOVERY: + if (usbi_backend.set_option) { + r = usbi_backend.set_option(ctx, option, ap); + break; + } - return LIBUSB_ERROR_NOT_SUPPORTED; - break; + r = LIBUSB_ERROR_NOT_SUPPORTED; + break; - case LIBUSB_OPTION_MAX: - default: - return LIBUSB_ERROR_INVALID_PARAM; - } + case LIBUSB_OPTION_LOG_CB: + libusb_set_log_cb_internal(ctx, log_cb, LIBUSB_LOG_CB_CONTEXT); + break; - return LIBUSB_SUCCESS;; + case LIBUSB_OPTION_MAX: /* unreachable */ + default: + r = LIBUSB_ERROR_INVALID_PARAM; + } + } while (0); + + va_end(ap); + + return r; } #if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) @@ -2264,20 +2393,35 @@ static enum libusb_log_level get_env_debug_level(void) } #endif +/** \ingroup libusb_lib + * Deprecated initialization function. Equivalent to calling libusb_init_context with no options. + * + * \see libusb_init_context + */ +int API_EXPORTED libusb_init(libusb_context **ctx) +{ + return libusb_init_context(ctx, NULL, 0); +} + /** \ingroup libusb_lib * Initialize libusb. This function must be called before calling any other * libusb function. * * If you do not provide an output location for a context pointer, a default * context will be created. If there was already a default context, it will - * be reused (and nothing will be initialized/reinitialized). + * be reused (and nothing will be initialized/reinitialized and options will + * be ignored). If num_options is 0 then options is ignored and may be NULL. + * + * Since version 1.0.27, \ref LIBUSB_API_VERSION >= 0x0100010A * * \param ctx Optional output location for context pointer. * Only valid on return code 0. + * \param options Optional array of options to set on the new context. + * \param num_options Number of elements in the options array. * \returns 0 on success, or a LIBUSB_ERROR code on failure * \see libusb_contexts */ -int API_EXPORTED libusb_init(libusb_context **ctx) +int API_EXPORTED libusb_init_context(libusb_context **ctx, const struct libusb_init_option options[], int num_options) { size_t priv_size = usbi_backend.context_priv_size; struct libusb_context *_ctx; @@ -2293,10 +2437,12 @@ int API_EXPORTED libusb_init(libusb_context **ctx) } /* check for first init */ + usbi_mutex_static_lock(&active_contexts_lock); if (!active_contexts_list.next) { list_init(&active_contexts_list); usbi_get_monotonic_time(×tamp_origin); } + usbi_mutex_static_unlock(&active_contexts_lock); _ctx = calloc(1, PTR_ALIGN(sizeof(*_ctx)) + priv_size); if (!_ctx) { @@ -2305,13 +2451,13 @@ int API_EXPORTED libusb_init(libusb_context **ctx) } #if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) - if (NULL == ctx && default_context_options[LIBUSB_OPTION_LOG_LEVEL].is_set) { - _ctx->debug = default_context_options[LIBUSB_OPTION_LOG_LEVEL].arg.ival; - } else { + _ctx->debug = LIBUSB_LOG_LEVEL_NONE; + if (getenv("LIBUSB_DEBUG")) { _ctx->debug = get_env_debug_level(); - } - if (_ctx->debug != LIBUSB_LOG_LEVEL_NONE) _ctx->debug_fixed = 1; + } else if (default_context_options[LIBUSB_OPTION_LOG_LEVEL].is_set) { + _ctx->debug = default_context_options[LIBUSB_OPTION_LOG_LEVEL].arg.ival; + } #endif usbi_mutex_init(&_ctx->usb_devs_lock); @@ -2324,7 +2470,29 @@ int API_EXPORTED libusb_init(libusb_context **ctx) if (LIBUSB_OPTION_LOG_LEVEL == option || !default_context_options[option].is_set) { continue; } - r = libusb_set_option(_ctx, option); + if (LIBUSB_OPTION_LOG_CB != option) { + r = libusb_set_option(_ctx, option); + } else { + r = libusb_set_option(_ctx, option, default_context_options[option].arg.log_cbval); + } + if (LIBUSB_SUCCESS != r) + goto err_free_ctx; + } + + /* apply any options provided by the user */ + for (int i = 0 ; i < num_options ; ++i) { + switch(options[i].option) { + case LIBUSB_OPTION_LOG_CB: + r = libusb_set_option(_ctx, options[i].option, options[i].value.log_cbval); + break; + + case LIBUSB_OPTION_LOG_LEVEL: + case LIBUSB_OPTION_USE_USBDK: + case LIBUSB_OPTION_NO_DEVICE_DISCOVERY: + case LIBUSB_OPTION_MAX: + default: + r = libusb_set_option(_ctx, options[i].option, options[i].value.ival); + } if (LIBUSB_SUCCESS != r) goto err_free_ctx; } @@ -2333,6 +2501,9 @@ int API_EXPORTED libusb_init(libusb_context **ctx) if (!ctx) { usbi_default_context = _ctx; default_context_refcnt = 1; +#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) + usbi_atomic_store(&default_debug_level, _ctx->debug); +#endif usbi_dbg(usbi_default_context, "created default context"); } @@ -2360,8 +2531,12 @@ int API_EXPORTED libusb_init(libusb_context **ctx) *ctx = _ctx; if (!usbi_fallback_context) { +#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING) + if (usbi_atomic_load(&default_debug_level) == -1) + usbi_atomic_store(&default_debug_level, _ctx->debug); +#endif usbi_fallback_context = _ctx; - usbi_warn(usbi_fallback_context, "installing new context as implicit default"); + usbi_dbg(usbi_fallback_context, "installing new context as implicit default"); } } @@ -2432,6 +2607,9 @@ void API_EXPORTED libusb_exit(libusb_context *ctx) list_del(&_ctx->list); usbi_mutex_static_unlock(&active_contexts_lock); + /* Exit hotplug before backend dependency */ + usbi_hotplug_exit(_ctx); + if (usbi_backend.exit) usbi_backend.exit(_ctx); @@ -2445,7 +2623,6 @@ void API_EXPORTED libusb_exit(libusb_context *ctx) /* Don't bother with locking after this point because unless there is * an application bug, nobody will be accessing the context. */ - usbi_hotplug_exit(_ctx); usbi_io_exit(_ctx); for_each_device(_ctx, dev) { @@ -2465,7 +2642,7 @@ void API_EXPORTED libusb_exit(libusb_context *ctx) /** \ingroup libusb_misc * Check at runtime if the loaded library has a given capability. - * This call should be performed after \ref libusb_init(), to ensure the + * This call should be performed after \ref libusb_init_context(), to ensure the * backend has updated its capability set. * * \param capability the \ref libusb_capability to check for @@ -2584,13 +2761,14 @@ static void log_v(struct libusb_context *ctx, enum libusb_log_level level, UNUSED(ctx); #else enum libusb_log_level ctx_level; + long default_level_value; - ctx = ctx ? ctx : usbi_default_context; - ctx = ctx ? ctx : usbi_fallback_context; - if (ctx) + if (ctx) { ctx_level = ctx->debug; - else - ctx_level = get_env_debug_level(); + } else { + default_level_value = usbi_atomic_load(&default_debug_level); + ctx_level = default_level_value < 0 ? get_env_debug_level() : (enum libusb_log_level)default_level_value; + } if (ctx_level < level) return; diff --git a/mac/libusb/descriptor.c b/mac/libusb/descriptor.c index 253ef1c31..4623ad1e3 100644 --- a/mac/libusb/descriptor.c +++ b/mac/libusb/descriptor.c @@ -521,7 +521,7 @@ static int get_config_descriptor(struct libusb_device *dev, uint8_t config_idx, * * This is a non-blocking function; the device descriptor is cached in memory. * - * Note since libusb-1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102, this + * Note since libusb-1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102, this * function always succeeds. * * \param dev the device @@ -548,7 +548,7 @@ int API_EXPORTED libusb_get_device_descriptor(libusb_device *dev, * valid if 0 was returned. Must be freed with libusb_free_config_descriptor() * after use. * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the device is in unconfigured state + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the device is in unconfigured state * \returns another LIBUSB_ERROR code on error * \see libusb_get_config_descriptor */ @@ -588,7 +588,7 @@ int API_EXPORTED libusb_get_active_config_descriptor(libusb_device *dev, * valid if 0 was returned. Must be freed with libusb_free_config_descriptor() * after use. * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the configuration does not exist + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the configuration does not exist * \returns another LIBUSB_ERROR code on error * \see libusb_get_active_config_descriptor() * \see libusb_get_config_descriptor_by_value() @@ -634,7 +634,7 @@ int API_EXPORTED libusb_get_config_descriptor(libusb_device *dev, * valid if 0 was returned. Must be freed with libusb_free_config_descriptor() * after use. * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the configuration does not exist + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the configuration does not exist * \returns another LIBUSB_ERROR code on error * \see libusb_get_active_config_descriptor() * \see libusb_get_config_descriptor() @@ -699,7 +699,7 @@ void API_EXPORTED libusb_free_config_descriptor( * descriptor. Only valid if 0 was returned. Must be freed with * libusb_free_ss_endpoint_companion_descriptor() after use. * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the configuration does not exist + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the configuration does not exist * \returns another LIBUSB_ERROR code on error */ int API_EXPORTED libusb_get_ss_endpoint_companion_descriptor( @@ -840,7 +840,7 @@ static int parse_bos(struct libusb_context *ctx, * \param bos output location for the BOS descriptor. Only valid if 0 was returned. * Must be freed with \ref libusb_free_bos_descriptor() after use. * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the device doesn't have a BOS descriptor + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the device doesn't have a BOS descriptor * \returns another LIBUSB_ERROR code on error */ int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *dev_handle, @@ -1070,6 +1070,70 @@ void API_EXPORTED libusb_free_container_id_descriptor( free(container_id); } +/** \ingroup libusb_desc + * Get a platform descriptor + * + * Since version 1.0.27, \ref LIBUSB_API_VERSION >= 0x0100010A + * + * \param ctx the context to operate on, or NULL for the default context + * \param dev_cap Device Capability descriptor with a bDevCapabilityType of + * \ref libusb_capability_type::LIBUSB_BT_PLATFORM_DESCRIPTOR + * LIBUSB_BT_PLATFORM_DESCRIPTOR + * \param platform_descriptor output location for the Platform descriptor. + * Only valid if 0 was returned. Must be freed with + * libusb_free_platform_descriptor() after use. + * \returns 0 on success + * \returns a LIBUSB_ERROR code on error + */ +int API_EXPORTED libusb_get_platform_descriptor(libusb_context *ctx, + struct libusb_bos_dev_capability_descriptor *dev_cap, + struct libusb_platform_descriptor **platform_descriptor) +{ + struct libusb_platform_descriptor *_platform_descriptor; + + if (dev_cap->bDevCapabilityType != LIBUSB_BT_PLATFORM_DESCRIPTOR) { + usbi_err(ctx, "unexpected bDevCapabilityType 0x%x (expected 0x%x)", + dev_cap->bDevCapabilityType, + LIBUSB_BT_PLATFORM_DESCRIPTOR); + return LIBUSB_ERROR_INVALID_PARAM; + } else if (dev_cap->bLength < LIBUSB_BT_PLATFORM_DESCRIPTOR_MIN_SIZE) { + usbi_err(ctx, "short dev-cap descriptor read %u/%d", + dev_cap->bLength, LIBUSB_BT_PLATFORM_DESCRIPTOR_MIN_SIZE); + return LIBUSB_ERROR_IO; + } + + _platform_descriptor = malloc(dev_cap->bLength); + if (!_platform_descriptor) + return LIBUSB_ERROR_NO_MEM; + + parse_descriptor(dev_cap, "bbbbu", _platform_descriptor); + + /* Capability data is located after reserved byte and 128-bit UUID */ + uint8_t* capability_data = dev_cap->dev_capability_data + 1 + 16; + + /* Capability data length is total descriptor length minus initial fields */ + size_t capability_data_length = _platform_descriptor->bLength - (16 + 4); + + memcpy(_platform_descriptor->CapabilityData, capability_data, capability_data_length); + + *platform_descriptor = _platform_descriptor; + return LIBUSB_SUCCESS; +} + +/** \ingroup libusb_desc + * Free a platform descriptor obtained from + * libusb_get_platform_descriptor(). + * It is safe to call this function with a NULL platform_descriptor parameter, + * in which case the function simply returns. + * + * \param platform_descriptor the Platform descriptor to free + */ +void API_EXPORTED libusb_free_platform_descriptor( + struct libusb_platform_descriptor *platform_descriptor) +{ + free(platform_descriptor); +} + /** \ingroup libusb_desc * Retrieve a string descriptor in C style ASCII. * @@ -1086,7 +1150,7 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_ha uint8_t desc_index, unsigned char *data, int length) { union usbi_string_desc_buf str; - int r, si, di; + int r; uint16_t langid, wdata; /* Asking for the zero'th index is special - it returns a string @@ -1122,18 +1186,214 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_ha else if ((str.desc.bLength & 1) || str.desc.bLength != r) usbi_warn(HANDLE_CTX(dev_handle), "suspicious bLength %u for string descriptor (read %d)", str.desc.bLength, r); - di = 0; - for (si = 2; si < str.desc.bLength; si += 2) { - if (di >= (length - 1)) - break; + /* Stop one byte before the end to leave room for null termination. */ + int dest_max = length - 1; + + /* The descriptor has this number of wide characters */ + int src_max = (str.desc.bLength - 1 - 1) / 2; - wdata = libusb_le16_to_cpu(str.desc.wData[di]); + /* Neither read nor write more than the smallest buffer */ + int idx_max = MIN(dest_max, src_max); + + int idx; + for (idx = 0; idx < idx_max; ++idx) { + wdata = libusb_le16_to_cpu(str.desc.wData[idx]); if (wdata < 0x80) - data[di++] = (unsigned char)wdata; + data[idx] = (unsigned char)wdata; else - data[di++] = '?'; /* non-ASCII */ + data[idx] = '?'; /* non-ASCII */ + } + + data[idx] = 0; /* null-terminate string */ + return idx; +} + +static int parse_iad_array(struct libusb_context *ctx, + struct libusb_interface_association_descriptor_array *iad_array, + const uint8_t *buffer, int size) +{ + uint8_t i; + struct usbi_descriptor_header header; + int consumed = 0; + const uint8_t *buf = buffer; + struct libusb_interface_association_descriptor *iad; + + if (size < LIBUSB_DT_CONFIG_SIZE) { + usbi_err(ctx, "short config descriptor read %d/%d", + size, LIBUSB_DT_CONFIG_SIZE); + return LIBUSB_ERROR_IO; + } + + // First pass: Iterate through desc list, count number of IADs + iad_array->length = 0; + while (consumed < size) { + parse_descriptor(buf, "bb", &header); + if (header.bLength < 2) { + usbi_err(ctx, "invalid descriptor bLength %d", + header.bLength); + return LIBUSB_ERROR_IO; + } + if (header.bDescriptorType == LIBUSB_DT_INTERFACE_ASSOCIATION) + iad_array->length++; + buf += header.bLength; + consumed += header.bLength; + } + + iad_array->iad = NULL; + if (iad_array->length > 0) { + iad = calloc(iad_array->length, sizeof(*iad)); + if (!iad) + return LIBUSB_ERROR_NO_MEM; + + iad_array->iad = iad; + + // Second pass: Iterate through desc list, fill IAD structures + consumed = 0; + i = 0; + while (consumed < size) { + parse_descriptor(buffer, "bb", &header); + if (header.bDescriptorType == LIBUSB_DT_INTERFACE_ASSOCIATION) + parse_descriptor(buffer, "bbbbbbbb", &iad[i++]); + buffer += header.bLength; + consumed += header.bLength; + } } - data[di] = 0; - return di; + return LIBUSB_SUCCESS; +} + +static int raw_desc_to_iad_array(struct libusb_context *ctx, const uint8_t *buf, + int size, struct libusb_interface_association_descriptor_array **iad_array) +{ + struct libusb_interface_association_descriptor_array *_iad_array + = calloc(1, sizeof(*_iad_array)); + int r; + + if (!_iad_array) + return LIBUSB_ERROR_NO_MEM; + + r = parse_iad_array(ctx, _iad_array, buf, size); + if (r < 0) { + usbi_err(ctx, "parse_iad_array failed with error %d", r); + free(_iad_array); + return r; + } + + *iad_array = _iad_array; + return LIBUSB_SUCCESS; +} + +/** \ingroup libusb_desc + * Get an array of interface association descriptors (IAD) for a given + * configuration. + * This is a non-blocking function which does not involve any requests being + * sent to the device. + * + * \param dev a device + * \param config_index the index of the configuration you wish to retrieve the + * IADs for. + * \param iad_array output location for the array of IADs. Only valid if 0 was + * returned. Must be freed with libusb_free_interface_association_descriptors() + * after use. It's possible that a given configuration contains no IADs. In this + * case the iad_array is still output, but will have 'length' field set to 0, and + * iad field set to NULL. + * \returns 0 on success + * \returns LIBUSB_ERROR_NOT_FOUND if the configuration does not exist + * \returns another LIBUSB_ERROR code on error + * \see libusb_get_active_interface_association_descriptors() + */ +int API_EXPORTED libusb_get_interface_association_descriptors(libusb_device *dev, + uint8_t config_index, struct libusb_interface_association_descriptor_array **iad_array) +{ + union usbi_config_desc_buf _config; + uint16_t config_len; + uint8_t *buf; + int r; + + if (!iad_array) + return LIBUSB_ERROR_INVALID_PARAM; + + usbi_dbg(DEVICE_CTX(dev), "IADs for config index %u", config_index); + if (config_index >= dev->device_descriptor.bNumConfigurations) + return LIBUSB_ERROR_NOT_FOUND; + + r = get_config_descriptor(dev, config_index, _config.buf, sizeof(_config.buf)); + if (r < 0) + return r; + + config_len = libusb_le16_to_cpu(_config.desc.wTotalLength); + buf = malloc(config_len); + if (!buf) + return LIBUSB_ERROR_NO_MEM; + + r = get_config_descriptor(dev, config_index, buf, config_len); + if (r >= 0) + r = raw_desc_to_iad_array(DEVICE_CTX(dev), buf, r, iad_array); + + free(buf); + return r; +} + +/** \ingroup libusb_desc + * Get an array of interface association descriptors (IAD) for the currently + * active configuration. + * This is a non-blocking function which does not involve any requests being + * sent to the device. + * + * \param dev a device + * \param iad_array output location for the array of IADs. Only valid if 0 was + * returned. Must be freed with libusb_free_interface_association_descriptors() + * after use. It's possible that a given configuration contains no IADs. In this + * case the iad_array is still output, but will have 'length' field set to 0, and + * iad field set to NULL. + * \returns 0 on success + * \returns LIBUSB_ERROR_NOT_FOUND if the device is in unconfigured state + * \returns another LIBUSB_ERROR code on error + * \see libusb_get_interface_association_descriptors + */ +int API_EXPORTED libusb_get_active_interface_association_descriptors(libusb_device *dev, + struct libusb_interface_association_descriptor_array **iad_array) +{ + union usbi_config_desc_buf _config; + uint16_t config_len; + uint8_t *buf; + int r; + + if (!iad_array) + return LIBUSB_ERROR_INVALID_PARAM; + + r = get_active_config_descriptor(dev, _config.buf, sizeof(_config.buf)); + if (r < 0) + return r; + + config_len = libusb_le16_to_cpu(_config.desc.wTotalLength); + buf = malloc(config_len); + if (!buf) + return LIBUSB_ERROR_NO_MEM; + + r = get_active_config_descriptor(dev, buf, config_len); + if (r >= 0) + r = raw_desc_to_iad_array(DEVICE_CTX(dev), buf, r, iad_array); + free(buf); + return r; +} + +/** \ingroup libusb_desc + * Free an array of interface association descriptors (IADs) obtained from + * libusb_get_interface_association_descriptors() or + * libusb_get_active_interface_association_descriptors(). + * It is safe to call this function with a NULL iad_array parameter, in which + * case the function simply returns. + * + * \param iad_array the IAD array to free + */ +void API_EXPORTED libusb_free_interface_association_descriptors( + struct libusb_interface_association_descriptor_array *iad_array) +{ + if (!iad_array) + return; + + if (iad_array->iad) + free((void*)iad_array->iad); + free(iad_array); } diff --git a/mac/libusb/hotplug.c b/mac/libusb/hotplug.c index 6b743c704..3c64f6919 100644 --- a/mac/libusb/hotplug.c +++ b/mac/libusb/hotplug.c @@ -33,7 +33,7 @@ * * \section hotplug_intro Introduction * - * Version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102, has added support + * Version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102, has added support * for hotplug events on some platforms (you should test if your platform * supports hotplug notification by calling \ref libusb_has_capability() with * parameter \ref LIBUSB_CAP_HAS_HOTPLUG). @@ -117,7 +117,7 @@ int main (void) { libusb_hotplug_callback_handle callback_handle; int rc; - libusb_init(NULL); + libusb_init_context(NULL, NULL, 0); rc = libusb_hotplug_register_callback(NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, 0, 0x045a, 0x5005, @@ -311,7 +311,7 @@ void usbi_hotplug_process(struct libusb_context *ctx, struct list_head *hotplug_ for_each_hotplug_cb_safe(ctx, hotplug_cb, next_cb) { if (hotplug_cb->flags & USBI_HOTPLUG_NEEDS_FREE) { usbi_dbg(ctx, "freeing hotplug cb %p with handle %d", - hotplug_cb, hotplug_cb->handle); + (void *) hotplug_cb, hotplug_cb->handle); list_del(&hotplug_cb->list); free(hotplug_cb); } @@ -377,7 +377,8 @@ int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx, usbi_mutex_unlock(&ctx->hotplug_cbs_lock); - usbi_dbg(ctx, "new hotplug cb %p with handle %d", hotplug_cb, hotplug_cb->handle); + usbi_dbg(ctx, "new hotplug cb %p with handle %d", + (void *) hotplug_cb, hotplug_cb->handle); if ((flags & LIBUSB_HOTPLUG_ENUMERATE) && (events & LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED)) { ssize_t i, len; diff --git a/mac/libusb/io.c b/mac/libusb/io.c index 9e3146cf9..ab84ba620 100644 --- a/mac/libusb/io.c +++ b/mac/libusb/io.c @@ -3,8 +3,8 @@ * I/O functions for libusb * Copyright © 2007-2009 Daniel Drake * Copyright © 2001 Johannes Erdfelt - * Copyright © 2019 Nathan Hjelm - * Copyright © 2019 Google LLC. All rights reserved. + * Copyright © 2019-2022 Nathan Hjelm + * Copyright © 2019-2022 Google LLC. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -313,6 +313,10 @@ if (r == 0 && actual_length == sizeof(data)) { * be invoked, and the callback function should check the transfer status to * determine that it was cancelled. * + * On macOS and iOS it is not possible to cancel a single transfer. In this + * case cancelling one transfer on an endpoint will cause all transfers on + * that endpoint to be cancelled. + * * Freeing the transfer after it has been cancelled but before cancellation * has completed will result in undefined behaviour. * @@ -1240,8 +1244,8 @@ void usbi_io_exit(struct libusb_context *ctx) static void calculate_timeout(struct usbi_transfer *itransfer) { - unsigned int timeout = - USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer)->timeout; + struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); + unsigned int timeout = transfer->timeout; if (!timeout) { TIMESPEC_CLEAR(&itransfer->timeout); @@ -1285,30 +1289,25 @@ DEFAULT_VISIBILITY struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer( int iso_packets) { - size_t priv_size; - size_t alloc_size; - unsigned char *ptr; - struct usbi_transfer *itransfer; - struct libusb_transfer *transfer; - assert(iso_packets >= 0); if (iso_packets < 0) return NULL; - priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size); - alloc_size = priv_size - + sizeof(struct usbi_transfer) - + sizeof(struct libusb_transfer) - + (sizeof(struct libusb_iso_packet_descriptor) * (size_t)iso_packets); - ptr = calloc(1, alloc_size); + size_t priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size); + size_t usbi_transfer_size = PTR_ALIGN(sizeof(struct usbi_transfer)); + size_t libusb_transfer_size = PTR_ALIGN(sizeof(struct libusb_transfer)); + size_t iso_packets_size = sizeof(struct libusb_iso_packet_descriptor) * (size_t)iso_packets; + size_t alloc_size = priv_size + usbi_transfer_size + libusb_transfer_size + iso_packets_size; + unsigned char *ptr = calloc(1, alloc_size); if (!ptr) return NULL; - itransfer = (struct usbi_transfer *)(ptr + priv_size); + struct usbi_transfer *itransfer = (struct usbi_transfer *)(ptr + priv_size); itransfer->num_iso_packets = iso_packets; itransfer->priv = ptr; usbi_mutex_init(&itransfer->lock); - transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); + struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); + return transfer; } @@ -1331,31 +1330,26 @@ struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer( */ void API_EXPORTED libusb_free_transfer(struct libusb_transfer *transfer) { - struct usbi_transfer *itransfer; - size_t priv_size; - unsigned char *ptr; - if (!transfer) return; - usbi_dbg(TRANSFER_CTX(transfer), "transfer %p", transfer); + usbi_dbg(TRANSFER_CTX(transfer), "transfer %p", (void *) transfer); if (transfer->flags & LIBUSB_TRANSFER_FREE_BUFFER) free(transfer->buffer); - itransfer = LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer); + struct usbi_transfer *itransfer = LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer); usbi_mutex_destroy(&itransfer->lock); if (itransfer->dev) libusb_unref_device(itransfer->dev); - priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size); - ptr = (unsigned char *)itransfer - priv_size; + unsigned char *ptr = USBI_TRANSFER_TO_TRANSFER_PRIV(itransfer); assert(ptr == itransfer->priv); free(ptr); } /* iterates through the flying transfers, and rearms the timer based on the * next upcoming timeout. - * must be called with flying_list locked. + * NB: flying_transfers_lock must be held when calling this. * returns 0 on success or a LIBUSB_ERROR code on failure. */ #ifdef HAVE_OS_TIMER @@ -1376,7 +1370,8 @@ static int arm_timer_for_next_timeout(struct libusb_context *ctx) /* act on first transfer that has not already been handled */ if (!(itransfer->timeout_flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))) { - usbi_dbg(ctx, "next timeout originally %ums", USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer)->timeout); + struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); + usbi_dbg(ctx, "next timeout originally %ums", transfer->timeout); return usbi_arm_timer(&ctx->timer, cur_ts); } } @@ -1394,7 +1389,8 @@ static inline int arm_timer_for_next_timeout(struct libusb_context *ctx) /* add a transfer to the (timeout-sorted) active transfers list. * This function will return non 0 if fails to update the timer, - * in which case the transfer is *not* on the flying_transfers list. */ + * in which case the transfer is *not* on the flying_transfers list. + * NB: flying_transfers_lock MUST be held when calling this. */ static int add_to_flying_list(struct usbi_transfer *itransfer) { struct usbi_transfer *cur; @@ -1438,8 +1434,9 @@ static int add_to_flying_list(struct usbi_transfer *itransfer) if (first && usbi_using_timer(ctx) && TIMESPEC_IS_SET(timeout)) { /* if this transfer has the lowest timeout of all active transfers, * rearm the timer with this transfer's timeout */ + struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); usbi_dbg(ctx, "arm timer for timeout in %ums (first in line)", - USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer)->timeout); + transfer->timeout); r = usbi_arm_timer(&ctx->timer, timeout); } #else @@ -1455,20 +1452,19 @@ static int add_to_flying_list(struct usbi_transfer *itransfer) /* remove a transfer from the active transfers list. * This function will *always* remove the transfer from the * flying_transfers list. It will return a LIBUSB_ERROR code - * if it fails to update the timer for the next timeout. */ + * if it fails to update the timer for the next timeout. + * NB: flying_transfers_lock MUST be held when calling this. */ static int remove_from_flying_list(struct usbi_transfer *itransfer) { struct libusb_context *ctx = ITRANSFER_CTX(itransfer); int rearm_timer; int r = 0; - usbi_mutex_lock(&ctx->flying_transfers_lock); rearm_timer = (TIMESPEC_IS_SET(&itransfer->timeout) && list_first_entry(&ctx->flying_transfers, struct usbi_transfer, list) == itransfer); list_del(&itransfer->list); if (rearm_timer) r = arm_timer_for_next_timeout(ctx); - usbi_mutex_unlock(&ctx->flying_transfers_lock); return r; } @@ -1479,11 +1475,11 @@ static int remove_from_flying_list(struct usbi_transfer *itransfer) * * \param transfer the transfer to submit * \returns 0 on success - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected - * \returns LIBUSB_ERROR_BUSY if the transfer has already been submitted. - * \returns LIBUSB_ERROR_NOT_SUPPORTED if the transfer flags are not supported + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_BUSY if the transfer has already been submitted. + * \returns \ref LIBUSB_ERROR_NOT_SUPPORTED if the transfer flags are not supported * by the operating system. - * \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than * the operating system and/or hardware can support (see \ref asynclimits) * \returns another LIBUSB_ERROR code on other failure */ @@ -1500,7 +1496,7 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer) itransfer->dev = libusb_ref_device(transfer->dev_handle->dev); ctx = HANDLE_CTX(transfer->dev_handle); - usbi_dbg(ctx, "transfer %p", transfer); + usbi_dbg(ctx, "transfer %p", (void *) transfer); /* * Important note on locking, this function takes / releases locks @@ -1562,8 +1558,11 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer) } usbi_mutex_unlock(&itransfer->lock); - if (r != LIBUSB_SUCCESS) + if (r != LIBUSB_SUCCESS) { + usbi_mutex_lock(&ctx->flying_transfers_lock); remove_from_flying_list(itransfer); + usbi_mutex_unlock(&ctx->flying_transfers_lock); + } return r; } @@ -1584,21 +1583,23 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer) * \ref libusb_transfer_status::LIBUSB_TRANSFER_CANCELLED * "LIBUSB_TRANSFER_CANCELLED" for each transfer that was cancelled. - * - Calling this function also sends a \c ClearFeature(ENDPOINT_HALT) request - * for the transfer's endpoint. If the device does not handle this request - * correctly, the data toggle bits for the endpoint can be left out of sync - * between host and device, which can have unpredictable results when the - * next data is sent on the endpoint, including data being silently lost. - * A call to \ref libusb_clear_halt will not resolve this situation, since - * that function uses the same request. Therefore, if your program runs on - * Darwin and uses a device that does not correctly implement - * \c ClearFeature(ENDPOINT_HALT) requests, it may only be safe to cancel - * transfers when followed by a device reset using + * - When built for macOS versions prior to 10.5, this function sends a + * \c ClearFeature(ENDPOINT_HALT) request for the transfer's endpoint. + * (Prior to libusb 1.0.27, this request was sent on all Darwin systems.) + * If the device does not handle this request correctly, the data toggle + * bits for the endpoint can be left out of sync between host and device, + * which can have unpredictable results when the next data is sent on + * the endpoint, including data being silently lost. A call to + * \ref libusb_clear_halt will not resolve this situation, since that + * function uses the same request. Therefore, if your program runs on + * macOS < 10.5 (or libusb < 1.0.27), and uses a device that does not + * correctly implement \c ClearFeature(ENDPOINT_HALT) requests, it may + * only be safe to cancel transfers when followed by a device reset using * \ref libusb_reset_device. * * \param transfer the transfer to cancel * \returns 0 on success - * \returns LIBUSB_ERROR_NOT_FOUND if the transfer is not in progress, + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the transfer is not in progress, * already complete, or already cancelled. * \returns a LIBUSB_ERROR code on failure */ @@ -1609,7 +1610,7 @@ int API_EXPORTED libusb_cancel_transfer(struct libusb_transfer *transfer) struct libusb_context *ctx = ITRANSFER_CTX(itransfer); int r; - usbi_dbg(ctx, "transfer %p", transfer ); + usbi_dbg(ctx, "transfer %p", (void *) transfer ); usbi_mutex_lock(&itransfer->lock); if (!(itransfer->state_flags & USBI_TRANSFER_IN_FLIGHT) || (itransfer->state_flags & USBI_TRANSFER_CANCELLING)) { @@ -1689,7 +1690,9 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer, uint8_t flags; int r; + usbi_mutex_lock(&ctx->flying_transfers_lock); r = remove_from_flying_list(itransfer); + usbi_mutex_unlock(&ctx->flying_transfers_lock); if (r < 0) usbi_err(ctx, "failed to set timer for next timeout"); @@ -1711,9 +1714,13 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer, flags = transfer->flags; transfer->status = status; transfer->actual_length = itransfer->transferred; - usbi_dbg(ctx, "transfer %p has callback %p", transfer, transfer->callback); - if (transfer->callback) + usbi_dbg(ctx, "transfer %p has callback %p", + (void *) transfer, transfer->callback); + if (transfer->callback) { + libusb_lock_event_waiters (ctx); transfer->callback(transfer); + libusb_unlock_event_waiters(ctx); + } /* transfer might have been freed by the above call, do not use from * this point. */ if (flags & LIBUSB_TRANSFER_FREE_TRANSFER) @@ -2013,7 +2020,7 @@ void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx) * indicates unlimited timeout. * \returns 0 after a transfer completes or another thread stops event handling * \returns 1 if the timeout expired - * \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if timeval is invalid * \ref libusb_mtasync */ int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv) @@ -2037,6 +2044,7 @@ int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv) return 0; } +// NB: flying_transfers_lock must be held when calling this static void handle_timeout(struct usbi_transfer *itransfer) { struct libusb_transfer *transfer = @@ -2052,6 +2060,7 @@ static void handle_timeout(struct usbi_transfer *itransfer) "async cancel failed %d", r); } +// NB: flying_transfers_lock must be held when calling this static void handle_timeouts_locked(struct libusb_context *ctx) { struct timespec systime; @@ -2332,7 +2341,7 @@ static int get_next_timeout(libusb_context *ctx, struct timeval *tv, * timeval struct for non-blocking mode * \param completed pointer to completion integer to check, or NULL * \returns 0 on success - * \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if timeval is invalid * \returns another LIBUSB_ERROR code on other failure * \ref libusb_mtasync */ @@ -2474,7 +2483,7 @@ int API_EXPORTED libusb_handle_events_completed(libusb_context *ctx, * \param tv the maximum time to block waiting for events, or zero for * non-blocking mode * \returns 0 on success - * \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if timeval is invalid * \returns another LIBUSB_ERROR code on other failure * \ref libusb_mtasync */ @@ -2558,7 +2567,7 @@ int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx) * \param tv output location for a relative time against the current * clock in which libusb must be called into in order to process timeout events * \returns 0 if there are no pending timeouts, 1 if a timeout was returned, - * or LIBUSB_ERROR_OTHER on failure + * or \ref LIBUSB_ERROR_OTHER on failure */ int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv) @@ -2619,11 +2628,11 @@ int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx, * To remove notifiers, pass NULL values for the function pointers. * * Note that file descriptors may have been added even before you register - * these notifiers (e.g. at libusb_init() time). + * these notifiers (e.g. at libusb_init_context() time). * * Additionally, note that the removal notifier may be called during * libusb_exit() (e.g. when it is closing file descriptors that were opened - * and added to the poll set at libusb_init() time). If you don't want this, + * and added to the poll set at libusb_init_context() time). If you don't want this, * remove the notifiers immediately before calling libusb_exit(). * * \param ctx the context to operate on, or NULL for the default context @@ -2827,7 +2836,8 @@ void usbi_handle_disconnect(struct libusb_device_handle *dev_handle) to_cancel = NULL; usbi_mutex_lock(&ctx->flying_transfers_lock); for_each_transfer(ctx, cur) { - if (USBI_TRANSFER_TO_LIBUSB_TRANSFER(cur)->dev_handle == dev_handle) { + struct libusb_transfer *cur_transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(cur); + if (cur_transfer->dev_handle == dev_handle) { usbi_mutex_lock(&cur->lock); if (cur->state_flags & USBI_TRANSFER_IN_FLIGHT) to_cancel = cur; @@ -2842,8 +2852,9 @@ void usbi_handle_disconnect(struct libusb_device_handle *dev_handle) if (!to_cancel) break; + struct libusb_transfer *transfer_to_cancel = USBI_TRANSFER_TO_LIBUSB_TRANSFER(to_cancel); usbi_dbg(ctx, "cancelling transfer %p from disconnect", - USBI_TRANSFER_TO_LIBUSB_TRANSFER(to_cancel)); + (void *) transfer_to_cancel); usbi_mutex_lock(&to_cancel->lock); usbi_backend.clear_transfer_priv(to_cancel); diff --git a/mac/libusb/libusb.h b/mac/libusb/libusb.h index 2592ea779..f4e9203c6 100644 --- a/mac/libusb/libusb.h +++ b/mac/libusb/libusb.h @@ -3,9 +3,9 @@ * Copyright © 2001 Johannes Erdfelt * Copyright © 2007-2008 Daniel Drake * Copyright © 2012 Pete Batard - * Copyright © 2012-2018 Nathan Hjelm + * Copyright © 2012-2023 Nathan Hjelm * Copyright © 2014-2020 Chris Dickens - * For more information, please visit: http://libusb.info + * For more information, please visit: https://libusb.info * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -50,9 +50,9 @@ typedef SSIZE_T ssize_t; #include #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#define ZERO_SIZED_ARRAY /* [] - valid C99 code */ +#define LIBUSB_FLEXIBLE_ARRAY /* [] - valid C99 code */ #else -#define ZERO_SIZED_ARRAY 0 /* [0] - non-standard, but usually working code */ +#define LIBUSB_FLEXIBLE_ARRAY 0 /* [0] - non-standard, but usually working code */ #endif /* __STDC_VERSION__ */ /* 'interface' might be defined as a macro on Windows, so we need to @@ -74,6 +74,8 @@ typedef SSIZE_T ssize_t; #define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated ("Use " #f " instead"))) #elif defined(__GNUC__) && (__GNUC__ >= 3) #define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated)) +#elif defined(_MSC_VER) +#define LIBUSB_DEPRECATED_FOR(f) __declspec(deprecated("Use " #f " instead")) #else #define LIBUSB_DEPRECATED_FOR(f) #endif /* __GNUC__ */ @@ -118,20 +120,25 @@ typedef SSIZE_T ssize_t; */ #if defined(_WIN32) || defined(__CYGWIN__) #define LIBUSB_CALL WINAPI +#define LIBUSB_CALLV WINAPIV #else #define LIBUSB_CALL +#define LIBUSB_CALLV #endif /* _WIN32 || __CYGWIN__ */ /** \def LIBUSB_API_VERSION * \ingroup libusb_misc * libusb's API version. * - * Since version 1.0.13, to help with feature detection, libusb defines + * Since version 1.0.18, to help with feature detection, libusb defines * a LIBUSB_API_VERSION macro that gets increased every time there is a * significant change to the API, such as the introduction of a new call, * the definition of a new macro/enum member, or any other element that * libusb applications may want to detect at compilation time. * + * Between versions 1.0.13 and 1.0.17 (inclusive) the older spelling of + * LIBUSBX_API_VERSION was used. + * * The macro is typically used in an application as follows: * \code * #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234) @@ -141,10 +148,34 @@ typedef SSIZE_T ssize_t; * * Internally, LIBUSB_API_VERSION is defined as follows: * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental) + * + * The incremental component has changed as follows: + *

    + *
  • libusbx version 1.0.13: LIBUSBX_API_VERSION = 0x01000100 + *
  • libusbx version 1.0.14: LIBUSBX_API_VERSION = 0x010000FF + *
  • libusbx version 1.0.15: LIBUSBX_API_VERSION = 0x01000101 + *
  • libusbx version 1.0.16: LIBUSBX_API_VERSION = 0x01000102 + *
  • libusbx version 1.0.17: LIBUSBX_API_VERSION = 0x01000102 + *
  • libusb version 1.0.18: LIBUSB_API_VERSION = 0x01000102 + *
  • libusb version 1.0.19: LIBUSB_API_VERSION = 0x01000103 + *
  • libusb version 1.0.20: LIBUSB_API_VERSION = 0x01000104 + *
  • libusb version 1.0.21: LIBUSB_API_VERSION = 0x01000105 + *
  • libusb version 1.0.22: LIBUSB_API_VERSION = 0x01000106 + *
  • libusb version 1.0.23: LIBUSB_API_VERSION = 0x01000107 + *
  • libusb version 1.0.24: LIBUSB_API_VERSION = 0x01000108 + *
  • libusb version 1.0.25: LIBUSB_API_VERSION = 0x01000109 + *
  • libusb version 1.0.26: LIBUSB_API_VERSION = 0x01000109 + *
  • libusb version 1.0.27: LIBUSB_API_VERSION = 0x0100010A + *
*/ -#define LIBUSB_API_VERSION 0x01000109 +#define LIBUSB_API_VERSION 0x0100010A -/* The following is kept for compatibility, but will be deprecated in the future */ +/** \def LIBUSBX_API_VERSION + * \ingroup libusb_misc + * + * This is the older spelling, kept for backwards compatibility of code + * needing to test for older library versions where the newer spelling + * did not exist. */ #define LIBUSBX_API_VERSION LIBUSB_API_VERSION #if defined(__cplusplus) @@ -265,6 +296,10 @@ enum libusb_descriptor_type { /** Endpoint descriptor. See libusb_endpoint_descriptor. */ LIBUSB_DT_ENDPOINT = 0x05, + /** Interface Association Descriptor. + * See libusb_interface_association_descriptor */ + LIBUSB_DT_INTERFACE_ASSOCIATION = 0x0b, + /** BOS descriptor */ LIBUSB_DT_BOS = 0x0f, @@ -305,6 +340,7 @@ enum libusb_descriptor_type { #define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7 #define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10 #define LIBUSB_BT_CONTAINER_ID_SIZE 20 +#define LIBUSB_BT_PLATFORM_DESCRIPTOR_MIN_SIZE 20 /* We unwrap the BOS => define its max size */ #define LIBUSB_DT_BOS_MAX_SIZE \ @@ -523,7 +559,10 @@ enum libusb_bos_type { LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 0x03, /** Container ID type */ - LIBUSB_BT_CONTAINER_ID = 0x04 + LIBUSB_BT_CONTAINER_ID = 0x04, + + /** Platform descriptor */ + LIBUSB_BT_PLATFORM_DESCRIPTOR = 0x05 }; /** \ingroup libusb_desc @@ -628,6 +667,65 @@ struct libusb_endpoint_descriptor { int extra_length; }; +/** \ingroup libusb_desc + * A structure representing the standard USB interface association descriptor. + * This descriptor is documented in section 9.6.4 of the USB 3.0 specification. + * All multiple-byte fields are represented in host-endian format. + */ +struct libusb_interface_association_descriptor { + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE_ASSOCIATION + * LIBUSB_DT_INTERFACE_ASSOCIATION in this context. */ + uint8_t bDescriptorType; + + /** Interface number of the first interface that is associated + * with this function */ + uint8_t bFirstInterface; + + /** Number of contiguous interfaces that are associated with + * this function */ + uint8_t bInterfaceCount; + + /** USB-IF class code for this function. + * A value of zero is not allowed in this descriptor. + * If this field is 0xff, the function class is vendor-specific. + * All other values are reserved for assignment by the USB-IF. + */ + uint8_t bFunctionClass; + + /** USB-IF subclass code for this function. + * If this field is not set to 0xff, all values are reserved + * for assignment by the USB-IF + */ + uint8_t bFunctionSubClass; + + /** USB-IF protocol code for this function. + * These codes are qualified by the values of the bFunctionClass + * and bFunctionSubClass fields. + */ + uint8_t bFunctionProtocol; + + /** Index of string descriptor describing this function */ + uint8_t iFunction; +}; + +/** \ingroup libusb_desc + * Structure containing an array of 0 or more interface association + * descriptors + */ +struct libusb_interface_association_descriptor_array { + /** Array of interface association descriptors. The size of this array + * is determined by the length field. + */ + const struct libusb_interface_association_descriptor *iad; + + /** Number of interface association descriptors contained. Read-only. */ + int length; +}; + /** \ingroup libusb_desc * A structure representing the standard USB interface descriptor. This * descriptor is documented in section 9.6.5 of the USB 3.0 specification. @@ -786,7 +884,7 @@ struct libusb_bos_dev_capability_descriptor { uint8_t bDevCapabilityType; /** Device Capability data (bLength - 3 bytes) */ - uint8_t dev_capability_data[ZERO_SIZED_ARRAY]; + uint8_t dev_capability_data[LIBUSB_FLEXIBLE_ARRAY]; }; /** \ingroup libusb_desc @@ -811,7 +909,7 @@ struct libusb_bos_descriptor { uint8_t bNumDeviceCaps; /** bNumDeviceCap Device Capability Descriptors */ - struct libusb_bos_dev_capability_descriptor *dev_capability[ZERO_SIZED_ARRAY]; + struct libusb_bos_dev_capability_descriptor *dev_capability[LIBUSB_FLEXIBLE_ARRAY]; }; /** \ingroup libusb_desc @@ -908,6 +1006,34 @@ struct libusb_container_id_descriptor { uint8_t ContainerID[16]; }; +/** \ingroup libusb_desc + * A structure representing a Platform descriptor. + * This descriptor is documented in section 9.6.2.4 of the USB 3.2 specification. + */ +struct libusb_platform_descriptor { + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY + * LIBUSB_DT_DEVICE_CAPABILITY in this context. */ + uint8_t bDescriptorType; + + /** Capability type. Will have value + * \ref libusb_capability_type::LIBUSB_BT_PLATFORM_DESCRIPTOR + * LIBUSB_BT_CONTAINER_ID in this context. */ + uint8_t bDevCapabilityType; + + /** Reserved field */ + uint8_t bReserved; + + /** 128 bit UUID */ + uint8_t PlatformCapabilityUUID[16]; + + /** Capability data (bLength - 20) */ + uint8_t CapabilityData[LIBUSB_FLEXIBLE_ARRAY]; +}; + /** \ingroup libusb_asyncio * Setup packet for control transfers. */ #if defined(_MSC_VER) || defined(__WATCOMC__) @@ -982,7 +1108,7 @@ struct libusb_version { * libusb_exit() will not destroy resources that the other user is still * using. * - * Sessions are created by libusb_init() and destroyed through libusb_exit(). + * Sessions are created by libusb_init_context() and destroyed through libusb_exit(). * If your application is guaranteed to only ever include a single libusb * user (i.e. you), you do not have to worry about contexts: pass NULL in * every function call where a context is required, and the default context @@ -1187,7 +1313,8 @@ enum libusb_transfer_flags { * * This flag is currently only supported on Linux. * On other systems, libusb_submit_transfer() will return - * LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this flag is set. + * \ref LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this + * flag is set. * * Available since libusb-1.0.9. */ @@ -1284,7 +1411,7 @@ struct libusb_transfer { int num_iso_packets; /** Isochronous packet descriptors, for isochronous transfers only. */ - struct libusb_iso_packet_descriptor iso_packet_desc[ZERO_SIZED_ARRAY]; + struct libusb_iso_packet_descriptor iso_packet_desc[LIBUSB_FLEXIBLE_ARRAY]; }; /** \ingroup libusb_misc @@ -1345,6 +1472,79 @@ enum libusb_log_cb_mode { LIBUSB_LOG_CB_CONTEXT = (1 << 1) }; +/** \ingroup libusb_lib + * Available option values for libusb_set_option() and libusb_init_context(). + */ +enum libusb_option { + /** Set the log message verbosity. + * + * This option must be provided an argument of type \ref libusb_log_level. + * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever + * printed. If you choose to increase the message verbosity level, ensure + * that your application does not close the stderr file descriptor. + * + * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative + * with its message logging and most of the time, will only log messages that + * explain error conditions and other oddities. This will help you debug + * your software. + * + * If the LIBUSB_DEBUG environment variable was set when libusb was + * initialized, this option does nothing: the message verbosity is fixed + * to the value in the environment variable. + * + * If libusb was compiled without any message logging, this option does + * nothing: you'll never get any messages. + * + * If libusb was compiled with verbose debug message logging, this option + * does nothing: you'll always get messages from all levels. + */ + LIBUSB_OPTION_LOG_LEVEL = 0, + + /** Use the UsbDk backend for a specific context, if available. + * + * This option should be set at initialization with libusb_init_context() + * otherwise unspecified behavior may occur. + * + * Only valid on Windows. Ignored on all other platforms. + */ + LIBUSB_OPTION_USE_USBDK = 1, + + /** Do not scan for devices + * + * With this option set, libusb will skip scanning devices in + * libusb_init_context(). + * + * Hotplug functionality will also be deactivated. + * + * The option is useful in combination with libusb_wrap_sys_device(), + * which can access a device directly without prior device scanning. + * + * This is typically needed on Android, where access to USB devices + * is limited. + * + * This option should only be used with libusb_init_context() + * otherwise unspecified behavior may occur. + * + * Only valid on Linux. Ignored on all other platforms. + */ + LIBUSB_OPTION_NO_DEVICE_DISCOVERY = 2, + +#define LIBUSB_OPTION_WEAK_AUTHORITY LIBUSB_OPTION_NO_DEVICE_DISCOVERY + + /** Set the context log callback function. + * + * Set the log callback function either on a context or globally. This + * option must be provided an argument of type \ref libusb_log_cb. + * Using this option with a NULL context is equivalent to calling + * libusb_set_log_cb() with mode \ref LIBUSB_LOG_CB_GLOBAL. + * Using it with a non-NULL context is equivalent to calling + * libusb_set_log_cb() with mode \ref LIBUSB_LOG_CB_CONTEXT. + */ + LIBUSB_OPTION_LOG_CB = 3, + + LIBUSB_OPTION_MAX = 4 +}; + /** \ingroup libusb_lib * Callback function for handling log messages. * \param ctx the context which is related to the log message, or NULL if it @@ -1359,10 +1559,25 @@ enum libusb_log_cb_mode { typedef void (LIBUSB_CALL *libusb_log_cb)(libusb_context *ctx, enum libusb_log_level level, const char *str); +/** \ingroup libusb_lib + * Structure used for setting options through \ref libusb_init_context. + * + */ +struct libusb_init_option { + /** Which option to set */ + enum libusb_option option; + /** An integer value used by the option (if applicable). */ + union { + int ival; + libusb_log_cb log_cbval; + } value; +}; + int LIBUSB_CALL libusb_init(libusb_context **ctx); +int LIBUSB_CALL libusb_init_context(libusb_context **ctx, const struct libusb_init_option options[], int num_options); void LIBUSB_CALL libusb_exit(libusb_context *ctx); -LIBUSB_DEPRECATED_FOR(libusb_set_option) void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level); +/* may be deprecated in the future in favor of lubusb_init_context()+libusb_set_option() */ void LIBUSB_CALL libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode); const struct libusb_version * LIBUSB_CALL libusb_get_version(void); int LIBUSB_CALL libusb_has_capability(uint32_t capability); @@ -1415,6 +1630,11 @@ int LIBUSB_CALL libusb_get_container_id_descriptor(libusb_context *ctx, struct libusb_container_id_descriptor **container_id); void LIBUSB_CALL libusb_free_container_id_descriptor( struct libusb_container_id_descriptor *container_id); +int LIBUSB_CALL libusb_get_platform_descriptor(libusb_context *ctx, + struct libusb_bos_dev_capability_descriptor *dev_cap, + struct libusb_platform_descriptor **platform_descriptor); +void LIBUSB_CALL libusb_free_platform_descriptor( + struct libusb_platform_descriptor *platform_descriptor); uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev); uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev); int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len); @@ -1427,6 +1647,15 @@ int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint); int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoint); +int LIBUSB_CALL libusb_get_max_alt_packet_size(libusb_device *dev, + int interface_number, int alternate_setting, unsigned char endpoint); + +int LIBUSB_CALL libusb_get_interface_association_descriptors(libusb_device *dev, + uint8_t config_index, struct libusb_interface_association_descriptor_array **iad_array); +int LIBUSB_CALL libusb_get_active_interface_association_descriptors(libusb_device *dev, + struct libusb_interface_association_descriptor_array **iad_array); +void LIBUSB_CALL libusb_free_interface_association_descriptors( + struct libusb_interface_association_descriptor_array *iad_array); int LIBUSB_CALL libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle); int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **dev_handle); @@ -2036,7 +2265,7 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx, * \param[in] cb_fn the function to be invoked on a matching event/device * \param[in] user_data user data to pass to the callback function * \param[out] callback_handle pointer to store the handle of the allocated callback (can be NULL) - * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure + * \returns \ref LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure */ int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx, int events, int flags, @@ -2069,67 +2298,7 @@ void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx, void * LIBUSB_CALL libusb_hotplug_get_user_data(libusb_context *ctx, libusb_hotplug_callback_handle callback_handle); -/** \ingroup libusb_lib - * Available option values for libusb_set_option(). - */ -enum libusb_option { - /** Set the log message verbosity. - * - * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever - * printed. If you choose to increase the message verbosity level, ensure - * that your application does not close the stderr file descriptor. - * - * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative - * with its message logging and most of the time, will only log messages that - * explain error conditions and other oddities. This will help you debug - * your software. - * - * If the LIBUSB_DEBUG environment variable was set when libusb was - * initialized, this function does nothing: the message verbosity is fixed - * to the value in the environment variable. - * - * If libusb was compiled without any message logging, this function does - * nothing: you'll never get any messages. - * - * If libusb was compiled with verbose debug message logging, this function - * does nothing: you'll always get messages from all levels. - */ - LIBUSB_OPTION_LOG_LEVEL = 0, - - /** Use the UsbDk backend for a specific context, if available. - * - * This option should be set immediately after calling libusb_init(), otherwise - * unspecified behavior may occur. - * - * Only valid on Windows. - */ - LIBUSB_OPTION_USE_USBDK = 1, - - /** Do not scan for devices - * - * With this option set, libusb will skip scanning devices in - * libusb_init(). Must be set before calling libusb_init(). - * - * Hotplug functionality will also be deactivated. - * - * The option is useful in combination with libusb_wrap_sys_device(), - * which can access a device directly without prior device scanning. - * - * This is typically needed on Android, where access to USB devices - * is limited. - * - * For LIBUSB_API_VERSION 0x01000108 it was called LIBUSB_OPTION_WEAK_AUTHORITY - * - * Only valid on Linux. - */ - LIBUSB_OPTION_NO_DEVICE_DISCOVERY = 2, - -#define LIBUSB_OPTION_WEAK_AUTHORITY LIBUSB_OPTION_NO_DEVICE_DISCOVERY - - LIBUSB_OPTION_MAX = 3 -}; - -int LIBUSB_CALL libusb_set_option(libusb_context *ctx, enum libusb_option option, ...); +int LIBUSB_CALLV libusb_set_option(libusb_context *ctx, enum libusb_option option, ...); #ifdef _MSC_VER #pragma warning(pop) diff --git a/mac/libusb/libusbi.h b/mac/libusb/libusbi.h index b1fc88c99..3b0c6105c 100644 --- a/mac/libusb/libusbi.h +++ b/mac/libusb/libusbi.h @@ -73,7 +73,7 @@ #endif /* The following is used to silence warnings for unused variables */ -#if defined(UNREFERENCED_PARAMETER) +#if defined(UNREFERENCED_PARAMETER) && !defined(__GNUC__) #define UNUSED(var) UNREFERENCED_PARAMETER(var) #else #define UNUSED(var) do { (void)(var); } while(0) @@ -128,6 +128,7 @@ typedef atomic_long usbi_atomic_t; * return_type LIBUSB_CALL function_name(params); */ #define API_EXPORTED LIBUSB_CALL DEFAULT_VISIBILITY +#define API_EXPORTEDV LIBUSB_CALLV DEFAULT_VISIBILITY #ifdef __cplusplus extern "C" { @@ -321,10 +322,10 @@ void usbi_log(struct libusb_context *ctx, enum libusb_log_level level, #else /* ENABLE_LOGGING */ -#define usbi_err(ctx, ...) UNUSED(ctx) -#define usbi_warn(ctx, ...) UNUSED(ctx) -#define usbi_info(ctx, ...) UNUSED(ctx) -#define usbi_dbg(ctx, ...) do {} while (0) +#define usbi_err(ctx, ...) do { (void)(ctx); } while(0) +#define usbi_warn(ctx, ...) do { (void)(ctx); } while(0) +#define usbi_info(ctx, ...) do { (void)(ctx); } while(0) +#define usbi_dbg(ctx, ...) do { (void)(ctx); } while(0) #endif /* ENABLE_LOGGING */ @@ -379,7 +380,7 @@ struct libusb_context { struct list_head flying_transfers; /* Note paths taking both this and usbi_transfer->lock must always * take this lock first */ - usbi_mutex_t flying_transfers_lock; + usbi_mutex_t flying_transfers_lock; /* for flying_transfers and timeout_flags */ #if !defined(PLATFORM_WINDOWS) /* user callbacks for pollfd changes */ @@ -533,7 +534,7 @@ static inline void usbi_localize_device_descriptor(struct libusb_device_descript desc->bcdDevice = libusb_le16_to_cpu(desc->bcdDevice); } -#ifdef HAVE_CLOCK_GETTIME +#if defined(HAVE_CLOCK_GETTIME) && !defined(__APPLE__) static inline void usbi_get_monotonic_time(struct timespec *tp) { ASSERT_EQ(clock_gettime(CLOCK_MONOTONIC, tp), 0); @@ -562,8 +563,11 @@ void usbi_get_real_time(struct timespec *tp); * 2. struct usbi_transfer * 3. struct libusb_transfer (which includes iso packets) [variable size] * - * from a libusb_transfer, you can get the usbi_transfer by rewinding the - * appropriate number of bytes. + * You can convert between them with the macros: + * TRANSFER_PRIV_TO_USBI_TRANSFER + * USBI_TRANSFER_TO_TRANSFER_PRIV + * USBI_TRANSFER_TO_LIBUSB_TRANSFER + * LIBUSB_TRANSFER_TO_USBI_TRANSFER */ struct usbi_transfer { @@ -574,7 +578,7 @@ struct usbi_transfer { int transferred; uint32_t stream_id; uint32_t state_flags; /* Protected by usbi_transfer->lock */ - uint32_t timeout_flags; /* Protected by the flying_stransfers_lock */ + uint32_t timeout_flags; /* Protected by the flying_transfers_lock */ /* The device reference is held until destruction for logging * even after dev_handle is set to NULL. */ @@ -616,10 +620,21 @@ enum usbi_transfer_timeout_flags { USBI_TRANSFER_TIMED_OUT = 1U << 2, }; +#define TRANSFER_PRIV_TO_USBI_TRANSFER(transfer_priv) \ + ((struct usbi_transfer *) \ + ((unsigned char *)(transfer_priv) \ + + PTR_ALIGN(sizeof(*transfer_priv)))) + +#define USBI_TRANSFER_TO_TRANSFER_PRIV(itransfer) \ + ((unsigned char *) \ + ((unsigned char *)(itransfer) \ + - PTR_ALIGN(usbi_backend.transfer_priv_size))) + #define USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer) \ ((struct libusb_transfer *) \ ((unsigned char *)(itransfer) \ + PTR_ALIGN(sizeof(struct usbi_transfer)))) + #define LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer) \ ((struct usbi_transfer *) \ ((unsigned char *)(transfer) \ @@ -678,7 +693,7 @@ struct usbi_interface_descriptor { struct usbi_string_descriptor { uint8_t bLength; uint8_t bDescriptorType; - uint16_t wData[ZERO_SIZED_ARRAY]; + uint16_t wData[LIBUSB_FLEXIBLE_ARRAY]; } LIBUSB_PACKED; struct usbi_bos_descriptor { @@ -813,6 +828,7 @@ struct usbi_option { int is_set; union { int ival; + libusb_log_cb log_cbval; } arg; }; @@ -891,7 +907,7 @@ static inline void *usbi_get_transfer_priv(struct usbi_transfer *itransfer) struct discovered_devs { size_t len; size_t capacity; - struct libusb_device *devices[ZERO_SIZED_ARRAY]; + struct libusb_device *devices[LIBUSB_FLEXIBLE_ARRAY]; }; struct discovered_devs *discovered_devs_append( @@ -1180,6 +1196,8 @@ struct usbi_os_backend { * claiming, no other drivers/applications can use the interface because * we now "own" it. * + * This function gets called with dev_handle->lock locked! + * * Return: * - 0 on success * - LIBUSB_ERROR_NOT_FOUND if the interface does not exist @@ -1199,6 +1217,8 @@ struct usbi_os_backend { * You will only ever be asked to release an interface which was * successfully claimed earlier. * + * This function gets called with dev_handle->lock locked! + * * Return: * - 0 on success * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it @@ -1335,7 +1355,7 @@ struct usbi_os_backend { * * This function must not block. * - * This function gets called with the flying_transfers_lock locked! + * This function gets called with itransfer->lock locked! * * Return: * - 0 on success @@ -1349,6 +1369,8 @@ struct usbi_os_backend { * This function must not block. The transfer cancellation must complete * later, resulting in a call to usbi_handle_transfer_cancellation() * from the context of handle_events. + * + * This function gets called with itransfer->lock locked! */ int (*cancel_transfer)(struct usbi_transfer *itransfer); diff --git a/mac/libusb/os/darwin_usb.c b/mac/libusb/os/darwin_usb.c index 388dbca60..c0963e09b 100644 --- a/mac/libusb/os/darwin_usb.c +++ b/mac/libusb/os/darwin_usb.c @@ -1,8 +1,8 @@ /* -*- Mode: C; indent-tabs-mode:nil -*- */ /* * darwin backend for libusb 1.0 - * Copyright © 2008-2021 Nathan Hjelm - * Copyright © 2019-2021 Google LLC. All rights reserved. + * Copyright © 2008-2023 Nathan Hjelm + * Copyright © 2019-2023 Google LLC. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,10 +32,7 @@ #include #include -#include -#include -#include -#include +#include /* Suppress warnings about the use of the deprecated objc_registerThreadWithCollector * function. Its use is also conditionalized to only older deployment targets. */ @@ -58,28 +55,34 @@ static int init_count = 0; static const mach_port_t darwin_default_master_port = 0; /* async event thread */ +/* if both this mutex and darwin_cached_devices_mutex are to be acquired then + darwin_cached_devices_mutex must be acquired first. */ static pthread_mutex_t libusb_darwin_at_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t libusb_darwin_at_cond = PTHREAD_COND_INITIALIZER; -#if !defined(HAVE_CLOCK_GETTIME) -static clock_serv_t clock_realtime; -static clock_serv_t clock_monotonic; -#endif - #define LIBUSB_DARWIN_STARTUP_FAILURE ((CFRunLoopRef) -1) static CFRunLoopRef libusb_darwin_acfl = NULL; /* event cf loop */ static CFRunLoopSourceRef libusb_darwin_acfls = NULL; /* shutdown signal for event cf loop */ -static usbi_mutex_t darwin_cached_devices_lock = PTHREAD_MUTEX_INITIALIZER; +static usbi_mutex_t darwin_cached_devices_mutex = PTHREAD_MUTEX_INITIALIZER; static struct list_head darwin_cached_devices; static const char *darwin_device_class = "IOUSBDevice"; +uint32_t libusb_testonly_fake_running_version __attribute__ ((visibility ("hidden"))); +int libusb_testonly_using_running_interface_version __attribute__ ((visibility ("hidden"))); +int libusb_testonly_using_running_device_version __attribute__ ((visibility ("hidden"))); +bool libusb_testonly_clear_running_version_cache __attribute__ ((visibility ("hidden"))); + #define DARWIN_CACHED_DEVICE(a) (((struct darwin_device_priv *)usbi_get_device_priv((a)))->dev) /* async event thread */ static pthread_t libusb_darwin_at; +/* protected by libusb_darwin_at_mutex */ +static bool libusb_darwin_at_started; + +static void darwin_exit(struct libusb_context *ctx); static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, void *buffer, size_t len); static int darwin_claim_interface(struct libusb_device_handle *dev_handle, uint8_t iface); static int darwin_release_interface(struct libusb_device_handle *dev_handle, uint8_t iface); @@ -96,6 +99,186 @@ static enum libusb_error process_new_device (struct libusb_context *ctx, struct static enum libusb_error darwin_get_cached_device(struct libusb_context *ctx, io_service_t service, struct darwin_cached_device **cached_out, UInt64 *old_session_id); +struct darwin_iokit_interface { + uint32_t min_os_version; + uint32_t version; + CFUUIDRef interface_id; +}; + +static const struct darwin_iokit_interface *get_interface_interface(void) { + const struct darwin_iokit_interface interfaces[] = { +#if defined(kIOUSBInterfaceInterfaceID800) + { + .min_os_version = 101200, + .version = 800, + .interface_id = kIOUSBInterfaceInterfaceID800, + }, +#endif +#if defined(kIOUSBInterfaceInterfaceID700) + { + .min_os_version = 101000, + .version = 700, + .interface_id = kIOUSBInterfaceInterfaceID700, + }, +#endif +#if defined(kIOUSBInterfaceInterfaceID650) + { + .min_os_version = 100900, + .version = 650, + .interface_id = kIOUSBInterfaceInterfaceID650 + }, +#endif +#if defined(kIOUSBInterfaceInterfaceID550) + { + .min_os_version = 100803, + .version = 550, + .interface_id = kIOUSBInterfaceInterfaceID550, + }, +#endif +#if defined(kIOUSBInterfaceInterfaceID245) + { + .min_os_version = 100407, + .version = 245, + .interface_id = kIOUSBInterfaceInterfaceID245, + }, +#endif + { + .min_os_version = 100000, + .version = 220, + .interface_id = kIOUSBInterfaceInterfaceID220, + }, + { + .version = 0, + }, + }; + static struct darwin_iokit_interface cached_interface = {.version = 0}; + if (libusb_testonly_clear_running_version_cache) { + memset (&cached_interface, 0, sizeof (cached_interface)); + } + if (0 == cached_interface.version) { + uint32_t os_version = get_running_version(); + for (int i = 0 ; interfaces[i].version > 0 ; ++i) { + if (os_version >= interfaces[i].min_os_version && cached_interface.min_os_version < interfaces[i].min_os_version) { + cached_interface = interfaces[i]; + } + } + + libusb_testonly_using_running_interface_version = cached_interface.version; + } + + return &cached_interface; +} + +static CFUUIDRef get_interface_interface_id(void) { + return get_interface_interface()->interface_id; +} + +static int get_interface_interface_version(void) { + return get_interface_interface()->version; +} + +static const struct darwin_iokit_interface *get_device_interface(void) { + struct darwin_iokit_interface interfaces[] = { +#if defined(kIOUSBDeviceInterfaceID650) + { + .min_os_version = 100900, + .version = 650, + .interface_id = kIOUSBDeviceInterfaceID650, + }, +#endif +#if defined(kIOUSBDeviceInterfaceID500) + { + .min_os_version = 100703, + .version = 500, + .interface_id = kIOUSBDeviceInterfaceID500, + }, +#endif +#if defined(kIOUSBDeviceInterfaceID320) + { + .min_os_version = 100504, + .version = 320, + .interface_id = kIOUSBDeviceInterfaceID320, + }, +#endif +#if defined(kIOUSBDeviceInterfaceID300) + { + .min_os_version = 100500, + .version = 300, + .interface_id = kIOUSBDeviceInterfaceID300, + }, +#endif +#if defined(kIOUSBDeviceInterfaceID245) + { + .min_os_version = 100407, + .version = 245, + .interface_id = kIOUSBDeviceInterfaceID245, + }, +#endif + { + .min_os_version = 100000, + .version = 197, + .interface_id = kIOUSBDeviceInterfaceID197, + }, + { + .version = 0, + }, + }; + static struct darwin_iokit_interface cached_interface = {.version = 0}; + if (libusb_testonly_clear_running_version_cache) { + memset (&cached_interface, 0, sizeof (cached_interface)); + } + if (0 == cached_interface.version) { + uint32_t os_version = get_running_version(); + for (int i = 0 ; interfaces[i].version > 0 ; ++i) { + if (os_version >= interfaces[i].min_os_version && cached_interface.min_os_version < interfaces[i].min_os_version) { + cached_interface = interfaces[i]; + } + } + libusb_testonly_using_running_device_version = cached_interface.version; + } + + return &cached_interface; +} + +static CFUUIDRef get_device_interface_id(void) { + return get_device_interface()->interface_id; +} + +static int get_device_interface_version(void) { + return get_device_interface()->version; +} + +struct darwin_pipe_properties { + uint8_t number; + uint8_t direction; + uint8_t transfer_type; + uint16_t max_packet_size; + uint8_t interval; +}; +typedef struct darwin_pipe_properties darwin_pipe_properties_t; + +static IOReturn darwin_get_pipe_properties(struct darwin_interface *cInterface, uint8_t pipe, darwin_pipe_properties_t *out) { + IOReturn kresult; + +#if (MAX_INTERFACE_VERSION >= 550) + if (get_interface_interface_version() >= 550) { + IOUSBEndpointProperties pipe_properties = {.bVersion = kUSBEndpointPropertiesVersion3}; + kresult = (*IOINTERFACE_V(cInterface, 550))->GetPipePropertiesV3 (IOINTERFACE(cInterface), pipe, &pipe_properties); + if (kIOReturnSuccess == kresult) { + out->number = pipe_properties.bEndpointNumber; + out->direction = pipe_properties.bDirection; + out->transfer_type = pipe_properties.bTransferType; + out->max_packet_size = pipe_properties.wMaxPacketSize; + out->interval = pipe_properties.bInterval; + } + return kresult; + } +#endif + return (*IOINTERFACE(cInterface))->GetPipeProperties(IOINTERFACE(cInterface), pipe, &out->direction, + &out->number, &out->transfer_type, &out->max_packet_size, + &out->interval); +} + #if defined(ENABLE_LOGGING) static const char *darwin_error_str (IOReturn result) { static char string_buffer[50]; @@ -172,7 +355,72 @@ static enum libusb_error darwin_to_libusb (IOReturn result) { } } -/* this function must be called with the darwin_cached_devices_lock held */ +uint32_t get_running_version(void) { + if (libusb_testonly_fake_running_version > 0) { + return libusb_testonly_fake_running_version; + } + + int ret; +#if !defined(TARGET_OS_OSX) || TARGET_OS_OSX == 1 + char os_version_string[64] = {'\0'};; + size_t os_version_string_len = sizeof(os_version_string) - 1; + + /* newer versions of macOS provide a sysctl for the OS version but this is not useful for iOS without + * code detecting this is iOS and a mapping from iOS -> macOS version. it is still useful to have since + * it provides the exact macOS version instead of the approximate version (as below). */ + ret = sysctlbyname("kern.osproductversion", os_version_string, &os_version_string_len, NULL, 0); + if (ret == 0) { + int major = 10, minor = 0, patch = 0; + ret = sscanf(os_version_string, "%i.%i.%i", &major, &minor, &patch); + if (ret < 2) { + usbi_err (NULL, "could not determine the running OS version, assuming 10.0, kern.osproductversion=%s", os_version_string); + return 100000; + } + return (major * 10000) + (minor * 100) + patch; + } +#endif + + char os_release_string[64] = {'\0'}; + size_t os_release_string_len = sizeof(os_release_string) - 1; + /* if the version can not be detected libusb assumes 10.0 so ignore any error here */ + ret = sysctlbyname("kern.osrelease", os_release_string, &os_release_string_len, NULL, 0); + if (ret != 0) { + usbi_err (NULL, "could not read kern.osrelease, errno=", errno); + return 100000; + } + + int darwin_major = 1, darwin_minor = 0; + ret = sscanf(os_release_string, "%i.%i", &darwin_major, &darwin_minor); + if (ret < 1) { + usbi_err (NULL, "could not determine the running Darwin version, assuming 1.3 (OS X 10.0), kern.osrelease=%s", os_release_string); + return 100000; + } + + int major = 10, minor = 0, patch = 0; + + if (1 == darwin_major && darwin_minor < 4) { + /* 10.0.x */ + } else if (darwin_major < 6) { + /* assume 10.1 for anything in this range */ + minor = 1; + } else if (darwin_major < 20) { + /* from macOS 10.2 through 10.15 the minor version can be calculated from the darwin_major by subtracting 4 and + * the patch level almost always matches darwin_minor. when the darwin_minor does not match the OS X patch level + * it is usually because Apple did not change it in a particular point release. when darwin_minor is changed it + * always matches the OS X/macOS patch level. */ + minor = darwin_major - 4; + patch = darwin_minor; + } else { + /* unlikely to be used as kern.osproductversion is available from 10.10 on */ + major = darwin_major - 9; + minor = darwin_minor; + /* ignore the patch level in this range */ + } + + return (major * 10000) + (minor * 100) + patch; +} + +/* this function must be called with the darwin_cached_devices_mutex held */ static void darwin_deref_cached_device(struct darwin_cached_device *cached_dev) { cached_dev->refcount--; /* free the device and remove it from the cache */ @@ -180,7 +428,7 @@ static void darwin_deref_cached_device(struct darwin_cached_device *cached_dev) list_del(&cached_dev->list); if (cached_dev->device) { - (*(cached_dev->device))->Release(cached_dev->device); + (*cached_dev->device)->Release(cached_dev->device); cached_dev->device = NULL; } IOObjectRelease (cached_dev->service); @@ -300,12 +548,12 @@ static bool get_ioregistry_value_data (io_service_t service, CFStringRef propert return success; } -static usb_device_t **darwin_device_from_service (struct libusb_context *ctx, io_service_t service) +static int darwin_device_from_service (struct libusb_context *ctx, io_service_t service, usb_device_t* device) { io_cf_plugin_ref_t *plugInInterface = NULL; - usb_device_t **device; IOReturn kresult; SInt32 score; + const int max_retries = 5; /* The IOCreatePlugInInterfaceForService function might consistently return @@ -325,17 +573,21 @@ static usb_device_t **darwin_device_from_service (struct libusb_context *ctx, io nanosleep(&(struct timespec){.tv_sec = 0, .tv_nsec = 1000}, NULL); } - if (kIOReturnSuccess != kresult || !plugInInterface) { + if (kIOReturnSuccess != kresult) { usbi_dbg (ctx, "could not set up plugin for service: %s", darwin_error_str (kresult)); - return NULL; + return darwin_to_libusb(kresult); + } + if (!plugInInterface) { + usbi_dbg (ctx, "could not set up plugin for service"); + return LIBUSB_ERROR_OTHER; } - (void)(*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(DeviceInterfaceID), - (LPVOID)&device); + (void)(*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(get_device_interface_id()), + (LPVOID)device); /* Use release instead of IODestroyPlugInInterface to avoid stopping IOServices associated with this device */ (*plugInInterface)->Release (plugInInterface); - return device; + return LIBUSB_SUCCESS; } static void darwin_devices_attached (void *ptr, io_iterator_t add_devices) { @@ -377,8 +629,6 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { struct darwin_cached_device *old_device; io_service_t device; - UInt64 session, locationID; - int ret; usbi_mutex_lock(&active_contexts_lock); @@ -386,7 +636,9 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { bool is_reenumerating = false; /* get the location from the i/o registry */ - ret = get_ioregistry_value_number (device, CFSTR("sessionID"), kCFNumberSInt64Type, &session); + UInt64 session = 0; + bool ret = get_ioregistry_value_number (device, CFSTR("sessionID"), kCFNumberSInt64Type, &session); + UInt32 locationID = 0; (void) get_ioregistry_value_number (device, CFSTR("locationID"), kCFNumberSInt32Type, &locationID); IOObjectRelease (device); if (!ret) @@ -394,18 +646,18 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { /* we need to match darwin_ref_cached_device call made in darwin_get_cached_device function otherwise no cached device will ever get freed */ - usbi_mutex_lock(&darwin_cached_devices_lock); + usbi_mutex_lock(&darwin_cached_devices_mutex); list_for_each_entry(old_device, &darwin_cached_devices, list, struct darwin_cached_device) { if (old_device->session == session) { if (old_device->in_reenumerate) { /* device is re-enumerating. do not dereference the device at this time. libusb_reset_device() * will deref if needed. */ - usbi_dbg (NULL, "detected device detached due to re-enumeration. sessionID: 0x%" PRIx64 ", locationID: 0x%" PRIx64, - session, locationID); + usbi_dbg (NULL, "detected device detached due to re-enumeration. sessionID: 0x%" PRIx64 + ", locationID: 0x%" PRIx32, session, locationID); /* the device object is no longer usable so go ahead and release it */ if (old_device->device) { - (*(old_device->device))->Release(old_device->device); + (*old_device->device)->Release(old_device->device); old_device->device = NULL; } @@ -418,7 +670,7 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { } } - usbi_mutex_unlock(&darwin_cached_devices_lock); + usbi_mutex_unlock(&darwin_cached_devices_mutex); if (is_reenumerating) { continue; } @@ -466,8 +718,8 @@ static void darwin_fail_startup(void) { } static void *darwin_event_thread_main (void *arg0) { + UNUSED(arg0); IOReturn kresult; - struct libusb_context *ctx = (struct libusb_context *)arg0; CFRunLoopRef runloop; CFRunLoopSourceRef libusb_shutdown_cfsource; CFRunLoopSourceContext libusb_shutdown_cfsourcectx; @@ -495,7 +747,7 @@ static void *darwin_event_thread_main (void *arg0) { io_iterator_t libusb_add_device_iterator; /* ctx must only be used for logging during thread startup */ - usbi_dbg (ctx, "creating hotplug event source"); + usbi_dbg (NULL, "creating hotplug event source"); runloop = CFRunLoopGetCurrent (); CFRetain (runloop); @@ -519,7 +771,7 @@ static void *darwin_event_thread_main (void *arg0) { NULL, &libusb_rem_device_iterator); if (kresult != kIOReturnSuccess) { - usbi_err (ctx, "could not add hotplug event source: %s", darwin_error_str (kresult)); + usbi_err (NULL, "could not add hotplug event source: %s", darwin_error_str (kresult)); CFRelease (libusb_shutdown_cfsource); CFRelease (runloop); darwin_fail_startup (); @@ -532,7 +784,7 @@ static void *darwin_event_thread_main (void *arg0) { NULL, &libusb_add_device_iterator); if (kresult != kIOReturnSuccess) { - usbi_err (ctx, "could not add hotplug event source: %s", darwin_error_str (kresult)); + usbi_err (NULL, "could not add hotplug event source: %s", darwin_error_str (kresult)); CFRelease (libusb_shutdown_cfsource); CFRelease (runloop); darwin_fail_startup (); @@ -542,7 +794,7 @@ static void *darwin_event_thread_main (void *arg0) { darwin_clear_iterator (libusb_rem_device_iterator); darwin_clear_iterator (libusb_add_device_iterator); - usbi_dbg (ctx, "darwin event thread ready to receive events"); + usbi_dbg (NULL, "darwin event thread ready to receive events"); /* signal the main thread that the hotplug runloop has been created. */ pthread_mutex_lock (&libusb_darwin_at_mutex); @@ -582,73 +834,82 @@ static void *darwin_event_thread_main (void *arg0) { pthread_exit (NULL); } -/* cleanup function to destroy cached devices */ +/* cleanup function to destroy cached devices. must be called with a lock on darwin_cached_devices_mutex */ static void darwin_cleanup_devices(void) { struct darwin_cached_device *dev, *next; list_for_each_entry_safe(dev, next, &darwin_cached_devices, list, struct darwin_cached_device) { + if (dev->refcount > 1) { + usbi_err(NULL, "device still referenced at libusb_exit"); + } darwin_deref_cached_device(dev); } } -static int darwin_init(struct libusb_context *ctx) { - bool first_init; - int rc; +/* must be called with a lock on darwin_cached_devices_mutex */ +static int darwin_first_time_init(void) { + if (NULL == darwin_cached_devices.next) { + list_init (&darwin_cached_devices); + } - first_init = (1 == ++init_count); + /* cache the interface versions that will be used. as a sanity check verify + * that the interface versions are non-zero. */ + const struct darwin_iokit_interface *interface_interface = get_interface_interface(); + const struct darwin_iokit_interface *device_interface = get_device_interface(); + if (0 == interface_interface->version || 0 == device_interface->version) { + usbi_err(NULL, "could not determine the device or interface interface to use with this version " + "of macOS (or MacOS X), current_running_version = %" PRIu32, get_running_version()); + return LIBUSB_ERROR_OTHER; + } - do { - if (first_init) { - if (NULL == darwin_cached_devices.next) { - list_init (&darwin_cached_devices); - } - assert(list_empty(&darwin_cached_devices)); -#if !defined(HAVE_CLOCK_GETTIME) - /* create the clocks that will be used if clock_gettime() is not available */ - host_name_port_t host_self; - - host_self = mach_host_self(); - host_get_clock_service(host_self, CALENDAR_CLOCK, &clock_realtime); - host_get_clock_service(host_self, SYSTEM_CLOCK, &clock_monotonic); - mach_port_deallocate(mach_task_self(), host_self); -#endif - } + if (!list_empty(&darwin_cached_devices)) { + usbi_err(NULL, "libusb_device reference not released on last exit. will not continue"); + return LIBUSB_ERROR_OTHER; + } - rc = darwin_scan_devices (ctx); - if (LIBUSB_SUCCESS != rc) - break; + int rc = pthread_create (&libusb_darwin_at, NULL, darwin_event_thread_main, NULL); + if (0 != rc) { + usbi_err (NULL, "could not create event thread, error %d", rc); + return LIBUSB_ERROR_OTHER; + } - if (first_init) { - rc = pthread_create (&libusb_darwin_at, NULL, darwin_event_thread_main, ctx); - if (0 != rc) { - usbi_err (ctx, "could not create event thread, error %d", rc); - rc = LIBUSB_ERROR_OTHER; - break; - } + pthread_mutex_lock (&libusb_darwin_at_mutex); + libusb_darwin_at_started = true; + while (NULL == libusb_darwin_acfl) { + pthread_cond_wait (&libusb_darwin_at_cond, &libusb_darwin_at_mutex); + } - pthread_mutex_lock (&libusb_darwin_at_mutex); - while (!libusb_darwin_acfl) - pthread_cond_wait (&libusb_darwin_at_cond, &libusb_darwin_at_mutex); - if (libusb_darwin_acfl == LIBUSB_DARWIN_STARTUP_FAILURE) { - libusb_darwin_acfl = NULL; - rc = LIBUSB_ERROR_OTHER; - } - pthread_mutex_unlock (&libusb_darwin_at_mutex); + if (libusb_darwin_acfl == LIBUSB_DARWIN_STARTUP_FAILURE) { + libusb_darwin_acfl = NULL; + rc = LIBUSB_ERROR_OTHER; + } + pthread_mutex_unlock (&libusb_darwin_at_mutex); - if (0 != rc) - pthread_join (libusb_darwin_at, NULL); + return rc; +} + +static int darwin_init_context(struct libusb_context *ctx) { + usbi_mutex_lock(&darwin_cached_devices_mutex); + + bool first_init = (1 == ++init_count); + + if (first_init) { + int rc = darwin_first_time_init(); + if (LIBUSB_SUCCESS != rc) { + usbi_mutex_unlock(&darwin_cached_devices_mutex); + return rc; } - } while (0); + } + usbi_mutex_unlock(&darwin_cached_devices_mutex); + + return darwin_scan_devices (ctx); +} +static int darwin_init(struct libusb_context *ctx) { + int rc = darwin_init_context(ctx); if (LIBUSB_SUCCESS != rc) { - if (first_init) { - darwin_cleanup_devices (); -#if !defined(HAVE_CLOCK_GETTIME) - mach_port_deallocate(mach_task_self(), clock_realtime); - mach_port_deallocate(mach_task_self(), clock_monotonic); -#endif - } - --init_count; + /* clean up any allocated resources */ + darwin_exit(ctx); } return rc; @@ -657,23 +918,26 @@ static int darwin_init(struct libusb_context *ctx) { static void darwin_exit (struct libusb_context *ctx) { UNUSED(ctx); + usbi_mutex_lock(&darwin_cached_devices_mutex); if (0 == --init_count) { /* stop the event runloop and wait for the thread to terminate. */ pthread_mutex_lock (&libusb_darwin_at_mutex); - CFRunLoopSourceSignal (libusb_darwin_acfls); - CFRunLoopWakeUp (libusb_darwin_acfl); - while (libusb_darwin_acfl) - pthread_cond_wait (&libusb_darwin_at_cond, &libusb_darwin_at_mutex); + if (NULL != libusb_darwin_acfls) { + CFRunLoopSourceSignal (libusb_darwin_acfls); + CFRunLoopWakeUp (libusb_darwin_acfl); + while (libusb_darwin_acfl) + pthread_cond_wait (&libusb_darwin_at_cond, &libusb_darwin_at_mutex); + } + + if (libusb_darwin_at_started) { + pthread_join (libusb_darwin_at, NULL); + libusb_darwin_at_started = false; + } pthread_mutex_unlock (&libusb_darwin_at_mutex); - pthread_join (libusb_darwin_at, NULL); darwin_cleanup_devices (); - -#if !defined(HAVE_CLOCK_GETTIME) - mach_port_deallocate(mach_task_self(), clock_realtime); - mach_port_deallocate(mach_task_self(), clock_monotonic); -#endif } + usbi_mutex_unlock(&darwin_cached_devices_mutex); } static int get_configuration_index (struct libusb_device *dev, UInt8 config_value) { @@ -683,12 +947,12 @@ static int get_configuration_index (struct libusb_device *dev, UInt8 config_valu IOReturn kresult; /* is there a simpler way to determine the index? */ - kresult = (*(priv->device))->GetNumberOfConfigurations (priv->device, &numConfig); + kresult = (*priv->device)->GetNumberOfConfigurations (priv->device, &numConfig); if (kresult != kIOReturnSuccess) return darwin_to_libusb (kresult); for (i = 0 ; i < numConfig ; i++) { - (*(priv->device))->GetConfigurationDescriptorPtr (priv->device, i, &desc); + (*priv->device)->GetConfigurationDescriptorPtr (priv->device, i, &desc); if (desc->bConfigurationValue == config_value) return i; @@ -740,7 +1004,7 @@ static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t confi /* check whether the os has configured the device */ static enum libusb_error darwin_check_configuration (struct libusb_context *ctx, struct darwin_cached_device *dev) { - usb_device_t **darwin_device = dev->device; + usb_device_t darwin_device = dev->device; IOUSBConfigurationDescriptorPtr configDesc; IOUSBFindInterfaceRequest request; @@ -776,7 +1040,7 @@ static enum libusb_error darwin_check_configuration (struct libusb_context *ctx, request.bInterfaceProtocol = kIOUSBFindInterfaceDontCare; request.bAlternateSetting = kIOUSBFindInterfaceDontCare; - kresult = (*(darwin_device))->CreateInterfaceIterator(darwin_device, &request, &interface_iterator); + kresult = (*darwin_device)->CreateInterfaceIterator(darwin_device, &request, &interface_iterator); if (kresult != kIOReturnSuccess) return darwin_to_libusb (kresult); @@ -805,7 +1069,7 @@ static enum libusb_error darwin_check_configuration (struct libusb_context *ctx, return LIBUSB_SUCCESS; } -static IOReturn darwin_request_descriptor (usb_device_t **device, UInt8 desc, UInt8 desc_index, void *buffer, size_t buffer_size) { +static IOReturn darwin_request_descriptor (usb_device_t device, UInt8 desc, UInt8 desc_index, void *buffer, size_t buffer_size) { IOUSBDevRequestTO req; assert(buffer_size <= UINT16_MAX); @@ -826,7 +1090,7 @@ static IOReturn darwin_request_descriptor (usb_device_t **device, UInt8 desc, UI } static enum libusb_error darwin_cache_device_descriptor (struct libusb_context *ctx, struct darwin_cached_device *dev) { - usb_device_t **device = dev->device; + usb_device_t device = dev->device; int retries = 1; long delay = 30000; // microseconds int unsuspended = 0, try_unsuspend = 1, try_reconfigure = 1; @@ -877,15 +1141,17 @@ static enum libusb_error darwin_cache_device_descriptor (struct libusb_context * if (kIOReturnSuccess != ret && is_open && try_unsuspend) { /* device may be suspended. unsuspend it and try again */ -#if DeviceVersion >= 320 - UInt32 info = 0; +#if MAX_DEVICE_VERSION >= 320 + if (get_device_interface_version() >= 320) { + UInt32 info = 0; - /* IOUSBFamily 320+ provides a way to detect device suspension but earlier versions do not */ - (void)(*device)->GetUSBDeviceInformation (device, &info); + /* IOUSBFamily 320+ provides a way to detect device suspension but earlier versions do not */ + (void)(*IODEVICE_V(device, 320))->GetUSBDeviceInformation (device, &info); - /* note that the device was suspended */ - if (info & (1U << kUSBInformationDeviceIsSuspendedBit) || 0 == info) - try_unsuspend = 1; + /* note that the device was suspended */ + if (info & (1U << kUSBInformationDeviceIsSuspendedBit) || 0 == info) + try_unsuspend = 1; + } #endif if (try_unsuspend) { @@ -998,7 +1264,7 @@ static enum libusb_error darwin_get_cached_device(struct libusb_context *ctx, io UInt64 sessionID = 0, parent_sessionID = 0; UInt32 locationID = 0; enum libusb_error ret = LIBUSB_SUCCESS; - usb_device_t **device; + usb_device_t device; UInt8 port = 0; /* assuming sessionID != 0 normally (never seen it be 0) */ @@ -1018,10 +1284,10 @@ static enum libusb_error darwin_get_cached_device(struct libusb_context *ctx, io usbi_dbg(ctx, "parent sessionID: 0x%" PRIx64, parent_sessionID); } - usbi_mutex_lock(&darwin_cached_devices_lock); + usbi_mutex_lock(&darwin_cached_devices_mutex); do { list_for_each_entry(new_device, &darwin_cached_devices, list, struct darwin_cached_device) { - usbi_dbg(ctx, "matching sessionID/locationID 0x%" PRIx64 "/0x%x against cached device with sessionID/locationID 0x%" PRIx64 "/0x%x", + usbi_dbg(ctx, "matching sessionID/locationID 0x%" PRIx64 "/0x%" PRIx32 " against cached device with sessionID/locationID 0x%" PRIx64 "/0x%" PRIx32, sessionID, locationID, new_device->session, new_device->location); if (new_device->location == locationID && new_device->in_reenumerate) { usbi_dbg (ctx, "found cached device with matching location that is being re-enumerated"); @@ -1041,9 +1307,8 @@ static enum libusb_error darwin_get_cached_device(struct libusb_context *ctx, io usbi_dbg(ctx, "caching new device with sessionID 0x%" PRIx64, sessionID); - device = darwin_device_from_service (ctx, service); - if (!device) { - ret = LIBUSB_ERROR_NO_DEVICE; + ret = darwin_device_from_service (ctx, service, &device); + if (LIBUSB_SUCCESS != ret) { break; } @@ -1094,7 +1359,7 @@ static enum libusb_error darwin_get_cached_device(struct libusb_context *ctx, io } } while (0); - usbi_mutex_unlock(&darwin_cached_devices_lock); + usbi_mutex_unlock(&darwin_cached_devices_mutex); return ret; } @@ -1158,7 +1423,7 @@ static enum libusb_error process_new_device (struct libusb_context *ctx, struct dev->parent_dev = usbi_get_device_by_session_id (ctx, (unsigned long) cached_device->parent_session); } - (*(priv->dev->device))->GetDeviceSpeed (priv->dev->device, &devSpeed); + (*priv->dev->device)->GetDeviceSpeed (priv->dev->device, &devSpeed); switch (devSpeed) { case kUSBDeviceSpeedLow: dev->speed = LIBUSB_SPEED_LOW; break; @@ -1227,7 +1492,7 @@ static int darwin_open (struct libusb_device_handle *dev_handle) { if (0 == dpriv->open_count) { /* try to open the device */ - kresult = (*(dpriv->device))->USBDeviceOpenSeize (dpriv->device); + kresult = (*dpriv->device)->USBDeviceOpenSeize (dpriv->device); if (kresult != kIOReturnSuccess) { usbi_warn (HANDLE_CTX (dev_handle), "USBDeviceOpen: %s", darwin_error_str(kresult)); @@ -1242,12 +1507,13 @@ static int darwin_open (struct libusb_device_handle *dev_handle) { } /* create async event source */ - kresult = (*(dpriv->device))->CreateDeviceAsyncEventSource (dpriv->device, &priv->cfSource); + kresult = (*dpriv->device)->CreateDeviceAsyncEventSource (dpriv->device, + &priv->cfSource); if (kresult != kIOReturnSuccess) { usbi_err (HANDLE_CTX (dev_handle), "CreateDeviceAsyncEventSource: %s", darwin_error_str(kresult)); if (priv->is_open) { - (*(dpriv->device))->USBDeviceClose (dpriv->device); + (*dpriv->device)->USBDeviceClose (dpriv->device); } priv->is_open = false; @@ -1303,7 +1569,7 @@ static void darwin_close (struct libusb_device_handle *dev_handle) { if (priv->is_open) { /* close the device */ - kresult = (*(dpriv->device))->USBDeviceClose(dpriv->device); + kresult = (*dpriv->device)->USBDeviceClose(dpriv->device); if (kresult != kIOReturnSuccess) { /* Log the fact that we had a problem closing the file, however failing a * close isn't really an error, so return success anyway */ @@ -1335,7 +1601,7 @@ static enum libusb_error darwin_set_configuration(struct libusb_device_handle *d if (dev_handle->claimed_interfaces & (1U << i)) darwin_release_interface (dev_handle, i); - kresult = (*(dpriv->device))->SetConfiguration (dpriv->device, (UInt8)config); + kresult = (*dpriv->device)->SetConfiguration (dpriv->device, (UInt8)config); if (kresult != kIOReturnSuccess) return darwin_to_libusb (kresult); @@ -1349,7 +1615,7 @@ static enum libusb_error darwin_set_configuration(struct libusb_device_handle *d return LIBUSB_SUCCESS; } -static IOReturn darwin_get_interface (usb_device_t **darwin_device, uint8_t ifc, io_service_t *usbInterfacep) { +static IOReturn darwin_get_interface (usb_device_t darwin_device, uint8_t ifc, io_service_t *usbInterfacep) { IOUSBFindInterfaceRequest request; IOReturn kresult; io_iterator_t interface_iterator; @@ -1364,7 +1630,7 @@ static IOReturn darwin_get_interface (usb_device_t **darwin_device, uint8_t ifc, request.bInterfaceProtocol = kIOUSBFindInterfaceDontCare; request.bAlternateSetting = kIOUSBFindInterfaceDontCare; - kresult = (*(darwin_device))->CreateInterfaceIterator(darwin_device, &request, &interface_iterator); + kresult = (*darwin_device)->CreateInterfaceIterator(darwin_device, &request, &interface_iterator); if (kresult != kIOReturnSuccess) return kresult; @@ -1386,29 +1652,34 @@ static IOReturn darwin_get_interface (usb_device_t **darwin_device, uint8_t ifc, return kIOReturnSuccess; } +static const struct libusb_interface_descriptor *get_interface_descriptor_by_number(struct libusb_device_handle *dev_handle, struct libusb_config_descriptor *conf_desc, int iface, uint8_t altsetting) +{ + int i; + + for (i = 0; i < conf_desc->bNumInterfaces; i++) { + if (altsetting < conf_desc->interface[i].num_altsetting && conf_desc->interface[i].altsetting[altsetting].bInterfaceNumber == iface) { + return &conf_desc->interface[i].altsetting[altsetting]; + } + } + + usbi_err(HANDLE_CTX(dev_handle), "interface %d with altsetting %d not found for device", iface, (int)altsetting); + return NULL; +} + static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle, uint8_t iface) { struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle); /* current interface */ struct darwin_interface *cInterface = &priv->interfaces[iface]; -#if InterfaceVersion >= 550 - IOUSBEndpointProperties pipeProperties = {.bVersion = kUSBEndpointPropertiesVersion3}; -#else - UInt8 dont_care1, dont_care3; - UInt16 dont_care2; -#endif - IOReturn kresult; - - UInt8 numep, direction, number; + uint8_t numep; int rc; struct libusb_context *ctx = HANDLE_CTX (dev_handle); - usbi_dbg (ctx, "building table of endpoints."); /* retrieve the total number of endpoints on this interface */ - kresult = (*(cInterface->interface))->GetNumEndpoints(cInterface->interface, &numep); + kresult = (*IOINTERFACE(cInterface))->GetNumEndpoints(IOINTERFACE(cInterface), &numep); if (kresult != kIOReturnSuccess) { usbi_err (ctx, "can't get number of endpoints for interface: %s", darwin_error_str(kresult)); return darwin_to_libusb (kresult); @@ -1416,21 +1687,16 @@ static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle, /* iterate through pipe references */ for (UInt8 i = 1 ; i <= numep ; i++) { -#if InterfaceVersion >= 550 - kresult = (*(cInterface->interface))->GetPipePropertiesV3 (cInterface->interface, i, &pipeProperties); - number = pipeProperties.bEndpointNumber; - direction = pipeProperties.bDirection; -#else - kresult = (*(cInterface->interface))->GetPipeProperties(cInterface->interface, i, &direction, &number, &dont_care1, - &dont_care2, &dont_care3); -#endif + darwin_pipe_properties_t pipe_properties; + kresult = darwin_get_pipe_properties(cInterface, i, &pipe_properties); if (kresult != kIOReturnSuccess) { /* probably a buggy device. try to get the endpoint address from the descriptors */ struct libusb_config_descriptor *config; + const struct libusb_interface_descriptor *if_desc; const struct libusb_endpoint_descriptor *endpoint_desc; UInt8 alt_setting; - kresult = (*(cInterface->interface))->GetAlternateSetting (cInterface->interface, &alt_setting); + kresult = (*IOINTERFACE(cInterface))->GetAlternateSetting (IOINTERFACE(cInterface), &alt_setting); if (kresult != kIOReturnSuccess) { usbi_err (HANDLE_CTX (dev_handle), "can't get alternate setting for interface"); return darwin_to_libusb (kresult); @@ -1441,15 +1707,19 @@ static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle, return rc; } - if (iface >= config->bNumInterfaces) { - usbi_err (HANDLE_CTX (dev_handle), "interface %d out of range for device", iface); + if_desc = get_interface_descriptor_by_number (dev_handle, config, iface, alt_setting); + if (if_desc == NULL) { + libusb_free_config_descriptor (config); return LIBUSB_ERROR_NOT_FOUND; } - endpoint_desc = config->interface[iface].altsetting[alt_setting].endpoint + i - 1; + + endpoint_desc = if_desc->endpoint + i - 1; cInterface->endpoint_addrs[i - 1] = endpoint_desc->bEndpointAddress; + libusb_free_config_descriptor (config); } else { - cInterface->endpoint_addrs[i - 1] = (UInt8)(((kUSBIn == direction) << kUSBRqDirnShift) | (number & LIBUSB_ENDPOINT_ADDRESS_MASK)); + cInterface->endpoint_addrs[i - 1] = (UInt8)(((kUSBIn == pipe_properties.direction) << kUSBRqDirnShift) | + (pipe_properties.number & LIBUSB_ENDPOINT_ADDRESS_MASK)); } usbi_dbg (ctx, "interface: %i pipe %i: dir: %i number: %i", iface, i, cInterface->endpoint_addrs[i - 1] >> kUSBRqDirnShift, @@ -1521,18 +1791,22 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, uint8 /* Do the actual claim */ kresult = (*plugInInterface)->QueryInterface(plugInInterface, - CFUUIDGetUUIDBytes(InterfaceInterfaceID), - (LPVOID)&cInterface->interface); + CFUUIDGetUUIDBytes(get_interface_interface_id()), + (LPVOID)&IOINTERFACE(cInterface)); /* We no longer need the intermediate plug-in */ /* Use release instead of IODestroyPlugInInterface to avoid stopping IOServices associated with this device */ (*plugInInterface)->Release (plugInInterface); - if (kresult != kIOReturnSuccess || !cInterface->interface) { + if (kresult != kIOReturnSuccess) { usbi_err (ctx, "QueryInterface: %s", darwin_error_str(kresult)); return darwin_to_libusb (kresult); } + if (!IOINTERFACE(cInterface)) { + usbi_err (ctx, "QueryInterface: returned null interface"); + return LIBUSB_ERROR_OTHER; + } /* claim the interface */ - kresult = (*(cInterface->interface))->USBInterfaceOpen(cInterface->interface); + kresult = (*IOINTERFACE(cInterface))->USBInterfaceOpen(IOINTERFACE(cInterface)); if (kresult != kIOReturnSuccess) { usbi_info (ctx, "USBInterfaceOpen: %s", darwin_error_str(kresult)); return darwin_to_libusb (kresult); @@ -1550,7 +1824,7 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, uint8 cInterface->cfSource = NULL; /* create async event source */ - kresult = (*(cInterface->interface))->CreateInterfaceAsyncEventSource (cInterface->interface, &cInterface->cfSource); + kresult = (*IOINTERFACE(cInterface))->CreateInterfaceAsyncEventSource (IOINTERFACE(cInterface), &cInterface->cfSource); if (kresult != kIOReturnSuccess) { usbi_err (ctx, "could not create async event source"); @@ -1576,8 +1850,9 @@ static int darwin_release_interface(struct libusb_device_handle *dev_handle, uin struct darwin_interface *cInterface = &priv->interfaces[iface]; /* Check to see if an interface is open */ - if (!cInterface->interface) + if (!IOINTERFACE(cInterface)) { return LIBUSB_SUCCESS; + } /* clean up endpoint data */ cInterface->num_endpoints = 0; @@ -1589,15 +1864,15 @@ static int darwin_release_interface(struct libusb_device_handle *dev_handle, uin cInterface->cfSource = NULL; } - kresult = (*(cInterface->interface))->USBInterfaceClose(cInterface->interface); + kresult = (*IOINTERFACE(cInterface))->USBInterfaceClose(IOINTERFACE(cInterface)); if (kresult != kIOReturnSuccess) usbi_warn (HANDLE_CTX (dev_handle), "USBInterfaceClose: %s", darwin_error_str(kresult)); - kresult = (*(cInterface->interface))->Release(cInterface->interface); + kresult = (*IOINTERFACE(cInterface))->Release(IOINTERFACE(cInterface)); if (kresult != kIOReturnSuccess) usbi_warn (HANDLE_CTX (dev_handle), "Release: %s", darwin_error_str(kresult)); - cInterface->interface = (usb_interface_t **) IO_OBJECT_NULL; + IOINTERFACE(cInterface) = NULL; return darwin_to_libusb (kresult); } @@ -1607,7 +1882,7 @@ static int check_alt_setting_and_clear_halt(struct libusb_device_handle *dev_han IOReturn kresult; uint8_t current_alt_setting; - kresult = (*(cInterface->interface))->GetAlternateSetting (cInterface->interface, ¤t_alt_setting); + kresult = (*IOINTERFACE(cInterface))->GetAlternateSetting (IOINTERFACE(cInterface), ¤t_alt_setting); if (kresult == kIOReturnSuccess && altsetting != current_alt_setting) { return LIBUSB_ERROR_PIPE; } @@ -1634,10 +1909,11 @@ static int darwin_set_interface_altsetting(struct libusb_device_handle *dev_hand /* current interface */ struct darwin_interface *cInterface = &priv->interfaces[iface]; - if (!cInterface->interface) + if (!IOINTERFACE(cInterface)) { return LIBUSB_ERROR_NO_DEVICE; + } - kresult = (*(cInterface->interface))->SetAlternateInterface (cInterface->interface, altsetting); + kresult = (*IOINTERFACE(cInterface))->SetAlternateInterface (IOINTERFACE(cInterface), altsetting); if (kresult == kIOReturnSuccess) { /* update the list of endpoints */ ret = get_endpoints (dev_handle, iface); @@ -1689,7 +1965,7 @@ static int darwin_clear_halt(struct libusb_device_handle *dev_handle, unsigned c } /* newer versions of darwin support clearing additional bits on the device's endpoint */ - kresult = (*(cInterface->interface))->ClearPipeStallBothEnds(cInterface->interface, pipeRef); + kresult = (*IOINTERFACE(cInterface))->ClearPipeStallBothEnds(IOINTERFACE(cInterface), pipeRef); if (kresult != kIOReturnSuccess) usbi_warn (HANDLE_CTX (dev_handle), "ClearPipeStall: %s", darwin_error_str (kresult)); @@ -1783,12 +2059,12 @@ static int darwin_reenumerate_device (struct libusb_device_handle *dev_handle, b cached_configurations = alloca (sizeof (*cached_configurations) * descriptor.bNumConfigurations); for (i = 0 ; i < descriptor.bNumConfigurations ; ++i) { - (*(dpriv->device))->GetConfigurationDescriptorPtr (dpriv->device, i, &cached_configuration); + (*dpriv->device)->GetConfigurationDescriptorPtr (dpriv->device, i, &cached_configuration); memcpy (cached_configurations + i, cached_configuration, sizeof (cached_configurations[i])); } /* if we need to release capture */ - if (HAS_CAPTURE_DEVICE()) { + if (get_running_version() >= 101000) { if (capture) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 options |= kUSBReEnumerateCaptureDeviceMask; @@ -1799,7 +2075,7 @@ static int darwin_reenumerate_device (struct libusb_device_handle *dev_handle, b } /* from macOS 10.11 ResetDevice no longer does anything so just use USBDeviceReEnumerate */ - kresult = (*(dpriv->device))->USBDeviceReEnumerate (dpriv->device, options); + kresult = (*dpriv->device)->USBDeviceReEnumerate (dpriv->device, options); if (kresult != kIOReturnSuccess) { usbi_err (ctx, "USBDeviceReEnumerate: %s", darwin_error_str (kresult)); dpriv->in_reenumerate = false; @@ -1844,7 +2120,7 @@ static int darwin_reenumerate_device (struct libusb_device_handle *dev_handle, b } for (i = 0 ; i < descriptor.bNumConfigurations ; ++i) { - (void) (*(dpriv->device))->GetConfigurationDescriptorPtr (dpriv->device, i, &cached_configuration); + (void) (*dpriv->device)->GetConfigurationDescriptorPtr (dpriv->device, i, &cached_configuration); if (memcmp (cached_configuration, cached_configurations + i, sizeof (cached_configurations[i]))) { usbi_dbg (ctx, "darwin/reenumerate_device: configuration descriptor %d changed", i); return LIBUSB_ERROR_NOT_FOUND; @@ -1864,7 +2140,7 @@ static int darwin_reset_device (struct libusb_device_handle *dev_handle) { #if !defined(TARGET_OS_OSX) || TARGET_OS_OSX == 1 if (dpriv->capture_count > 0) { /* we have to use ResetDevice as USBDeviceReEnumerate() loses the authorization for capture */ - kresult = (*(dpriv->device))->ResetDevice (dpriv->device); + kresult = (*dpriv->device)->ResetDevice (dpriv->device); ret = darwin_to_libusb (kresult); } else { ret = darwin_reenumerate_device (dev_handle, false); @@ -1945,10 +2221,10 @@ static void darwin_destroy_device(struct libusb_device *dev) { if (dpriv->dev) { /* need to hold the lock in case this is the last reference to the device */ - usbi_mutex_lock(&darwin_cached_devices_lock); + usbi_mutex_lock(&darwin_cached_devices_mutex); darwin_deref_cached_device (dpriv->dev); dpriv->dev = NULL; - usbi_mutex_unlock(&darwin_cached_devices_lock); + usbi_mutex_unlock(&darwin_cached_devices_mutex); } } @@ -1956,17 +2232,10 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) { struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); IOReturn ret; - uint8_t transferType; uint8_t pipeRef; - uint16_t maxPacketSize; struct darwin_interface *cInterface; -#if InterfaceVersion >= 550 - IOUSBEndpointProperties pipeProperties = {.bVersion = kUSBEndpointPropertiesVersion3}; -#else - /* None of the values below are used in libusb for bulk transfers */ - uint8_t direction, number, interval; -#endif + darwin_pipe_properties_t pipe_properties; if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface) != 0) { usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface"); @@ -1974,47 +2243,38 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) { return LIBUSB_ERROR_NOT_FOUND; } -#if InterfaceVersion >= 550 - ret = (*(cInterface->interface))->GetPipePropertiesV3 (cInterface->interface, pipeRef, &pipeProperties); - - transferType = pipeProperties.bTransferType; - maxPacketSize = pipeProperties.wMaxPacketSize; -#else - ret = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number, - &transferType, &maxPacketSize, &interval); -#endif - - if (ret) { + ret = darwin_get_pipe_properties(cInterface, pipeRef, &pipe_properties); + if (kIOReturnSuccess != ret) { usbi_err (TRANSFER_CTX (transfer), "bulk transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out", darwin_error_str(ret), ret); return darwin_to_libusb (ret); } - if (0 != (transfer->length % maxPacketSize)) { + if (0 != (transfer->length % pipe_properties.max_packet_size)) { /* do not need a zero packet */ transfer->flags &= ~LIBUSB_TRANSFER_ADD_ZERO_PACKET; } /* submit the request */ /* timeouts are unavailable on interrupt endpoints */ - if (transferType == kUSBInterrupt) { + if (pipe_properties.transfer_type == kUSBInterrupt) { if (IS_XFERIN(transfer)) - ret = (*(cInterface->interface))->ReadPipeAsync(cInterface->interface, pipeRef, transfer->buffer, - (UInt32)transfer->length, darwin_async_io_callback, itransfer); + ret = (*IOINTERFACE(cInterface))->ReadPipeAsync(IOINTERFACE(cInterface), pipeRef, transfer->buffer, + (UInt32)transfer->length, darwin_async_io_callback, itransfer); else - ret = (*(cInterface->interface))->WritePipeAsync(cInterface->interface, pipeRef, transfer->buffer, - (UInt32)transfer->length, darwin_async_io_callback, itransfer); + ret = (*IOINTERFACE(cInterface))->WritePipeAsync(IOINTERFACE(cInterface), pipeRef, transfer->buffer, + (UInt32)transfer->length, darwin_async_io_callback, itransfer); } else { itransfer->timeout_flags |= USBI_TRANSFER_OS_HANDLES_TIMEOUT; if (IS_XFERIN(transfer)) - ret = (*(cInterface->interface))->ReadPipeAsyncTO(cInterface->interface, pipeRef, transfer->buffer, - (UInt32)transfer->length, transfer->timeout, transfer->timeout, - darwin_async_io_callback, itransfer); + ret = (*IOINTERFACE(cInterface))->ReadPipeAsyncTO(IOINTERFACE(cInterface), pipeRef, transfer->buffer, + (UInt32)transfer->length, transfer->timeout, transfer->timeout, + darwin_async_io_callback, itransfer); else - ret = (*(cInterface->interface))->WritePipeAsyncTO(cInterface->interface, pipeRef, transfer->buffer, - (UInt32)transfer->length, transfer->timeout, transfer->timeout, - darwin_async_io_callback, itransfer); + ret = (*IOINTERFACE(cInterface))->WritePipeAsyncTO(IOINTERFACE(cInterface), pipeRef, transfer->buffer, + (UInt32)transfer->length, transfer->timeout, transfer->timeout, + darwin_async_io_callback, itransfer); } if (ret) @@ -2024,7 +2284,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) { return darwin_to_libusb (ret); } -#if InterfaceVersion >= 550 +#if MAX_INTERFACE_VERSION >= 550 static int submit_stream_transfer(struct usbi_transfer *itransfer) { struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); struct darwin_interface *cInterface; @@ -2037,16 +2297,22 @@ static int submit_stream_transfer(struct usbi_transfer *itransfer) { return LIBUSB_ERROR_NOT_FOUND; } + if (get_interface_interface_version() < 550) { + usbi_err (TRANSFER_CTX(transfer), "IOUSBFamily version %d does not support bulk stream transfers", + get_interface_interface_version()); + return LIBUSB_ERROR_NOT_SUPPORTED; + } + itransfer->timeout_flags |= USBI_TRANSFER_OS_HANDLES_TIMEOUT; if (IS_XFERIN(transfer)) - ret = (*(cInterface->interface))->ReadStreamsPipeAsyncTO(cInterface->interface, pipeRef, itransfer->stream_id, - transfer->buffer, (UInt32)transfer->length, transfer->timeout, - transfer->timeout, darwin_async_io_callback, itransfer); + ret = (*IOINTERFACE_V(cInterface, 550))->ReadStreamsPipeAsyncTO(IOINTERFACE(cInterface), pipeRef, itransfer->stream_id, + transfer->buffer, (UInt32)transfer->length, transfer->timeout, + transfer->timeout, darwin_async_io_callback, itransfer); else - ret = (*(cInterface->interface))->WriteStreamsPipeAsyncTO(cInterface->interface, pipeRef, itransfer->stream_id, - transfer->buffer, (UInt32)transfer->length, transfer->timeout, - transfer->timeout, darwin_async_io_callback, itransfer); + ret = (*IOINTERFACE_V(cInterface, 550))->WriteStreamsPipeAsyncTO(IOINTERFACE(cInterface), pipeRef, itransfer->stream_id, + transfer->buffer, (UInt32)transfer->length, transfer->timeout, + transfer->timeout, darwin_async_io_callback, itransfer); if (ret) usbi_err (TRANSFER_CTX (transfer), "bulk stream transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out", @@ -2061,18 +2327,11 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) { struct darwin_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer); IOReturn kresult; - uint8_t pipeRef, interval; + uint8_t pipeRef; UInt64 frame; AbsoluteTime atTime; int i; -#if InterfaceVersion >= 550 - IOUSBEndpointProperties pipeProperties = {.bVersion = kUSBEndpointPropertiesVersion3}; -#else - /* None of the values below are used in libusb for iso transfers */ - uint8_t direction, number, transferType; - uint16_t maxPacketSize; -#endif - + darwin_pipe_properties_t pipe_properties; struct darwin_interface *cInterface; /* construct an array of IOUSBIsocFrames, reuse the old one if the sizes are the same */ @@ -2103,13 +2362,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) { } /* determine the properties of this endpoint and the speed of the device */ -#if InterfaceVersion >= 550 - kresult = (*(cInterface->interface))->GetPipePropertiesV3 (cInterface->interface, pipeRef, &pipeProperties); - interval = pipeProperties.bInterval; -#else - kresult = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number, - &transferType, &maxPacketSize, &interval); -#endif + kresult = darwin_get_pipe_properties(cInterface, pipeRef, &pipe_properties); if (kresult != kIOReturnSuccess) { usbi_err (TRANSFER_CTX (transfer), "failed to get pipe properties: %d", kresult); free(tpriv->isoc_framelist); @@ -2119,7 +2372,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) { } /* Last but not least we need the bus frame number */ - kresult = (*(cInterface->interface))->GetBusFrameNumber(cInterface->interface, &frame, &atTime); + kresult = (*IOINTERFACE(cInterface))->GetBusFrameNumber(IOINTERFACE(cInterface), &frame, &atTime); if (kresult != kIOReturnSuccess) { usbi_err (TRANSFER_CTX (transfer), "failed to get bus frame number: %d", kresult); free(tpriv->isoc_framelist); @@ -2136,20 +2389,20 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) { /* submit the request */ if (IS_XFERIN(transfer)) - kresult = (*(cInterface->interface))->ReadIsochPipeAsync(cInterface->interface, pipeRef, transfer->buffer, frame, - (UInt32)transfer->num_iso_packets, tpriv->isoc_framelist, darwin_async_io_callback, - itransfer); + kresult = (*IOINTERFACE(cInterface))->ReadIsochPipeAsync(IOINTERFACE(cInterface), pipeRef, transfer->buffer, frame, + (UInt32)transfer->num_iso_packets, tpriv->isoc_framelist, darwin_async_io_callback, + itransfer); else - kresult = (*(cInterface->interface))->WriteIsochPipeAsync(cInterface->interface, pipeRef, transfer->buffer, frame, - (UInt32)transfer->num_iso_packets, tpriv->isoc_framelist, darwin_async_io_callback, - itransfer); + kresult = (*IOINTERFACE(cInterface))->WriteIsochPipeAsync(IOINTERFACE(cInterface), pipeRef, transfer->buffer, frame, + (UInt32)transfer->num_iso_packets, tpriv->isoc_framelist, darwin_async_io_callback, + itransfer); if (LIBUSB_SPEED_FULL == transfer->dev_handle->dev->speed) /* Full speed */ - cInterface->frames[transfer->endpoint] = frame + (UInt32)transfer->num_iso_packets * (1U << (interval - 1)); + cInterface->frames[transfer->endpoint] = frame + (UInt32)transfer->num_iso_packets * (1U << (pipe_properties.interval - 1)); else /* High/super speed */ - cInterface->frames[transfer->endpoint] = frame + (UInt32)transfer->num_iso_packets * (1U << (interval - 1)) / 8; + cInterface->frames[transfer->endpoint] = frame + (UInt32)transfer->num_iso_packets * (1U << (pipe_properties.interval - 1)) / 8; if (kresult != kIOReturnSuccess) { usbi_err (TRANSFER_CTX (transfer), "isochronous transfer failed (dir: %s): %s", IS_XFERIN(transfer) ? "In" : "Out", @@ -2197,10 +2450,11 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) { return LIBUSB_ERROR_NOT_FOUND; } - kresult = (*(cInterface->interface))->ControlRequestAsyncTO (cInterface->interface, pipeRef, &(tpriv->req), darwin_async_io_callback, itransfer); + kresult = (*IOINTERFACE(cInterface))->ControlRequestAsyncTO (IOINTERFACE(cInterface), pipeRef, + &(tpriv->req), darwin_async_io_callback, itransfer); } else /* control request on endpoint 0 */ - kresult = (*(dpriv->device))->DeviceRequestAsyncTO(dpriv->device, &(tpriv->req), darwin_async_io_callback, itransfer); + kresult = (*dpriv->device)->DeviceRequestAsyncTO(dpriv->device, &(tpriv->req), darwin_async_io_callback, itransfer); if (kresult != kIOReturnSuccess) usbi_err (TRANSFER_CTX (transfer), "control request failed: %s", darwin_error_str(kresult)); @@ -2220,7 +2474,7 @@ static int darwin_submit_transfer(struct usbi_transfer *itransfer) { case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: return submit_iso_transfer(itransfer); case LIBUSB_TRANSFER_TYPE_BULK_STREAM: -#if InterfaceVersion >= 550 +#if MAX_INTERFACE_VERSION >= 550 return submit_stream_transfer(itransfer); #else usbi_err (TRANSFER_CTX(transfer), "IOUSBFamily version does not support bulk stream transfers"); @@ -2239,10 +2493,11 @@ static int cancel_control_transfer(struct usbi_transfer *itransfer) { usbi_warn (ITRANSFER_CTX (itransfer), "aborting all transactions control pipe"); - if (!dpriv->device) + if (!dpriv->device) { return LIBUSB_ERROR_NO_DEVICE; + } - kresult = (*(dpriv->device))->USBDeviceAbortPipeZero (dpriv->device); + kresult = (*dpriv->device)->USBDeviceAbortPipeZero (dpriv->device); return darwin_to_libusb (kresult); } @@ -2262,23 +2517,29 @@ static int darwin_abort_transfers (struct usbi_transfer *itransfer) { return LIBUSB_ERROR_NOT_FOUND; } - if (!dpriv->device) + if (!dpriv->device) { return LIBUSB_ERROR_NO_DEVICE; + } usbi_warn (ctx, "aborting all transactions on interface %d pipe %d", iface, pipeRef); /* abort transactions */ -#if InterfaceVersion >= 550 - if (LIBUSB_TRANSFER_TYPE_BULK_STREAM == transfer->type) - (*(cInterface->interface))->AbortStreamsPipe (cInterface->interface, pipeRef, itransfer->stream_id); - else +#if MAX_INTERFACE_VERSION >= 550 + if (LIBUSB_TRANSFER_TYPE_BULK_STREAM == transfer->type && get_interface_interface_version() >= 550) { + kresult = (*IOINTERFACE_V(cInterface, 550))->AbortStreamsPipe (IOINTERFACE(cInterface), pipeRef, itransfer->stream_id); + } else #endif - (*(cInterface->interface))->AbortPipe (cInterface->interface, pipeRef); + { + kresult = (*IOINTERFACE(cInterface))->AbortPipe (IOINTERFACE(cInterface), pipeRef); + } - usbi_dbg (ctx, "calling clear pipe stall to clear the data toggle bit"); - /* newer versions of darwin support clearing additional bits on the device's endpoint */ - kresult = (*(cInterface->interface))->ClearPipeStallBothEnds(cInterface->interface, pipeRef); + if (get_interface_interface_version() <= 245) { + /* with older releases of IOUSBFamily the OS always clears the host side data toggle. for + consistency also clear the data toggle on the device. */ + usbi_dbg (ctx, "calling ClearPipeStallBothEnds to clear the data toggle bit"); + kresult = (*IOINTERFACE(cInterface))->ClearPipeStallBothEnds(IOINTERFACE(cInterface), pipeRef); + } return darwin_to_libusb (kresult); } @@ -2313,7 +2574,7 @@ static void darwin_async_io_callback (void *refcon, IOReturn result, void *arg0) (void) ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface); - (*(cInterface->interface))->WritePipe (cInterface->interface, pipeRef, transfer->buffer, 0); + (*IOINTERFACE(cInterface))->WritePipe (IOINTERFACE(cInterface), pipeRef, transfer->buffer, 0); } tpriv->result = result; @@ -2389,29 +2650,38 @@ static int darwin_handle_transfer_completion (struct usbi_transfer *itransfer) { return usbi_handle_transfer_completion (itransfer, darwin_transfer_status (itransfer, tpriv->result)); } -#if !defined(HAVE_CLOCK_GETTIME) void usbi_get_monotonic_time(struct timespec *tp) { - mach_timespec_t sys_time; +/* Check if the SDK is new enough to declare clock_gettime(), and the deployment target is at least 10.12. */ +#if ((MAC_OS_X_VERSION_MAX_ALLOWED >= 101200) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)) + clock_gettime(CLOCK_MONOTONIC, tp); +#else + mach_timebase_info_data_t machTimeBaseInfo; + mach_timebase_info(&machTimeBaseInfo); - /* use system boot time as reference for the monotonic clock */ - clock_get_time (clock_monotonic, &sys_time); + uint64_t uptime = mach_absolute_time(); + uint64_t uptimeNano = uptime * machTimeBaseInfo.numer / machTimeBaseInfo.denom; - tp->tv_sec = sys_time.tv_sec; - tp->tv_nsec = sys_time.tv_nsec; + uint64_t uptimeSeconds = uptimeNano / NSEC_PER_SEC; + uint64_t uptimeNanoRemainder = uptimeNano - (uptimeSeconds * NSEC_PER_SEC); + + tp->tv_sec = uptimeSeconds; + tp->tv_nsec = uptimeNanoRemainder; +#endif } void usbi_get_real_time(struct timespec *tp) { - mach_timespec_t sys_time; - - /* CLOCK_REALTIME represents time since the epoch */ - clock_get_time (clock_realtime, &sys_time); - - tp->tv_sec = sys_time.tv_sec; - tp->tv_nsec = sys_time.tv_nsec; -} +/* Check if the SDK is new enough to declare clock_gettime(), and the deployment target is at least 10.12. */ +#if ((MAC_OS_X_VERSION_MAX_ALLOWED >= 101200) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)) + clock_gettime(CLOCK_REALTIME, tp); +#else + struct timeval tv; + gettimeofday(&tv, NULL); + tp->tv_sec = tv.tv_sec; + tp->tv_nsec = tv.tv_usec * NSEC_PER_USEC; #endif +} -#if InterfaceVersion >= 550 +#if MAX_INTERFACE_VERSION >= 550 static int darwin_alloc_streams (struct libusb_device_handle *dev_handle, uint32_t num_streams, unsigned char *endpoints, int num_endpoints) { struct darwin_interface *cInterface; @@ -2425,7 +2695,7 @@ static int darwin_alloc_streams (struct libusb_device_handle *dev_handle, uint32 return rc; } - (*(cInterface->interface))->SupportsStreams (cInterface->interface, pipeRef, &supportsStreams); + (*IOINTERFACE_V(cInterface, 550))->SupportsStreams (IOINTERFACE(cInterface), pipeRef, &supportsStreams); if (num_streams > supportsStreams) num_streams = supportsStreams; } @@ -2438,7 +2708,7 @@ static int darwin_alloc_streams (struct libusb_device_handle *dev_handle, uint32 for (i = 0 ; i < num_endpoints ; ++i) { (void) ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface); - rc = (*(cInterface->interface))->CreateStreams (cInterface->interface, pipeRef, num_streams); + rc = (*IOINTERFACE_V(cInterface, 550))->CreateStreams (IOINTERFACE(cInterface), pipeRef, num_streams); if (kIOReturnSuccess != rc) return darwin_to_libusb(rc); } @@ -2457,11 +2727,11 @@ static int darwin_free_streams (struct libusb_device_handle *dev_handle, unsigne if (0 != (rc = ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface))) return rc; - (*(cInterface->interface))->SupportsStreams (cInterface->interface, pipeRef, &supportsStreams); + (*IOINTERFACE_V(cInterface, 550))->SupportsStreams (IOINTERFACE(cInterface), pipeRef, &supportsStreams); if (0 == supportsStreams) return LIBUSB_ERROR_INVALID_PARAM; - rc = (*(cInterface->interface))->CreateStreams (cInterface->interface, pipeRef, 0); + rc = (*IOINTERFACE_V(cInterface, 550))->CreateStreams (IOINTERFACE(cInterface), pipeRef, 0); if (kIOReturnSuccess != rc) return darwin_to_libusb(rc); } @@ -2470,7 +2740,7 @@ static int darwin_free_streams (struct libusb_device_handle *dev_handle, unsigne } #endif -#if InterfaceVersion >= 700 +#if MAX_INTERFACE_VERSION >= 700 /* macOS APIs for getting entitlement values */ @@ -2504,15 +2774,10 @@ static int darwin_reload_device (struct libusb_device_handle *dev_handle) { struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev); enum libusb_error err; - usbi_mutex_lock(&darwin_cached_devices_lock); - (*(dpriv->device))->Release(dpriv->device); - dpriv->device = darwin_device_from_service (HANDLE_CTX (dev_handle), dpriv->service); - if (!dpriv->device) { - err = LIBUSB_ERROR_NO_DEVICE; - } else { - err = LIBUSB_SUCCESS; - } - usbi_mutex_unlock(&darwin_cached_devices_lock); + usbi_mutex_lock(&darwin_cached_devices_mutex); + (*dpriv->device)->Release(dpriv->device); + err = darwin_device_from_service (HANDLE_CTX (dev_handle), dpriv->service, &dpriv->device); + usbi_mutex_unlock(&darwin_cached_devices_mutex); return err; } @@ -2526,8 +2791,7 @@ static int darwin_detach_kernel_driver (struct libusb_device_handle *dev_handle, enum libusb_error err; struct libusb_context *ctx = HANDLE_CTX (dev_handle); - if (HAS_CAPTURE_DEVICE()) { - } else { + if (get_interface_interface_version() < 700) { return LIBUSB_ERROR_NOT_SUPPORTED; } @@ -2570,8 +2834,7 @@ static int darwin_attach_kernel_driver (struct libusb_device_handle *dev_handle, UNUSED(interface); struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev); - if (HAS_CAPTURE_DEVICE()) { - } else { + if (get_interface_interface_version() < 700) { return LIBUSB_ERROR_NOT_SUPPORTED; } @@ -2638,14 +2901,14 @@ const struct usbi_os_backend usbi_backend = { .clear_halt = darwin_clear_halt, .reset_device = darwin_reset_device, -#if InterfaceVersion >= 550 +#if MAX_INTERFACE_VERSION >= 550 .alloc_streams = darwin_alloc_streams, .free_streams = darwin_free_streams, #endif .kernel_driver_active = darwin_kernel_driver_active, -#if InterfaceVersion >= 700 +#if MAX_INTERFACE_VERSION >= 700 .detach_kernel_driver = darwin_detach_kernel_driver, .attach_kernel_driver = darwin_attach_kernel_driver, .claim_interface = darwin_capture_claim_interface, diff --git a/mac/libusb/os/darwin_usb.h b/mac/libusb/os/darwin_usb.h index 7b72fffb8..86646bfee 100644 --- a/mac/libusb/os/darwin_usb.h +++ b/mac/libusb/os/darwin_usb.h @@ -1,7 +1,7 @@ /* * darwin backend for libusb 1.0 - * Copyright © 2008-2019 Nathan Hjelm - * Copyright © 2019 Google LLC. All rights reserved. + * Copyright © 2008-2023 Nathan Hjelm + * Copyright © 2019-2023 Google LLC. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -36,117 +36,48 @@ /* IOUSBInterfaceInferface */ -/* New in OS 10.12.0. */ -#if defined (kIOUSBInterfaceInterfaceID800) - -#define usb_interface_t IOUSBInterfaceInterface800 -#define InterfaceInterfaceID kIOUSBInterfaceInterfaceID800 -#define InterfaceVersion 800 - -/* New in OS 10.10.0. */ -#elif defined (kIOUSBInterfaceInterfaceID700) - -#define usb_interface_t IOUSBInterfaceInterface700 -#define InterfaceInterfaceID kIOUSBInterfaceInterfaceID700 -#define InterfaceVersion 700 - -/* New in OS 10.9.0. */ -#elif defined (kIOUSBInterfaceInterfaceID650) - -#define usb_interface_t IOUSBInterfaceInterface650 -#define InterfaceInterfaceID kIOUSBInterfaceInterfaceID650 -#define InterfaceVersion 650 - -/* New in OS 10.8.2 but can't test deployment target to that granularity, so round up. */ -#elif defined (kIOUSBInterfaceInterfaceID550) - -#define usb_interface_t IOUSBInterfaceInterface550 -#define InterfaceInterfaceID kIOUSBInterfaceInterfaceID550 -#define InterfaceVersion 550 - -/* New in OS 10.7.3 but can't test deployment target to that granularity, so round up. */ -#elif defined (kIOUSBInterfaceInterfaceID500) - -#define usb_interface_t IOUSBInterfaceInterface500 -#define InterfaceInterfaceID kIOUSBInterfaceInterfaceID500 -#define InterfaceVersion 500 - -/* New in OS 10.5.0. */ -#elif defined (kIOUSBInterfaceInterfaceID300) - -#define usb_interface_t IOUSBInterfaceInterface300 -#define InterfaceInterfaceID kIOUSBInterfaceInterfaceID300 -#define InterfaceVersion 300 - -/* New in OS 10.4.5 (or 10.4.6?) but can't test deployment target to that granularity, so round up. */ -#elif defined (kIOUSBInterfaceInterfaceID245) - -#define usb_interface_t IOUSBInterfaceInterface245 -#define InterfaceInterfaceID kIOUSBInterfaceInterfaceID245 -#define InterfaceVersion 245 - -/* New in OS 10.4.0. */ -#elif defined (kIOUSBInterfaceInterfaceID220) - -#define usb_interface_t IOUSBInterfaceInterface220 -#define InterfaceInterfaceID kIOUSBInterfaceInterfaceID220 -#define InterfaceVersion 220 - +#if defined(kIOUSBInterfaceInterfaceID800) +#define MAX_INTERFACE_VERSION 800 +#elif defined(kIOUSBInterfaceInterfaceID700) +#define MAX_INTERFACE_VERSION 700 +#elif defined(kIOUSBInterfaceInterfaceID650) +#define MAX_INTERFACE_VERSION 650 +#elif defined(kIOUSBInterfaceInterfaceID550) +#define MAX_INTERFACE_VERSION 550 +#elif defined(kIOUSBInterfaceInterfaceID245) +#define MAX_INTERFACE_VERSION 245 #else - -#error "IOUSBFamily is too old. Please upgrade your SDK and/or deployment target" - +#define MAX_INTERFACE_VERSION 220 #endif -/* IOUSBDeviceInterface */ - -/* New in OS 10.9.0. */ -#if defined (kIOUSBDeviceInterfaceID650) - -#define usb_device_t IOUSBDeviceInterface650 -#define DeviceInterfaceID kIOUSBDeviceInterfaceID650 -#define DeviceVersion 650 - -/* New in OS 10.7.3 but can't test deployment target to that granularity, so round up. */ -#elif defined (kIOUSBDeviceInterfaceID500) - -#define usb_device_t IOUSBDeviceInterface500 -#define DeviceInterfaceID kIOUSBDeviceInterfaceID500 -#define DeviceVersion 500 - -/* New in OS 10.5.4 but can't test deployment target to that granularity, so round up. */ -#elif defined (kIOUSBDeviceInterfaceID320) - -#define usb_device_t IOUSBDeviceInterface320 -#define DeviceInterfaceID kIOUSBDeviceInterfaceID320 -#define DeviceVersion 320 - -/* New in OS 10.5.0. */ -#elif defined (kIOUSBDeviceInterfaceID300) - -#define usb_device_t IOUSBDeviceInterface300 -#define DeviceInterfaceID kIOUSBDeviceInterfaceID300 -#define DeviceVersion 300 +/* set to the minimum version and casted up as needed. */ +typedef IOUSBInterfaceInterface220 **usb_interface_t; -/* New in OS 10.4.5 (or 10.4.6?) but can't test deployment target to that granularity, so round up. */ -#elif defined (kIOUSBDeviceInterfaceID245) +#define IOINTERFACE0(darwin_interface, version) ((IOUSBInterfaceInterface ## version **) (darwin_interface)->interface) +#define IOINTERFACE_V(darwin_interface, version) IOINTERFACE0(darwin_interface, version) +#define IOINTERFACE(darwin_interface) ((darwin_interface)->interface) -#define usb_device_t IOUSBDeviceInterface245 -#define DeviceInterfaceID kIOUSBDeviceInterfaceID245 -#define DeviceVersion 245 - -/* New in OS 10.2.3 but can't test deployment target to that granularity, so round up. */ -#elif defined (kIOUSBDeviceInterfaceID197) - -#define usb_device_t IOUSBDeviceInterface197 -#define DeviceInterfaceID kIOUSBDeviceInterfaceID197 -#define DeviceVersion 197 +/* IOUSBDeviceInterface */ +#if defined(kIOUSBDeviceInterfaceID650) +#define MAX_DEVICE_VERSION 650 +#elif defined(kIOUSBDeviceInterfaceID500) +#define MAX_DEVICE_VERSION 500 +#elif defined(kIOUSBDeviceInterfaceID320) +#define MAX_DEVICE_VERSION 320 +#elif defined(kIOUSBDeviceInterfaceID300) +#define MAX_DEVICE_VERSION 300 +#elif defined(kIOUSBDeviceInterfaceID245) +#define MAX_DEVICE_VERSION 245 #else +#define MAX_DEVICE_VERSION 197 +#endif -#error "IOUSBFamily is too old. Please upgrade your SDK and/or deployment target" +/* set to the minimum version and casted up as needed */ +typedef IOUSBDeviceInterface197 **usb_device_t; -#endif +#define IODEVICE0(darwin_device, version) ((IOUSBDeviceInterface ## version **)(darwin_device)) +#define IODEVICE_V(darwin_device, version) IODEVICE0(darwin_device, version) #if !defined(kIOUSBHostInterfaceClassName) #define kIOUSBHostInterfaceClassName "IOUSBHostInterface" @@ -160,15 +91,13 @@ #define IO_OBJECT_NULL ((io_object_t) 0) #endif -/* Testing availability */ -#ifndef __has_builtin - #define __has_builtin(x) 0 // Compatibility with non-clang compilers. -#endif -#if __has_builtin(__builtin_available) - #define HAS_CAPTURE_DEVICE() __builtin_available(macOS 10.10, *) -#else - #define HAS_CAPTURE_DEVICE() 0 -#endif +/* returns the current macOS version in a format similar to the + * MAC_OS_X_VERSION_MIN_REQUIRED macro. + * Examples: + * 10.1.5 -> 100105 + * 13.3.0 -> 130300 + */ +uint32_t get_running_version(void); typedef IOCFPlugInInterface *io_cf_plugin_ref_t; typedef IONotificationPortRef io_notification_port_t; @@ -182,7 +111,7 @@ struct darwin_cached_device { UInt64 session; USBDeviceAddress address; char sys_path[21]; - usb_device_t **device; + usb_device_t device; io_service_t service; int open_count; UInt8 first_config, active_config, port; @@ -201,7 +130,7 @@ struct darwin_device_handle_priv { CFRunLoopSourceRef cfSource; struct darwin_interface { - usb_interface_t **interface; + usb_interface_t interface; uint8_t num_endpoints; CFRunLoopSourceRef cfSource; uint64_t frames[256]; diff --git a/mac/libusb/os/events_posix.c b/mac/libusb/os/events_posix.c index 715a2d551..4056dae2e 100644 --- a/mac/libusb/os/events_posix.c +++ b/mac/libusb/os/events_posix.c @@ -28,6 +28,31 @@ #ifdef HAVE_TIMERFD #include #endif + +#ifdef __EMSCRIPTEN__ +/* On Emscripten `pipe` does not conform to the spec and does not block + * until events are available, which makes it unusable for event system + * and often results in deadlocks when `pipe` is in a loop like it is + * in libusb. + * + * Therefore use a custom event system based on browser event emitters. */ +#include +#include +#include + +EM_ASYNC_JS(void, em_libusb_wait_async, (const _Atomic int* ptr, int expected_value, int timeout), { + await Atomics.waitAsync(HEAP32, ptr >> 2, expected_value, timeout).value; +}); + +static void em_libusb_wait(const _Atomic int *ptr, int expected_value, int timeout) +{ + if (emscripten_is_main_runtime_thread()) { + em_libusb_wait_async(ptr, expected_value, timeout); + } else { + emscripten_atomic_wait_u32((int*)ptr, expected_value, 1000000LL * timeout); + } +} +#endif #include #ifdef HAVE_EVENTFD @@ -131,6 +156,10 @@ void usbi_signal_event(usbi_event_t *event) r = write(EVENT_WRITE_FD(event), &dummy, sizeof(dummy)); if (r != sizeof(dummy)) usbi_warn(NULL, "event write failed"); +#ifdef __EMSCRIPTEN__ + event->has_event = 1; + emscripten_atomic_notify(&event->has_event, EMSCRIPTEN_NOTIFY_ALL_WAITERS); +#endif } void usbi_clear_event(usbi_event_t *event) @@ -141,6 +170,9 @@ void usbi_clear_event(usbi_event_t *event) r = read(EVENT_READ_FD(event), &dummy, sizeof(dummy)); if (r != sizeof(dummy)) usbi_warn(NULL, "event read failed"); +#ifdef __EMSCRIPTEN__ + event->has_event = 0; +#endif } #ifdef HAVE_TIMERFD @@ -223,6 +255,14 @@ int usbi_wait_for_events(struct libusb_context *ctx, int internal_fds, num_ready; usbi_dbg(ctx, "poll() %u fds with timeout in %dms", (unsigned int)nfds, timeout_ms); +#ifdef __EMSCRIPTEN__ + // Emscripten's poll doesn't actually block, so we need to use an out-of-band + // waiting signal. + em_libusb_wait(&ctx->event.has_event, 0, timeout_ms); + // Emscripten ignores timeout_ms, but set it to 0 for future-proofing in case + // they ever implement real poll. + timeout_ms = 0; +#endif num_ready = poll(fds, nfds, timeout_ms); usbi_dbg(ctx, "poll() returned %d", num_ready); if (num_ready == 0) { diff --git a/mac/libusb/os/events_posix.h b/mac/libusb/os/events_posix.h index d81b5c4df..4bd7f0fa2 100644 --- a/mac/libusb/os/events_posix.h +++ b/mac/libusb/os/events_posix.h @@ -36,6 +36,9 @@ typedef struct usbi_event { #else typedef struct usbi_event { int pipefd[2]; +#ifdef __EMSCRIPTEN__ + _Atomic int has_event; +#endif } usbi_event_t; #define USBI_EVENT_OS_HANDLE(e) ((e)->pipefd[0]) #define USBI_EVENT_POLL_EVENTS POLLIN diff --git a/mac/libusb/os/threads_posix.c b/mac/libusb/os/threads_posix.c index 0e0e22134..0079fd598 100644 --- a/mac/libusb/os/threads_posix.c +++ b/mac/libusb/os/threads_posix.c @@ -32,8 +32,6 @@ #elif defined(__NetBSD__) # include #elif defined(__OpenBSD__) -# define _BSD_SOURCE -# include # include #elif defined(__sun__) # include @@ -109,9 +107,7 @@ unsigned int usbi_get_tid(void) #elif defined(__NetBSD__) tid = _lwp_self(); #elif defined(__OpenBSD__) - /* The following only works with OpenBSD > 5.1 as it requires - * real thread support. For 5.1 and earlier, -1 is returned. */ - tid = syscall(SYS_getthrid); + tid = getthrid(); #elif defined(__sun__) tid = _lwp_self(); #else diff --git a/mac/libusb/strerror.c b/mac/libusb/strerror.c index 9445fa9e8..eb355034b 100644 --- a/mac/libusb/strerror.c +++ b/mac/libusb/strerror.c @@ -28,7 +28,7 @@ *
  • Download the latest \c strerror.c from:
    * https://raw.github.com/libusb/libusb/master/libusb/strerror.c
  • *
  • Open the file in an UTF-8 capable editor
  • - *
  • Add the 2 letter ISO 639-1 + *
  • Add the 2 letter ISO 639-1 * code for your locale at the end of \c usbi_locale_supported[]
    * Eg. for Chinese, you would add "zh" so that: * \code... usbi_locale_supported[] = { "en", "nl", "fr" };\endcode @@ -160,7 +160,7 @@ static const char * const (*usbi_error_strings)[LIBUSB_ERROR_COUNT] = &usbi_loca * If libusb_setlocale() is not called, all messages will be in English. * * The following functions return translatable strings: libusb_strerror(). - * Note that the libusb log messages controlled through libusb_set_debug() + * Note that the libusb log messages controlled through LIBUSB_OPTION_LOG_LEVEL * are not translated, they are always in English. * * For POSIX UTF-8 environments if you want libusb to follow the standard @@ -169,9 +169,9 @@ static const char * const (*usbi_error_strings)[LIBUSB_ERROR_COUNT] = &usbi_loca * * \param locale locale-string in the form of lang[_country_region][.codeset] * or lang[-region], where lang is a 2 letter ISO 639-1 code - * \returns LIBUSB_SUCCESS on success - * \returns LIBUSB_ERROR_INVALID_PARAM if the locale doesn't meet the requirements - * \returns LIBUSB_ERROR_NOT_FOUND if the requested language is not supported + * \returns \ref LIBUSB_SUCCESS on success + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the locale doesn't meet the requirements + * \returns \ref LIBUSB_ERROR_NOT_FOUND if the requested language is not supported * \returns a LIBUSB_ERROR code on other errors */ diff --git a/mac/libusb/sync.c b/mac/libusb/sync.c index 1fa1f0be5..146cce23c 100644 --- a/mac/libusb/sync.c +++ b/mac/libusb/sync.c @@ -34,10 +34,15 @@ static void LIBUSB_CALL sync_transfer_cb(struct libusb_transfer *transfer) { + usbi_dbg(TRANSFER_CTX(transfer), "actual_length=%d", transfer->actual_length); + int *completed = transfer->user_data; *completed = 1; - usbi_dbg(TRANSFER_CTX(transfer), "actual_length=%d", transfer->actual_length); - /* caller interprets result and frees transfer */ + /* + * Right after setting 'completed', another thread might free the transfer, so don't + * access it beyond this point. The instantiating thread (not necessarily the + * current one) interprets the result and frees the transfer. + */ } static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer) @@ -85,12 +90,12 @@ static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer) * before giving up due to no response being received. For an unlimited * timeout, use value 0. * \returns on success, the number of bytes actually transferred - * \returns LIBUSB_ERROR_TIMEOUT if the transfer timed out - * \returns LIBUSB_ERROR_PIPE if the control request was not supported by the + * \returns \ref LIBUSB_ERROR_TIMEOUT if the transfer timed out + * \returns \ref LIBUSB_ERROR_PIPE if the control request was not supported by the * device - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected - * \returns LIBUSB_ERROR_BUSY if called from event handling context - * \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_BUSY if called from event handling context + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than * the operating system and/or hardware can support (see \ref asynclimits) * \returns another LIBUSB_ERROR code on other failures */ @@ -260,14 +265,14 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle, * timeout, use value 0. * * \returns 0 on success (and populates transferred) - * \returns LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates + * \returns \ref LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates * transferred) - * \returns LIBUSB_ERROR_PIPE if the endpoint halted - * \returns LIBUSB_ERROR_OVERFLOW if the device offered more data, see + * \returns \ref LIBUSB_ERROR_PIPE if the endpoint halted + * \returns \ref LIBUSB_ERROR_OVERFLOW if the device offered more data, see * \ref libusb_packetoverflow - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected - * \returns LIBUSB_ERROR_BUSY if called from event handling context - * \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_BUSY if called from event handling context + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than * the operating system and/or hardware can support (see \ref asynclimits) * \returns another LIBUSB_ERROR code on other failures */ @@ -315,13 +320,13 @@ int API_EXPORTED libusb_bulk_transfer(libusb_device_handle *dev_handle, * timeout, use value 0. * * \returns 0 on success (and populates transferred) - * \returns LIBUSB_ERROR_TIMEOUT if the transfer timed out - * \returns LIBUSB_ERROR_PIPE if the endpoint halted - * \returns LIBUSB_ERROR_OVERFLOW if the device offered more data, see + * \returns \ref LIBUSB_ERROR_TIMEOUT if the transfer timed out + * \returns \ref LIBUSB_ERROR_PIPE if the endpoint halted + * \returns \ref LIBUSB_ERROR_OVERFLOW if the device offered more data, see * \ref libusb_packetoverflow - * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected - * \returns LIBUSB_ERROR_BUSY if called from event handling context - * \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than + * \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected + * \returns \ref LIBUSB_ERROR_BUSY if called from event handling context + * \returns \ref LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than * the operating system and/or hardware can support (see \ref asynclimits) * \returns another LIBUSB_ERROR code on other error */ diff --git a/mac/libusb/version.h b/mac/libusb/version.h index fe95d84b6..ca9df20ff 100644 --- a/mac/libusb/version.h +++ b/mac/libusb/version.h @@ -7,7 +7,7 @@ #define LIBUSB_MINOR 0 #endif #ifndef LIBUSB_MICRO -#define LIBUSB_MICRO 26 +#define LIBUSB_MICRO 27 #endif #ifndef LIBUSB_NANO #define LIBUSB_NANO 0 diff --git a/mac/libusb/version_nano.h b/mac/libusb/version_nano.h index dbd5d5f5b..a6165f334 100644 --- a/mac/libusb/version_nano.h +++ b/mac/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11724 +#define LIBUSB_NANO 11882 From 386f1ca4419c739d2bebe8cb185d515bfbd37e6b Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 18 Apr 2024 05:34:22 -0600 Subject: [PATCH 073/132] support builds with shapelib (as documented). (#1268) --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da33def6b..52cedd50a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -351,7 +351,6 @@ target_sources(gpsbabel PRIVATE ${SOURCES} ${HEADERS}) # We don't care about stripping things out of the build. Full monty, baby. target_compile_definitions(gpsbabel PRIVATE MAXIMAL_ENABLED) target_compile_definitions(gpsbabel PRIVATE FILTERS_ENABLED) -target_compile_definitions(gpsbabel PRIVATE SHAPELIB_ENABLED) target_compile_definitions(gpsbabel PRIVATE CSVFMTS_ENABLED) target_link_libraries(gpsbabel PRIVATE ${QT_LIBRARIES} ${LIBS}) From c320b2146f95f73ce8e51def83c729ca6704dce6 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:54:49 -0600 Subject: [PATCH 074/132] add fedora 40 to CI (#1270) --- .github/workflows/fedora.yml | 4 ++++ tools/Dockerfile_f40 | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tools/Dockerfile_f40 diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index ce8187ab7..995ade4bc 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -28,6 +28,10 @@ jobs: CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' - IMAGE: '39' CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6' + - IMAGE: '40' + CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' + - IMAGE: '40' + CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6' container: image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_f${{ matrix.IMAGE }} env: diff --git a/tools/Dockerfile_f40 b/tools/Dockerfile_f40 new file mode 100644 index 000000000..fe9e83448 --- /dev/null +++ b/tools/Dockerfile_f40 @@ -0,0 +1,22 @@ +# this file is used to build the image gpsbabel_build_environment used by travis. + +FROM fedora:40 + +LABEL maintainer="https://github.com/tsteven4" + +WORKDIR /app + +# basic tools to build +RUN dnf install --assumeyes git make valgrind diffutils findutils langpacks-en ninja-build && \ + dnf clean all +# libraries used by gpsbabel. zlib and shapelib may or may not be used depending qmake options. +RUN dnf install --assumeyes libusb1-devel zlib-devel shapelib-devel && \ + dnf clean all +# Qt used by gpsbabel, gpsbabelfe +RUN dnf install --assumeyes qt5-qtbase-devel qt5-qtserialport-devel qt5-qtwebengine-devel qt5-linguist qt5-qttranslations && \ + dnf clean all +RUN dnf install --assumeyes qt6-qtbase-devel qt6-qtserialport-devel qt6-qtwebengine-devel qt6-linguist qt6-qttranslations qt6-qt5compat-devel qt6-qttools-devel libxkbcommon-devel && \ + dnf clean all +# tools to build the docs +RUN dnf install --assumeyes expat desktop-file-utils libxslt docbook-style-xsl fop docbook5-style-xsl docbook5-schemas && \ + dnf clean all From 2d6e12d67a546d61af715416fc5424c3625e6d00 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 27 Apr 2024 13:35:28 -0600 Subject: [PATCH 075/132] add Ubuntu noble to CI (#1273) * add ubuntu noble docker support * update qt6 packages for noble. noble has some new qt6 packages that alleviate the need to directly install some libraries. also, the dependencies of some qt6 packages have been improved allowing us to specify what we use more directly. this results in the same set of packges being installed. * remove dependent qt5 package * add noble to CI --- .github/workflows/ubuntu.yml | 7 +++ tools/Dockerfile_noble | 94 ++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 tools/Dockerfile_noble diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d4c8cec17..4385a76ad 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -31,6 +31,13 @@ jobs: CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6' SCRIPT: './tools/build_and_test_cmake.sh' TOOLS: 'clang' + - IMAGE: 'noble' + CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6' + SCRIPT: './tools/build_and_test_cmake.sh' + - IMAGE: 'noble' + CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6' + SCRIPT: './tools/build_and_test_cmake.sh' + TOOLS: 'clang' - IMAGE: 'jammy' CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt5' SCRIPT: './tools/build_extra_tests.sh' diff --git a/tools/Dockerfile_noble b/tools/Dockerfile_noble new file mode 100644 index 000000000..498f1ac39 --- /dev/null +++ b/tools/Dockerfile_noble @@ -0,0 +1,94 @@ +# this file is used to build the image gpsbabel_build_environment used by travis. + +FROM ubuntu:noble + +LABEL maintainer="https://github.com/tsteven4" + +WORKDIR /app + +# update environment. +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ + apt-utils \ + && apt-get upgrade -y \ + && rm -rf /var/lib/apt/lists/* + +# install packages needed for gpsbabel build +# split into multiple commands to limit layer size + +# basic build and test tools +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + autoconf \ + git \ + valgrind \ + expat \ + libxml2-utils \ + bear \ + cmake \ + ninja-build \ + clazy \ + clang-tidy \ + jq \ + curl \ + && rm -rf /var/lib/apt/lists/* + +# alternative compiler +RUN apt-get update && apt-get install -y --no-install-recommends \ + clang \ + && rm -rf /var/lib/apt/lists/* + +# pkgs needed to build document +RUN apt-get update && apt-get install -y --no-install-recommends \ + fop \ + xsltproc \ + docbook-xml \ + docbook5-xml \ + docbook-xsl \ + docbook-xsl-ns \ + libavalon-framework-java \ + jing \ + && rm -rf /var/lib/apt/lists/* + +# pkgs with libraries needed by gpsbabel +RUN apt-get update && apt-get install -y --no-install-recommends \ + libusb-1.0-0-dev \ + pkg-config \ + libudev-dev \ + && rm -rf /var/lib/apt/lists/* + +# pkgs with qt used by gpsbabel +RUN apt-get update && apt-get install -y --no-install-recommends \ + qtbase5-dev \ + qttools5-dev \ + qttranslations5-l10n \ + qtwebengine5-dev \ + libqt5serialport5-dev \ + && rm -rf /var/lib/apt/lists/* + +# pkgs with qt used by gpsbabel +RUN apt-get update && apt-get install -y --no-install-recommends \ + qt6-base-dev \ + qt6-5compat-dev \ + qt6-serialport-dev \ + libx11-xcb-dev \ + libxkbcommon-dev \ + qt6-tools-dev \ + qt6-translations-l10n \ + qt6-webengine-dev \ + qt6-wayland \ + && rm -rf /var/lib/apt/lists/* + +# pkgs needed to generate coverage report: +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcovr \ + && rm -rf /var/lib/apt/lists/* + +# install environment for locale test +RUN apt-get update && apt-get install -y --no-install-recommends \ + locales \ + && rm -rf /var/lib/apt/lists/* \ + && sed -i 's/^# *\(en_US ISO-8859-1\)/\1/' /etc/locale.gen \ + && locale-gen \ + && locale -a From 06351ff9665f4d449b8aa9788083de6f9a807a46 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 4 May 2024 09:53:15 -0600 Subject: [PATCH 076/132] Move floor to Qt 6.2 (#1272) * move floor from Qt 5.15 to 6.2. * fix some CI failures * try harder to fix coverage build * try to fix coverage again * try agin * move up msvc tools minimum for Qt6 * clean up clazy warnings with Qt6. * drop redundnant CI job * revert translation related unintentionl changes * simplify find qt packages * assume Qt6 in textstream * move CI tidy to noble * assume Qt6 in textstream.h * remove obsolete makesetup.bat * remove Qt5 support from coretool * strip Qt5 from noble image * update default qt versions. * update minimum cmake version to match Qt 6.2.4 QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT * assume QHash result is type size_t * remove unnecessary qOverloads (in Qt6). --- .github/workflows/codacy-analysis.yaml | 4 +- .github/workflows/fedora.yml | 10 ---- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 7 +-- .github/workflows/windows.yml | 26 +-------- CMakeLists.txt | 29 +++------- INSTALL | 3 +- csv_util.cc | 13 ++--- defs.h | 6 -- gdb.h | 19 +------ gui/CMakeLists.txt | 31 +++++------ gui/coretool/CMakeLists.txt | 17 +++--- gui/main.cc | 2 +- gui/mainwindow.cc | 12 +--- gui/makesetup.bat | 76 -------------------------- gui/runmachine.cc | 14 ++--- gui/runmachine.h | 15 ++--- igc.h | 2 +- inifile.cc | 6 +- main.cc | 6 +- mkshort.h | 2 +- smplrout.cc | 2 +- src/core/textstream.cc | 38 +------------ src/core/textstream.h | 12 ---- tools/Dockerfile_noble | 9 --- tools/ci_install_windows.sh | 2 +- tools/ci_setup_windows.ps1 | 2 +- trackfilter.cc | 14 ++--- xmldoc/chapters/build.xml | 3 +- 29 files changed, 81 insertions(+), 303 deletions(-) delete mode 100644 gui/makesetup.bat diff --git a/.github/workflows/codacy-analysis.yaml b/.github/workflows/codacy-analysis.yaml index acd19a832..1a33418ba 100644 --- a/.github/workflows/codacy-analysis.yaml +++ b/.github/workflows/codacy-analysis.yaml @@ -16,8 +16,8 @@ jobs: fail-fast: false matrix: include: - - IMAGE: 'jammy' - CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt5' + - IMAGE: 'noble' + CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6' SCRIPT: './tools/ci_run_tidy.sh' container: image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_${{ matrix.IMAGE }} diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index 995ade4bc..f8a2aa553 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -14,22 +14,12 @@ jobs: fail-fast: false matrix: include: - - IMAGE: '35' - CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' - - IMAGE: '37' - CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' - IMAGE: '37' CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6' - - IMAGE: '38' - CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' - IMAGE: '38' CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6' - - IMAGE: '39' - CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' - IMAGE: '39' CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6' - - IMAGE: '40' - CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5' - IMAGE: '40' CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6' container: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 3538c98fa..23b05ca83 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: include: - - QT_VERSION: '5.15.2' + - QT_VERSION: '6.2.4' XCODE_VERSION: '13.4.1' GENERATOR: 'Ninja' RELEASE: false diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 4385a76ad..0e18db517 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -21,9 +21,6 @@ jobs: # focal has Qt 5.12, end of standard support 4/2025, end of life 4/2030. #- IMAGE: 'focal' # SCRIPT: './tools/build_and_test_cmake.sh' - - IMAGE: 'jammy' - CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt5' - SCRIPT: './tools/build_and_test_cmake.sh' - IMAGE: 'jammy' CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6' SCRIPT: './tools/build_and_test_cmake.sh' @@ -39,7 +36,7 @@ jobs: SCRIPT: './tools/build_and_test_cmake.sh' TOOLS: 'clang' - IMAGE: 'jammy' - CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt5' + CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6' SCRIPT: './tools/build_extra_tests.sh' container: image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_${{ matrix.IMAGE }} @@ -76,7 +73,7 @@ jobs: - name: install run: | sudo apt-get update - sudo apt-get install gcovr lcov libusb-1.0-0-dev qtbase5-dev qtwebengine5-dev libqt5serialport5-dev ninja-build + sudo apt-get install gcovr lcov libusb-1.0-0-dev libgl-dev qt6-base-dev libqt6core5compat6-dev libqt6serialport6-dev qt6-webengine-dev qt6-webengine-dev-tools ninja-build - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ba596ce36..b37a74a0d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -19,35 +19,11 @@ jobs: fail-fast: false matrix: include: - - QT_VERSION: '5.15.2' - ARCH: 'amd64' - HOST_ARCH: 'amd64' - COMPILER: 'msvc2019_64' - METHOD: 'aqt' - GENERATOR: 'Visual Studio 16 2019' - RELEASE: false - os: windows-2019 - - QT_VERSION: '5.15.2' - ARCH: 'amd64' - HOST_ARCH: 'amd64' - COMPILER: 'msvc2019_64' - TOOLSET: 'v141,version=14.16.27023' - METHOD: 'aqt' - GENERATOR: 'Visual Studio 16 2019' - RELEASE: false - os: windows-2019 - - QT_VERSION: '5.15.2' - ARCH: 'x86' - HOST_ARCH: 'amd64' - COMPILER: 'msvc2019' - METHOD: 'aqt' - GENERATOR: 'Visual Studio 16 2019' - RELEASE: false - os: windows-2019 - QT_VERSION: '6.2.4' ARCH: 'amd64' HOST_ARCH: 'amd64' COMPILER: 'msvc2019_64' + TOOLSET: 'v142,version=14.29.30133' METHOD: 'aqt' GENERATOR: 'Visual Studio 16 2019' RELEASE: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 52cedd50a..55ac322d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.16) include(CMakeDependentOption) include(CheckIncludeFile) @@ -26,17 +26,12 @@ set(CMAKE_AUTORCC ON) add_executable(gpsbabel) # Find the QtCore library -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) -list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Core) -if(${Qt${QT_VERSION_MAJOR}Core_VERSION} VERSION_LESS 5.15) - message(FATAL_ERROR "Qt version ${Qt${QT_VERSION_MAJOR}Core_VERSION} found, but version 5.15 or newer is required.") +find_package(Qt6 REQUIRED COMPONENTS Core Core5Compat) +list(APPEND QT_LIBRARIES Qt6::Core Qt6::Core5Compat) +if(${Qt6Core_VERSION} VERSION_LESS 6.2) + message(FATAL_ERROR "Qt version ${Qt6Core_VERSION} found, but version 6.2 or newer is required.") else() - message(STATUS "Using Qt${QT_VERSION_MAJOR} version ${Qt${QT_VERSION_MAJOR}Core_VERSION}") -endif() -if(${QT_VERSION_MAJOR} EQUAL "6") - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core5Compat REQUIRED) - list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Core5Compat) + message(STATUS "Using Qt6 version ${Qt6Core_VERSION}") endif() option(GPSBABEL_ENABLE_PCH "enable precompiled headers." ON) @@ -174,6 +169,7 @@ set(SUPPORT rgbcolors.cc route.cc session.cc + src/core/codecdevice.cc src/core/logging.cc src/core/nvector.cc src/core/textstream.cc @@ -187,9 +183,6 @@ set(SUPPORT waypt.cc xmlgeneric.cc ) -if(${QT_VERSION_MAJOR} EQUAL "6") - set(SUPPORT ${SUPPORT} src/core/codecdevice.cc) -endif() # HEADERS set(HEADERS @@ -267,6 +260,7 @@ set(HEADERS jeeps/gpsusbcommon.h jeeps/gpsusbint.h jeeps/gpsutil.h + src/core/codecdevice.h src/core/datetime.h src/core/file.h src/core/logging.h @@ -277,9 +271,6 @@ set(HEADERS src/core/xmlstreamwriter.h src/core/xmltag.h ) -if(${QT_VERSION_MAJOR} EQUAL "6") - set(HEADERS ${HEADERS} src/core/codecdevice.h) -endif() string(REPLACE .cc .h FILTER_HEADERS "${FILTERS}") set(HEADERS ${HEADERS} ${FILTER_HEADERS}) @@ -292,9 +283,7 @@ endif() if(WIN32) target_compile_definitions(gpsbabel PRIVATE __WIN32__) - if(${QT_VERSION_MAJOR} EQUAL "6") - qt_disable_unicode_defines(gpsbabel) - endif() + qt_disable_unicode_defines(gpsbabel) if(CMAKE_BUILD_TYPE STREQUAL Debug) target_compile_definitions(gpsbabel PRIVATE _DEBUG) endif() diff --git a/INSTALL b/INSTALL index f6ea5c7cb..8fe983de6 100644 --- a/INSTALL +++ b/INSTALL @@ -104,6 +104,5 @@ On non-macOS unix builds by default we now compile in the gpsbabel generated translation files, i.e. gpsbabelfe_*.qm, gpsbabel_*.qm, as well as gmapbase.html. When compiled in these files do not need to be distributed. These are used by the GUI. Additional translation files from Qt will also be -used if they are found. They may be in a package such as qttranslations5-l10n -or qt5-qttranslations. +used if they are found. They may be in a package such as qt6-translations-l10n. diff --git a/csv_util.cc b/csv_util.cc index 373e35556..1a7ad8420 100644 --- a/csv_util.cc +++ b/csv_util.cc @@ -20,7 +20,6 @@ */ -#include // for assert #include // for fabs #include // for strtod #include // for strlen, strchr, strncmp, strcmp, memmove, strcpy, strcspn, strncpy @@ -28,7 +27,7 @@ #include // for QByteArray #include // for QChar #include // for QDebug -#include // for QRegularExpression +#include // for QList #include // for QString, operator+ #include "defs.h" @@ -49,12 +48,10 @@ csv_stringclean(const QString& source, const QString& to_nuke) { QString r = source; if (!to_nuke.isEmpty()) { - // avoid problematic regular rexpressions, e.g. xmapwpt generated [:\n:], - // or one can imagine [0-9] when we meant the characters, '0', '-', and '9', - // or one can imagine [^a] when we meant the characters '^' and 'a'. - QRegularExpression regex = QRegularExpression(QStringLiteral("[%1]").arg(QRegularExpression::escape(to_nuke))); - assert(regex.isValid()); - r.remove(regex); + auto isNukeable = [&to_nuke](const QChar &ch)->bool { + return to_nuke.contains(ch); + }; + r.removeIf(isNukeable); } return r; } diff --git a/defs.h b/defs.h index 7604be2f1..93f2b5d0b 100644 --- a/defs.h +++ b/defs.h @@ -1022,10 +1022,4 @@ int color_to_bbggrr(const char* cname); constexpr double unknown_alt = -99999999.0; constexpr int unknown_color = -1; -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -using qhash_result_t = uint; -#else -using qhash_result_t = size_t; -#endif - #endif // DEFS_H_INCLUDED_ diff --git a/gdb.h b/gdb.h index fc3497401..d4797a45e 100644 --- a/gdb.h +++ b/gdb.h @@ -30,7 +30,6 @@ #include // for QString #include // for QStringView #include // for QVector -#include // for QT_VERSION, QT_VERSION_CHECK #include "defs.h" // for arglist_t, Waypoint, route_head, ARGTYPE_BOOL, ARGTYPE_INT, ARG_NOMINMAX, bounds, FF_CAP_RW_ALL, ff_cap, ff_type, ff_type_file #include "format.h" // for Format @@ -74,23 +73,9 @@ class GdbFormat : public Format public: WptNamePosnKey(const QString& name, double lt, double ln) : shortname(name), lat(lt), lon(ln) {} - friend qhash_result_t qHash(const WptNamePosnKey &c, qhash_result_t seed = 0) noexcept + friend size_t qHash(const WptNamePosnKey &c, size_t seed = 0) noexcept { -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) return qHashMulti(seed, c.shortname.toUpper(), c.lat, c.lon); -#else - /* - * As noted in above refeference - * QtPrivate::QHashCombine is private API, but does not require any special buildsystem magic; - * it’s in , a public header. - */ - QtPrivate::QHashCombine hash; - - seed = hash(seed, c.shortname.toUpper()); - seed = hash(seed, c.lat); - seed = hash(seed, c.lon); - return seed; -#endif } QString shortname; @@ -104,7 +89,7 @@ class GdbFormat : public Format public: WptNameKey(const QString& name) : shortname(name) {} /* converting constructor */ - friend qhash_result_t qHash(const WptNameKey &c, qhash_result_t seed = 0) noexcept + friend size_t qHash(const WptNameKey &c, size_t seed = 0) noexcept { return qHash(c.shortname.toUpper(), seed); } diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index a64f6813a..04e095498 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -22,19 +22,18 @@ if(NOT UNIX OR APPLE) endif() # Find the QtCore library -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Network SerialPort Widgets Xml REQUIRED) -list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::SerialPort Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Xml) -if(${Qt${QT_VERSION_MAJOR}Core_VERSION} VERSION_LESS 5.15) - message(FATAL_ERROR "Qt version ${Qt${QT_VERSION_MAJOR}Core_VERSION} found, but version 5.15 or newer is required.") +find_package(Qt6 REQUIRED COMPONENTS Core Gui Network SerialPort Widgets Xml) +list(APPEND QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Network Qt6::SerialPort Qt6::Widgets Qt6::Xml) +if(${Qt6Core_VERSION} VERSION_LESS 6.2) + message(FATAL_ERROR "Qt version ${Qt6Core_VERSION} found, but version 6.2 or newer is required.") else() - message(STATUS "Using Qt${QT_VERSION_MAJOR} version ${Qt${QT_VERSION_MAJOR}Core_VERSION}") + message(STATUS "Using Qt6 version ${Qt6Core_VERSION}") endif() option(GPSBABEL_MAPPREVIEW "enable map preview." ON) if (GPSBABEL_MAPPREVIEW) - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WebEngineWidgets WebChannel REQUIRED) - list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::WebEngineWidgets Qt${QT_VERSION_MAJOR}::WebChannel) + find_package(Qt6 REQUIRED COMPONENTS WebEngineWidgets WebChannel) + list(APPEND QT_LIBRARIES Qt6::WebEngineWidgets Qt6::WebChannel) else() target_compile_definitions(gpsbabelfe PRIVATE DISABLE_MAPPREVIEW) endif() @@ -173,9 +172,9 @@ message(STATUS "Libs are: \"${LnkLibs}\"") get_target_property(IncDirs gpsbabelfe INCLUDE_DIRECTORIES) message(STATUS "Include Directores are: \"${IncDirs}\"") -find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS LinguistTools) -if (NOT Qt${QT_VERSION_MAJOR}LinguistTools_FOUND) - message(WARNING "Qt${QT_VERSION_MAJOR}LinguistTools not found, gpsbabelfe translations cannot be updated or released, and application cannot be packaged.") +find_package(Qt6 QUIET COMPONENTS LinguistTools) +if (NOT Qt6LinguistTools_FOUND) + message(WARNING "Qt6LinguistTools not found, gpsbabelfe translations cannot be updated or released, and application cannot be packaged.") else() # FIXME: translations updated and released in source directory (and under version control). list(APPEND TRANSLATIONS gpsbabelfe_de.ts) @@ -186,19 +185,19 @@ else() list(APPEND TRANSLATIONS gpsbabelfe_ru.ts) add_custom_target(gpsbabelfe_lupdate - COMMAND Qt${QT_VERSION_MAJOR}::lupdate ${SOURCES} ${FORMS} -ts ${TRANSLATIONS} + COMMAND Qt6::lupdate ${SOURCES} ${FORMS} -ts ${TRANSLATIONS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM USES_TERMINAL) add_custom_target(gpsbabelfe_lrelease - COMMAND Qt${QT_VERSION_MAJOR}::lrelease ${TRANSLATIONS} + COMMAND Qt6::lrelease ${TRANSLATIONS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS gpsbabelfe_lupdate VERBATIM USES_TERMINAL) if(APPLE) - get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) + get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION) add_custom_target(package_app COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/package_app -a $ -q ${_qmake_executable} -g $ -s ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${CMAKE_COMMAND} -E copy $/../GPSBabelFE.dmg ${CMAKE_CURRENT_BINARY_DIR} @@ -206,7 +205,7 @@ else() VERBATIM USES_TERMINAL) elseif(UNIX) - get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) + get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION) add_custom_target(package_app COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/package_app -a $ -q ${_qmake_executable} -g $ -s ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS gpsbabelfe gpsbabel gpsbabelfe_lrelease coretool_lrelease @@ -220,7 +219,7 @@ else() endif() # in 5.12.12 cmake doesn't know about windeployqt, look in directory that has qmake. - get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) + get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION) get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) find_program(WINDEPLOYQT NAMES windeployqt PATHS "${_qt_bin_dir}" NO_DEFAULT_PATH) if (WINDEPLOYQT STREQUAL "WINDEPLOYQT-NOTFOUND") diff --git a/gui/coretool/CMakeLists.txt b/gui/coretool/CMakeLists.txt index dbe37b739..aa3df9a0c 100644 --- a/gui/coretool/CMakeLists.txt +++ b/gui/coretool/CMakeLists.txt @@ -4,9 +4,8 @@ endif() add_executable(coretool EXCLUDE_FROM_ALL) -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets REQUIRED) -list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets) +find_package(Qt6 REQUIRED COMPONENTS Core Widgets) +list(APPEND QT_LIBRARIES Qt6::Core Qt6::Widgets) list(APPEND SOURCES ../formatload.cc) list(APPEND SOURCES coretool.cc) @@ -22,7 +21,7 @@ target_link_libraries(coretool ${QT_LIBRARIES}) # FIXME: core_strings.h generated in source directory (and under version control). # FIXME: translations updated and released in source directory (and under version control). -get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) +get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION) get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/core_strings.h COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR} @@ -39,26 +38,26 @@ list(APPEND TRANSLATIONS gpsbabel_hu.ts) list(APPEND TRANSLATIONS gpsbabel_it.ts) list(APPEND TRANSLATIONS gpsbabel_ru.ts) -find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS LinguistTools) -if(Qt${QT_VERSION_MAJOR}LinguistTools_FOUND) +find_package(Qt6 QUIET COMPONENTS LinguistTools) +if(Qt6LinguistTools_FOUND) # The line numbers are almost meaningless the way we generate corestrings.h, and we force everything to the same context. # With line numbers and the similartext heuristic enabled translations can be copied from an old message to a new message, # and marked as unfinished. The threshold for similar is low. # These will be used by the application, even though they really need to be checked. # Disable the similartext heuristic to avoid these mistranslations. add_custom_target(coretool_lupdate - COMMAND Qt${QT_VERSION_MAJOR}::lupdate -disable-heuristic similartext core_strings.h -ts ${TRANSLATIONS} + COMMAND Qt6::lupdate -disable-heuristic similartext core_strings.h -ts ${TRANSLATIONS} DEPENDS core_strings.h WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM USES_TERMINAL) add_custom_target(coretool_lrelease - COMMAND Qt${QT_VERSION_MAJOR}::lrelease ${TRANSLATIONS} + COMMAND Qt6::lrelease ${TRANSLATIONS} DEPENDS coretool_lupdate WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM USES_TERMINAL) else() - message(WARNING "Qt${QT_VERSION_MAJOR}LinguistTools not found, coretool translations cannot be updated or released.") + message(WARNING "Qt6LinguistTools not found, coretool translations cannot be updated or released.") endif() diff --git a/gui/main.cc b/gui/main.cc index 6ad489aa8..84b08c1fe 100644 --- a/gui/main.cc +++ b/gui/main.cc @@ -32,7 +32,7 @@ int main(int argc, char** argv) // MIN_QT_VERSION in GPSBabel.pro should correspond to the QT_VERSION_CHECK // arguments in main.cc and gui/main.cc and the version check in // CMakeLists.txt, gui/CMakeLists.txt. -#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) +#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) #error this version of Qt is not supported. #endif diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc index 21352c239..054169a4c 100644 --- a/gui/mainwindow.cc +++ b/gui/mainwindow.cc @@ -178,13 +178,9 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) connect(ui_.actionUpgradeCheck, &QAction::triggered, this, &MainWindow::upgradeCheckActionX); connect(ui_.actionPreferences, &QAction::triggered, this, &MainWindow::preferencesActionX); -// TODO: Qt6 deleted the obsolete overloaded signal QComboBox::currentIndexChanged(const QString &text) -// that required using qOverload. - connect(ui_.inputFormatCombo, qOverload(&QComboBox::currentIndexChanged), + connect(ui_.inputFormatCombo, &QComboBox::currentIndexChanged, this, &MainWindow::inputFormatChanged); -// TODO: Qt6 deleted the obsolete overloaded signal QComboBox::currentIndexChanged(const QString &text) -// that required using qOverload. - connect(ui_.outputFormatCombo, qOverload(&QComboBox::currentIndexChanged), + connect(ui_.outputFormatCombo, &QComboBox::currentIndexChanged, this, &MainWindow::outputFormatChanged); connect(ui_.inputOptionsBtn, &QAbstractButton::clicked, this, &MainWindow::inputOptionButtonClicked); @@ -270,11 +266,7 @@ void MainWindow::switchTranslator(QTranslator& translator, const QString& filena const QStringList directories = { QApplication::applicationDirPath() + "/translations", ":/translations", -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - QLibraryInfo::location(QLibraryInfo::TranslationsPath) -#else QLibraryInfo::path(QLibraryInfo::TranslationsPath) -#endif }; // Load the new translator. diff --git a/gui/makesetup.bat b/gui/makesetup.bat deleted file mode 100644 index 08531a67a..000000000 --- a/gui/makesetup.bat +++ /dev/null @@ -1,76 +0,0 @@ -rem $Id: makesetup.bat,v 1.2 2010-06-27 21:13:07 robertl Exp $ -rem -rem Copy the Qt stuff into a local directory. The Inno Setup compiler -rem cannot handle %QTDIR environment variable in the source file -rem specification - -echo off -rd /q /s qtdir -mkdir qtdir -mkdir qtdir\bin -mkdir qtdir\translations -mkdir qtdir\plugins -mkdir qtdir\plugins\imageformats -mkdir qtdir\plugins\platforms -mkdir qtdir\mingw - -rem Basic Qt runtime DLLs -rem if "%QTDIR%"=="" call \QtSDK\Desktop\Qt\4.7.4\mingw\bin\qtenv2.bat -rem if "%QTDIR%"=="" call \Qt\Qt5.2.1\5.2.1\mingw48_32\bin\qtenv2.bat -if "%QTDIR%"=="" set QTDIR=c:\Qt\Qt5.2.1\5.2.1\mingw48_32 -copy %QTDIR%\bin\icu*.dll qtdir\bin -copy %QTDIR%\bin\libgcc_s_dw2-1.dll qtdir\bin -copy %QTDIR%\bin\libstdc*.dll qtdir\bin -copy %QTDIR%\bin\libwinpthread*.dll qtdir\bin -copy %QTDIR%\bin\Qt5Core.dll qtdir\bin -copy %QTDIR%\bin\Qt5Gui.dll qtdir\bin -copy %QTDIR%\bin\Qt5Multimedia.dll qtdir\bin -copy %QTDIR%\bin\Qt5MultimediaWidgets.dll qtdir\bin -copy %QTDIR%\bin\Qt5Network.dll qtdir\bin -copy %QTDIR%\bin\Qt5OpenGL.dll qtdir\bin -copy %QTDIR%\bin\Qt5Positioning.dll qtdir\bin -copy %QTDIR%\bin\Qt5PrintSupport.dll qtdir\bin -copy %QTDIR%\bin\Qt5Qml.dll qtdir\bin -copy %QTDIR%\bin\Qt5Quick.dll qtdir\bin -copy %QTDIR%\bin\Qt5Sensors.dll qtdir\bin -copy %QTDIR%\bin\Qt5Sql.dll qtdir\bin -copy %QTDIR%\bin\Qt5Webkit.dll qtdir\bin -copy %QTDIR%\bin\Qt5WebkitWidgets.dll qtdir\bin -copy %QTDIR%\bin\Qt5Widgets.dll qtdir\bin -copy %QTDIR%\bin\Qt5Xml.dll qtdir\bin - -rem Image format plugins needed at runtime, but not debug verions -xcopy %QTDIR%\plugins\imageformats qtdir\plugins\imageformats -xcopy %QTDIR%\plugins\platforms qtdir\plugins\platforms -rem del qtdir\plugins\imageformats\*d4*.dll -rem del qtdir\plugins\imageformats\lib*d4*.a - -rem Mingw runtime support -copy %QTDIR%\..\mingw\bin\mingwm10.dll qtdir\mingw - -rem Copy QT's own translations (Apply/OK, and the like) -copy %QTDIR%\translations\qt_*.qm qtdir\translations -del qtdir\translations\qt_help* - -rem Generate the compiled translations. All of this makes sense only if -rem the you're doing releases strictly -rem copy %QTDIR%\translations\qt_*.ts qtdir\translations -rem lrelease gpsbabel_de.ts -rem lrelease gpsbabel_es.ts -rem lrelease gpsbabel_fr.ts -rem lrelease gpsbabel_hu.ts -rem lrelease gpsbabel_it.ts -rem lrelease gpsbabelfe_de.ts -rem lrelease gpsbabelfe_es.ts -rem lrelease gpsbabelfe_fr.ts -rem lrelease gpsbabelfe_hu.ts -rem lrelease gpsbabelfe_it.ts -rem lrelease gpsbabelfe_ru.ts -rem for /f %%a in (dir /b *.ts) do lrelease %%a - -"c:\Program Files\Inno Setup 5\ISCC.exe" setup.iss - -rem cleanup -rd /q /s qtdir -rem del gpsbabel_*.qm -rem del gpsbabelfe_*.qm diff --git a/gui/runmachine.cc b/gui/runmachine.cc index 80465a5c6..7633a06aa 100644 --- a/gui/runmachine.cc +++ b/gui/runmachine.cc @@ -19,13 +19,12 @@ #include "runmachine.h" -#include // for qDebug -#include // for QEventLoop -#include // for QNonConstOverload -#include // for QOverload, qOverload -#include // for QDialog +#include // for operator<<, QDebug +#include // for QEventLoop +#include // for QueuedConnection +#include // for qDebug -#include "appname.h" // for appName +#include "appname.h" // for appName QString RunMachine::decodeProcessError(QProcess::ProcessError err) @@ -64,8 +63,7 @@ RunMachine::RunMachine(QWidget* parent, std::nullopt, std::nullopt); }, Qt::QueuedConnection); - // TODO: Qt6 combined the obsolete overloaded signal QProcess::finished(int exitCode) - connect(process_, qOverload(&QProcess::finished), + connect(process_, &QProcess::finished, this, [this](int exitCode, QProcess::ExitStatus exitStatus) { execute(processFinished, std::nullopt, diff --git a/gui/runmachine.h b/gui/runmachine.h index ff3104b52..a5330f29e 100644 --- a/gui/runmachine.h +++ b/gui/runmachine.h @@ -20,15 +20,16 @@ #ifndef RUNMACHINE_H #define RUNMACHINE_H -#include // for QObject -#include // for QProcess, QProcess::ExitStatus, QProcess::ProcessError, qt_getEnumName -#include // for QString -#include // for QStringList -#include // for QWidget +#include // for QList +#include // for Q_ENUM, Q_OBJECT, Q_SIGNALS +#include // for QProcess, QProcess::ProcessError, QProcess::ExitStatus +#include // for QString +#include // for QStringList +#include // for QWidget -#include // for optional, nullopt +#include // for optional -#include "processwait.h" // for ProcessWaitDialog +#include "processwait.h" // for ProcessWaitDialog class RunMachine : public QWidget diff --git a/igc.h b/igc.h index 51019a348..ba291d167 100644 --- a/igc.h +++ b/igc.h @@ -83,7 +83,7 @@ class IgcFormat : public Format // Qt5 doesn't have a qHash function for scoped enumerations. // Qt6 falls back to std::hash, but it may not use the seed. - friend qhash_result_t qHash(const igc_ext_type_t& key, qhash_result_t seed = 0) noexcept + friend size_t qHash(const igc_ext_type_t& key, size_t seed = 0) noexcept { return qHash(static_cast::type>(key), seed); } diff --git a/inifile.cc b/inifile.cc index be1e28a70..bae2d49ae 100644 --- a/inifile.cc +++ b/inifile.cc @@ -29,7 +29,7 @@ #include // for QHash #include // for QIODevice::ReadOnly, QIODevice #include // for QTextStream -#include // for qEnvironmentVariable, qPrintable, QT_VERSION, QT_VERSION_CHECK +#include // for qEnvironmentVariable, qPrintable #include #define MYNAME "inifile" @@ -191,11 +191,7 @@ inifile_init(const QString& filename, const char* myname) gpsbabel::File file(name); file.open(QFile::ReadOnly); QTextStream stream(&file); -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - // default for QTextStream::setCodec in Qt5 is QTextCodec::codecForLocale() // default for QTextStream::setEncoding in Qt6 is QStringConverter::Utf8 - stream.setCodec("UTF-8"); -#endif stream.setAutoDetectUnicode(true); auto* result = new inifile_t; diff --git a/main.cc b/main.cc index 21cafdee1..690950b4a 100644 --- a/main.cc +++ b/main.cc @@ -738,12 +738,12 @@ main(int argc, char* argv[]) // MIN_QT_VERSION in GPSBabel.pro should correspond to the QT_VERSION_CHECK // arguments in main.cc and gui/main.cc and the version check in // CMakeLists.txt, gui/CMakeLists.txt. -#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) +#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) #error This version of Qt is not supported. #endif -#if defined(_MSC_VER) && (_MSC_VER < 1910) /* MSVC 2015 or earlier */ -#error MSVC 2015 and earlier are not supported. Please use MSVC 2017 or MSVC 2019. +#if defined(_MSC_VER) && (_MSC_VER < 1920) /* MSVC 2017 or earlier */ +#error MSVC 2017 and earlier are not supported. Please use MSVC 2019 or MSVC 2022. #endif if constexpr (DEBUG_LOCALE) { diff --git a/mkshort.h b/mkshort.h index 8086adfc3..1fe2c02d7 100644 --- a/mkshort.h +++ b/mkshort.h @@ -60,7 +60,7 @@ class MakeShort public: ShortNameKey(const QByteArray& name) : shortname(name) {} /* converting constructor */ - friend qhash_result_t qHash(const ShortNameKey& key, qhash_result_t seed = 0) noexcept + friend size_t qHash(const ShortNameKey& key, size_t seed = 0) noexcept { // We hash all strings as upper case. return qHash(key.shortname.toUpper(), seed); diff --git a/smplrout.cc b/smplrout.cc index 0e5985ec4..77bdcdc1f 100644 --- a/smplrout.cc +++ b/smplrout.cc @@ -209,7 +209,7 @@ void SimplifyRouteFilter::routesimple_head(const route_head* rte) neighborhood goner = errormap.last(); goner.wpt->wpt_flags.marked_for_deletion = 1; // errormap.remove(lastKey()); // with Qt 5.12.12, 5.15.2 results in asan heap-use-after-free errors in build_extra_tests.sh - errormap.erase(std::prev(errormap.end())); // in Qt6 can use cend(). + errormap.erase(std::prev(errormap.cend())); // in Qt6 can use cend(). // wpthash.remove(goner.wpt); // removal not necessary /* recompute neighbors of point marked for deletion. */ diff --git a/src/core/textstream.cc b/src/core/textstream.cc index a4a899ec4..e3a62cdae 100644 --- a/src/core/textstream.cc +++ b/src/core/textstream.cc @@ -18,22 +18,16 @@ */ -#include // for qint64, QT_VERSION, QT_VERSION_CHECK +#include // for qint64 -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #include // for QByteArrayView -#endif #include // for QFile #include // for QFlags #include // for QIODevice -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #include // for QIODeviceBase::OpenMode #include // for QStringConverter, QStringConverter::Utf8, QStringConverter::Encoding, QStringConverter::Utf16 -#endif -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #include // for optional -#endif #include "defs.h" // for fatal, list_codecs #include "src/core/textstream.h" @@ -45,31 +39,6 @@ namespace gpsbabel void TextStream::open(const QString& fname, QIODevice::OpenMode mode, const char* module, const char* codec_name) { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - codec_ = QTextCodec::codecForName(codec_name); - if (codec_ == nullptr) { - list_codecs(); - fatal("%s: Unsupported codec '%s'.\n", module, codec_name); - } - - file_ = new gpsbabel::File(fname); - file_->open(mode); - setDevice(file_); - setCodec(codec_); - - if (mode & QFile::ReadOnly) { - if (codec_->mibEnum() == 106) { // UTF-8 - setAutoDetectUnicode(true); - } - } - - if (mode & QFile::WriteOnly) { - // enable bom for all UTF codecs except UTF-8 - if (codec_->mibEnum() != 106) { - setGenerateByteOrderMark(true); - } - } -#else std::optional encoding = QStringConverter::encodingForName(codec_name); bool use_stringconverter = encoding.has_value(); @@ -116,7 +85,6 @@ void TextStream::open(const QString& fname, QIODevice::OpenMode mode, const char setDevice(device_); setEncoding(QStringConverter::Utf16); } -#endif } void TextStream::close() @@ -127,15 +95,11 @@ void TextStream::close() delete file_; file_ = nullptr; } -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - codec_ = nullptr; -#else if (device_ != nullptr) { device_->close(); delete device_; device_ = nullptr; } -#endif } } // namespace gpsbabel diff --git a/src/core/textstream.h b/src/core/textstream.h index 52aa59667..93f09bbfe 100644 --- a/src/core/textstream.h +++ b/src/core/textstream.h @@ -19,21 +19,13 @@ #ifndef SRC_CORE_TEXTSTREAM_INCLUDED_H_ #define SRC_CORE_TEXTSTREAM_INCLUDED_H_ -#include // for QT_VERSION, QT_VERSION_CHECK #include // for QIODevice -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #include // for QIODeviceBase::OpenMode -#endif #include // for QString -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -#include // for QTextCodec -#endif #include // for QTextStream -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #include "src/core/codecdevice.h" // for CodecDevice -#endif #include "src/core/file.h" // for File @@ -48,11 +40,7 @@ class TextStream : public QTextStream private: gpsbabel::File* file_{nullptr}; -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - QTextCodec* codec_{nullptr}; -#else gpsbabel::CodecDevice* device_{nullptr}; -#endif }; } // namespace gpsbabel diff --git a/tools/Dockerfile_noble b/tools/Dockerfile_noble index 498f1ac39..41065517d 100644 --- a/tools/Dockerfile_noble +++ b/tools/Dockerfile_noble @@ -58,15 +58,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libudev-dev \ && rm -rf /var/lib/apt/lists/* -# pkgs with qt used by gpsbabel -RUN apt-get update && apt-get install -y --no-install-recommends \ - qtbase5-dev \ - qttools5-dev \ - qttranslations5-l10n \ - qtwebengine5-dev \ - libqt5serialport5-dev \ - && rm -rf /var/lib/apt/lists/* - # pkgs with qt used by gpsbabel RUN apt-get update && apt-get install -y --no-install-recommends \ qt6-base-dev \ diff --git a/tools/ci_install_windows.sh b/tools/ci_install_windows.sh index 9c4e379d1..ad8fd5023 100755 --- a/tools/ci_install_windows.sh +++ b/tools/ci_install_windows.sh @@ -18,7 +18,7 @@ function validate() { ) } -QT_VERSION=${1:-5.15.2} +QT_VERSION=${1:-6.5.3} COMPILER=${2:-msvc2019_64} METHOD=${3:-default} diff --git a/tools/ci_setup_windows.ps1 b/tools/ci_setup_windows.ps1 index 73791c747..4c38b28e9 100755 --- a/tools/ci_setup_windows.ps1 +++ b/tools/ci_setup_windows.ps1 @@ -7,7 +7,7 @@ # and https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt Param( - [string] $qtdir = "C:\Qt\Qt5.15.2\5.15.2\msvc2019_64", + [string] $qtdir = "C:\Qt\6.5.3\msvc2019_64", [ValidateSet("x86", "amd64")][string] $arch = "amd64", [ValidateSet("x86", "amd64")][string] $host_arch = "amd64", [string] $vcversion diff --git a/trackfilter.cc b/trackfilter.cc index 708032496..f9ee348f9 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -359,8 +359,8 @@ void TrackFilter::trackfilter_merge() QList buff; - auto it = track_list.begin(); - while (it != track_list.end()) { /* put all points into temp buffer */ + auto it = track_list.cbegin(); + while (it != track_list.cend()) { /* put all points into temp buffer */ route_head* track = *it; // steal all the wpts WaypointList wpts; @@ -377,9 +377,9 @@ void TrackFilter::trackfilter_merge() delete wpt; } } - if (it != track_list.begin()) { + if (it != track_list.cbegin()) { track_del_head(track); - it = track_list.erase(it); + it = static_cast(track_list.erase(it)); } else { ++it; } @@ -714,8 +714,8 @@ void TrackFilter::trackfilter_range() int original_waypt_count = track_waypt_count(); - auto it = track_list.begin(); - while (it != track_list.end()) { + auto it = track_list.cbegin(); + while (it != track_list.cend()) { route_head* track = *it; foreach (Waypoint* wpt, track->waypoint_list) { @@ -739,7 +739,7 @@ void TrackFilter::trackfilter_range() if (track->rte_waypt_empty()) { track_del_head(track); - it = track_list.erase(it); + it = static_cast(track_list.erase(it)); } else { ++it; } diff --git a/xmldoc/chapters/build.xml b/xmldoc/chapters/build.xml index 83434456e..de92ffa54 100644 --- a/xmldoc/chapters/build.xml +++ b/xmldoc/chapters/build.xml @@ -373,8 +373,7 @@ On non-macOS unix builds by default we now compile in the gpsbabel generated translation files, i.e. gpsbabelfe_*.qm, gpsbabel_*.qm, as well as gmapbase.html. When compiled in these files do not need to be distributed. These are used by the GUI. Additional translation files from Qt will also be -used if they are found. They may be in a package such as qttranslations5-l10n -or qt5-qttranslations. +used if they are found. They may be in a package such as qt6-translations-l10n. From a20f47540b9a0d1bf5ab96c4728eca8e0cf70124 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 4 May 2024 10:48:07 -0600 Subject: [PATCH 077/132] clang-tidy readability-isolate-declaration (#1274) --- exif.cc | 4 +++- garmin_fit.cc | 12 +++++++++--- garmin_gpi.cc | 9 ++++++--- garmin_txt.cc | 8 ++++++-- garmin_xt.cc | 15 +++++++++++---- gdb.cc | 9 ++++++--- gpx.cc | 7 ++++++- grtcirc.cc | 13 ++++++++++--- igc.cc | 29 +++++++++++++++++++++-------- kml.cc | 8 ++++++-- lowranceusr.cc | 6 ++++-- nmea.cc | 30 +++++++++++++++++++++++------- osm.cc | 6 ++++-- ozi.cc | 4 +++- parse.cc | 20 ++++++++++++++------ skytraq.cc | 43 +++++++++++++++++++++++++++++++++---------- smplrout.cc | 3 ++- text.cc | 3 ++- tpg.cc | 3 ++- trackfilter.cc | 6 ++++-- unicsv.cc | 17 ++++++++++++----- xcsv.cc | 9 ++++++--- 22 files changed, 193 insertions(+), 71 deletions(-) diff --git a/exif.cc b/exif.cc index 6521cbb64..14d194865 100644 --- a/exif.cc +++ b/exif.cc @@ -579,7 +579,9 @@ void ExifFormat::exif_read_app(ExifApp* app) { gbsize_t offs; - uint32_t exif_ifd_ofs, gps_ifd_ofs, inter_ifd_ofs; + uint32_t exif_ifd_ofs; + uint32_t gps_ifd_ofs; + uint32_t inter_ifd_ofs; ExifIfd* ifd; gbfile* fin = app->fexif; diff --git a/garmin_fit.cc b/garmin_fit.cc index 3982216f8..a5fac1185 100644 --- a/garmin_fit.cc +++ b/garmin_fit.cc @@ -1151,7 +1151,8 @@ GarminFitFormat::fit_collect_track_tlr(const route_head* rte) // Recalculate odometer_distance for the whole track unless already // (properly, i.e. monotonically increasing) set double dist_sum = 0; - double prev_lat = 999, prev_lon = 999; + double prev_lat = 999; + double prev_lon = 999; double max_speed = 0; gpsbabel::DateTime prev_time; for (auto& crpt: course) { @@ -1216,8 +1217,13 @@ GarminFitFormat::fit_collect_track_tlr(const route_head* rte) } // Use current time as creation time if we have nothing better - gpsbabel::DateTime track_date_time, track_end_date_time, creation_time; - double first_lat = 999, first_lon = 999, last_lat = 999, last_lon = 999; + gpsbabel::DateTime track_date_time; + gpsbabel::DateTime track_end_date_time; + gpsbabel::DateTime creation_time; + double first_lat = 999; + double first_lon = 999; + double last_lat = 999; + double last_lon = 999; if (!course.empty()) { track_date_time = creation_time = course.front().creation_time; track_end_date_time = course.back().creation_time; diff --git a/garmin_gpi.cc b/garmin_gpi.cc index 3877de63c..745f68c2f 100644 --- a/garmin_gpi.cc +++ b/garmin_gpi.cc @@ -159,7 +159,8 @@ GarminGPIFormat::gpi_read_string(const char* field) const void GarminGPIFormat::read_header() { - int len, i; + int len; + int i; i = gbfgetint32(fin); if (i != 0) { @@ -1053,9 +1054,11 @@ GarminGPIFormat::enum_waypt_cb(const Waypoint* ref) const void GarminGPIFormat::load_bitmap_from_file(const char* fname, const unsigned char** data, int* data_sz) { - int i, sz; + int i; + int sz; int dest_bpp; - int src_line_sz, dest_line_sz; + int src_line_sz; + int dest_line_sz; bmp_header_t src_h; gpi_bitmap_header_t* dest_h; unsigned char* ptr; diff --git a/garmin_txt.cc b/garmin_txt.cc index 81f5d1b59..db0db9a84 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -193,9 +193,13 @@ void GarminTxtFormat::print_position(const Waypoint* wpt) { int valid = 1; - double lat, lon, north, east; + double lat; + double lon; + double north; + double east; int zone; - char map[3], zonec; + char map[3]; + char zonec; convert_datum(wpt, &lat, &lon); diff --git a/garmin_xt.cc b/garmin_xt.cc index a0f4cc48e..6f96b2b13 100644 --- a/garmin_xt.cc +++ b/garmin_xt.cc @@ -64,7 +64,10 @@ GarminXTFormat::format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_ { int method = 0; uint8_t spam = 0; - int32_t TrackMaxLat = 0, TrackMaxLon = 0, TrackMinLat = 0, TrackMinLon = 0; + int32_t TrackMaxLat = 0; + int32_t TrackMaxLon = 0; + int32_t TrackMinLat = 0; + int32_t TrackMinLon = 0; char trk_name[30]=""; // TODO: SHIFT - can't test behaviour, do not have appropriate files //int ii; @@ -205,9 +208,13 @@ GarminXTFormat::format_garmin_xt_proc_strk() int Count = 0; // Used to obtain number of read bytes int TracksCompleted = 0; // Number of processed tracks uint8_t TrackBlock[STRK_BLOCK_SIZE]; // File Block - double Lat = 0, Lon = 0; // wpt data - double PrevLat = 0, PrevLon = 0, PrevEle = 0; // wpt data - uint32_t Time = 0, PrevTime = 0; // wpt data + double Lat = 0; + double Lon = 0; // wpt data + double PrevLat = 0; + double PrevLon = 0; + double PrevEle = 0; // wpt data + uint32_t Time = 0; + uint32_t PrevTime = 0; // wpt data uint8_t trk_color = 0xff; // Skip 12 bytes from the BOF diff --git a/gdb.cc b/gdb.cc index db3bec6a5..47f0d072a 100644 --- a/gdb.cc +++ b/gdb.cc @@ -992,7 +992,8 @@ GdbFormat::read() char typ; gt_waypt_classes_e wpt_class; Waypoint* wpt; - route_head* trk, *rte; + route_head* trk; + route_head* rte; int len = FREAD_i32; if (FREAD(&typ, 1) < 1) { @@ -1182,7 +1183,8 @@ GdbFormat::write_waypoint( const Waypoint* wpt, const QString& shortname, const garmin_fs_t* gmsd, const int icon, const int display) { - char zbuf[32], ffbuf[32]; + char zbuf[32]; + char ffbuf[32]; waypt_ct++; /* increase informational number of written waypoints */ @@ -1335,7 +1337,8 @@ void GdbFormat::write_route(const route_head* rte, const QString& rte_name) { bounds bounds; - char zbuf[32], ffbuf[32]; + char zbuf[32]; + char ffbuf[32]; memset(zbuf, 0, sizeof(zbuf)); memset(ffbuf, 0xFF, sizeof(ffbuf)); diff --git a/gpx.cc b/gpx.cc index 04e3e408b..45430bdb5 100644 --- a/gpx.cc +++ b/gpx.cc @@ -505,7 +505,12 @@ xml_parse_time(const QString& dateTimeString) *pointstr = '\0'; } - int year = 0, mon = 1, mday = 1, hour = 0, min = 0, sec = 0; + int year = 0; + int mon = 1; + int mday = 1; + int hour = 0; + int min = 0; + int sec = 0; gpsbabel::DateTime dt; int res = sscanf(timestr, "%d-%d-%dT%d:%d:%d", &year, &mon, &mday, &hour, &min, &sec); diff --git a/grtcirc.cc b/grtcirc.cc index 52a002cf4..94ea141f9 100644 --- a/grtcirc.cc +++ b/grtcirc.cc @@ -134,9 +134,16 @@ double linedistprj(double lat1, double lon1, static double _lon1 = -9999; static double _lon2 = -9999; - static double x1, y1, z1; - static double x2, y2, z2; - static double xa, ya, za, la; + static double x1; + static double y1; + static double z1; + static double x2; + static double y2; + static double z2; + static double xa; + static double ya; + static double za; + static double la; double dot; diff --git a/igc.cc b/igc.cc index 817f527a1..23b026470 100644 --- a/igc.cc +++ b/igc.cc @@ -128,9 +128,14 @@ void IgcFormat::rd_deinit() */ void IgcFormat::TaskRecordReader::igc_task_rec(const char* rec) { - unsigned int lat_deg, lat_min, lat_frac; - unsigned int lon_deg, lon_min, lon_frac; - char lat_hemi[2], lon_hemi[2]; + unsigned int lat_deg; + unsigned int lat_min; + unsigned int lat_frac; + unsigned int lon_deg; + unsigned int lon_min; + unsigned int lon_frac; + char lat_hemi[2]; + char lon_hemi[2]; char tmp_str[kMaxRecLen]; // First task record identifies the task to follow @@ -234,14 +239,22 @@ void IgcFormat::TaskRecordReader::igc_task_rec(const char* rec) void IgcFormat::read() { char* ibuf; - int hours, mins, secs; - unsigned int lat_deg, lat_min, lat_frac; - unsigned int lon_deg, lon_min, lon_frac; - char lat_hemi[2], lon_hemi[2]; + int hours; + int mins; + int secs; + unsigned int lat_deg; + unsigned int lat_min; + unsigned int lat_frac; + unsigned int lon_deg; + unsigned int lon_min; + unsigned int lon_frac; + char lat_hemi[2]; + char lon_hemi[2]; char validity; route_head* pres_head = nullptr; route_head* gnss_head = nullptr; - int pres_alt, gnss_alt; + int pres_alt; + int gnss_alt; char pres_valid = 0; char gnss_valid = 0; Waypoint* pres_wpt = nullptr; diff --git a/kml.cc b/kml.cc index d7e9c826b..db5bfbd75 100644 --- a/kml.cc +++ b/kml.cc @@ -199,7 +199,9 @@ void KmlFormat::wpt_ts_end(const QString& args, const QXmlStreamAttributes* /*at void KmlFormat::wpt_coord(const QString& args, const QXmlStreamAttributes* /*attrs*/) { - double lat, lon, alt; + double lat; + double lon; + double alt; if (! wpt_tmp) { return; } @@ -345,7 +347,9 @@ void KmlFormat::gx_trk_coord(const QString& args, const QXmlStreamAttributes* /* fatal(MYNAME ": gx_trk_coord: invalid kml file\n"); } - double lat, lon, alt; + double lat; + double lon; + double alt; int n = sscanf(CSTR(args), "%lf %lf %lf", &lon, &lat, &alt); if (EOF != n && 2 != n && 3 != n) { fatal(MYNAME ": coord field decode failure on \"%s\".\n", qPrintable(args)); diff --git a/lowranceusr.cc b/lowranceusr.cc index 37201990f..c264a7956 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -1260,7 +1260,8 @@ LowranceusrFormat::read() void LowranceusrFormat::lowranceusr_waypt_disp(const Waypoint* wpt) const { - int SymbolId, alt; + int SymbolId; + int alt; int Lat = lat_deg_to_mm(wpt->latitude); int Lon = lon_deg_to_mm(wpt->longitude); @@ -1410,7 +1411,8 @@ LowranceusrFormat::lowranceusr4_waypt_disp(const Waypoint* wpt) it means */ gbfputint32(2, file_out); - int SymbolId, ColorId; + int SymbolId; + int ColorId; if (!wpt->gc_data->get_icon().isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) { if (writing_version == 4) { SymbolId = lowranceusr4_find_icon_number_from_desc(wpt->icon_descr); diff --git a/nmea.cc b/nmea.cc index 84129cd0a..e4087aa21 100644 --- a/nmea.cc +++ b/nmea.cc @@ -192,7 +192,9 @@ NmeaFormat::nmea_add_wpt(Waypoint* wpt, route_head* trk) const // transferred to either the global_waypoint_list or global_track_list. wpt->extra_data = nullptr; if (datum != kDautmWGS84) { - double lat, lon, alt; + double lat; + double lon; + double alt; GPS_Math_Known_Datum_To_WGS84_M( wpt->latitude, wpt->longitude, 0, &lat, &lon, &alt, datum); @@ -669,7 +671,9 @@ NmeaFormat::gpgsa_parse(const QString& ibuf) const if (nfields > cnt + 3) prn[cnt] = fields[cnt + 3].toInt(); } - float pdop = 0, hdop = 0, vdop = 0; + float pdop = 0; + float hdop = 0; + float vdop = 0; if (nfields > 15) pdop = fields[15].toFloat(); if (nfields > 16) hdop = fields[16].toFloat(); if (nfields > 17) vdop = fields[17].toFloat(); @@ -732,12 +736,24 @@ double NmeaFormat::pcmpt_deg(int d) void NmeaFormat::pcmpt_parse(const char* ibuf) { - int i, j1, j2, j3, j4, j5, j6; - int lat, lon; - char altflag, u1, u2; - float alt, f1, f2; + int i; + int j1; + int j2; + int j3; + int j4; + int j5; + int j6; + int lat; + int lon; + char altflag; + char u1; + char u2; + float alt; + float f1; + float f2; char coords[20] = {0}; - int dmy, hms; + int dmy; + int hms; dmy = hms = 0; diff --git a/osm.cc b/osm.cc index 298f0b07c..f24f0ee49 100644 --- a/osm.cc +++ b/osm.cc @@ -459,7 +459,8 @@ OsmFormat::osm_node(const QString& /*unused*/, const QXmlStreamAttributes* attrv void OsmFormat::osm_node_tag(const QString& /*unused*/, const QXmlStreamAttributes* attrv) { - QString key, value; + QString key; + QString value; signed char ikey; if (attrv->hasAttribute("k")) { @@ -539,7 +540,8 @@ OsmFormat::osm_way_nd(const QString& /*unused*/, const QXmlStreamAttributes* att void OsmFormat::osm_way_tag(const QString& /*unused*/, const QXmlStreamAttributes* attrv) { - QString key, value; + QString key; + QString value; signed char ikey; if (attrv->hasAttribute("k")) { diff --git a/ozi.cc b/ozi.cc index d1ab73aa9..8b981c4da 100644 --- a/ozi.cc +++ b/ozi.cc @@ -127,7 +127,9 @@ void OziFormat::ozi_convert_datum(Waypoint* wpt) const { if (datum != kDautmWGS84) { - double lat, lon, alt; + double lat; + double lon; + double alt; GPS_Math_Known_Datum_To_WGS84_M(wpt->latitude, wpt->longitude, 0.0, &lat, &lon, &alt, datum); wpt->latitude = lat; diff --git a/parse.cc b/parse.cc index e589e5079..c1cb6b2ea 100644 --- a/parse.cc +++ b/parse.cc @@ -160,16 +160,23 @@ int parse_coordinates(const char* str, int datum, const grid_type grid, double* latitude, double* longitude, const char* module) { - double lat, lon; - unsigned char lathemi=0, lonhemi=0; - int deg_lat, deg_lon, min_lat, min_lon; + double lat; + double lon; + unsigned char lathemi=0; + unsigned char lonhemi=0; + int deg_lat; + int deg_lon; + int min_lat; + int min_lon; char map[3]; int utmz; - double utme, utmn; + double utme; + double utmn; char utmc; int result; int ct; - double lx, ly; + double lx; + double ly; const char* format; int valid = 1; @@ -236,7 +243,8 @@ parse_coordinates(const char* str, int datum, const grid_type grid, break; case grid_swiss: { - double east, north; + double east; + double north; datum = kDautmWGS84; /* fix */ format = "%lf %lf%n"; diff --git a/skytraq.cc b/skytraq.cc index eca79199c..180547cbd 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -209,7 +209,9 @@ int SkytraqBase::skytraq_rd_msg(void* payload, unsigned int len) const { int errors = 5; // Allow this many receiver errors silently. - unsigned int c, i, state; + unsigned int c; + unsigned int i; + unsigned int state; signed int rcv_len; // Negative length is read error. for (i = 0, state = 0; i < RETRIES && state < sizeof(MSG_START); i++) { @@ -417,7 +419,10 @@ SkytraqBase::skytraq_configure_logging() const { // an0008-1.4.14: logs if // (dt > tmin & dd >= dmin & v >= vmin) | dt > tmax | dd > dmax | v > vmax - unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000; + unsigned int tmin=6; + unsigned int tmax=3600; + unsigned int dmin=0; + unsigned int dmax=10000; static uint8_t MSG_LOG_CONFIGURE_CONTROL[] = { 0x18, // message_id 0x00, 0x00, 0x0e, 0x10, // max_time: was 0x0000ffff (big endian!) @@ -768,7 +773,8 @@ SkytraqBase::process_data_item(read_state* pst, const item_frame* pitem, int len int /* returns number of bytes processed (terminates on 0xFF i.e. empty or padding bytes) */ SkytraqBase::process_data_sector(read_state* pst, const uint8_t* buf, int len) const { - int plen, ilen; + int plen; + int ilen; for (plen = 0; plen < len && buf[plen] != 0xFF; plen += ilen) { ilen = process_data_item(pst, reinterpret_cast(&buf[plen]), len-plen); @@ -787,7 +793,10 @@ SkytraqBase::skytraq_read_single_sector(unsigned int sector, uint8_t* buf) const { uint8_t MSG_LOG_SECTOR_READ_CONTROL[2] = { 0x1B, (uint8_t)(sector) }; int errors = 5; /* allow this many errors */ - unsigned int c, i, j, cs; + unsigned int c; + unsigned int i; + unsigned int j; + unsigned int cs; uint8_t buffer[16]; if (sector > 0xFF) { @@ -926,8 +935,15 @@ SkytraqBase::skytraq_read_tracks() const { read_state st; uint32_t log_wr_ptr; - uint16_t sectors_free, sectors_total, /*sectors_used_a, sectors_used_b,*/ sectors_used; - int t, rc, got_sectors, total_sectors_read = 0; + uint16_t sectors_free; + uint16_t sectors_total; + /* uint16_t sectors_used_a; */ + /* uint16_t sectors_used_b; */ + uint16_t sectors_used; + int t; + int rc; + int got_sectors; + int total_sectors_read = 0; int read_at_once = MAX(xstrtoi(opt_read_at_once, nullptr, 10), 1); int opt_first_sector_val = xstrtoi(opt_first_sector, nullptr, 10); int opt_last_sector_val = xstrtoi(opt_last_sector, nullptr, 10); @@ -1142,7 +1158,8 @@ SkytraqBase::skytraq_erase() const void SkytraqBase::skytraq_set_location() const { - double lat, lng; + double lat; + double lng; uint8_t MSG_SET_LOCATION[17] = { 0x36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t MSG_GET_LOCATION = 0x35; @@ -1320,7 +1337,9 @@ void MinihomerFormat::miniHomer_get_poi() const { uint8_t MSG_GET_POI[3] = { 0x4D, 0, 0}; uint8_t buf[32]; - double lat, lng, alt; + double lat; + double lng; + double alt; for (unsigned int poi = 0; poi>8)&0xff; @@ -1368,8 +1387,12 @@ int MinihomerFormat::miniHomer_set_poi(uint16_t poinum, const char* opt_poi) con 0, 0, 0, 0, 0, 0, 0, 0, //alt (double ecef) 0 // attr (u8, 1-> to flash, 0->ro sram) }; - double lat, lng, alt; - double ecef_x, ecef_y, ecef_z; + double lat; + double lng; + double alt; + double ecef_x; + double ecef_y; + double ecef_z; int result = 0; // result will be 0 if opt_poi isn't set diff --git a/smplrout.cc b/smplrout.cc index 77bdcdc1f..5570991d7 100644 --- a/smplrout.cc +++ b/smplrout.cc @@ -119,7 +119,8 @@ double SimplifyRouteFilter::compute_track_error(const neighborhood& nb) const (wpt1->GetCreationTime() != wpt2->GetCreationTime())) { double frac = static_cast(wpt1->GetCreationTime().msecsTo(wpt3->GetCreationTime())) / static_cast(wpt1->GetCreationTime().msecsTo(wpt2->GetCreationTime())); - double reslat, reslon; + double reslat; + double reslon; linepart(wpt1->latitude, wpt1->longitude, wpt2->latitude, wpt2->longitude, frac, &reslat, &reslon); diff --git a/text.cc b/text.cc index 46533eaa8..e288303d4 100644 --- a/text.cc +++ b/text.cc @@ -68,7 +68,8 @@ void TextFormat::text_disp(const Waypoint* wpt) { int32_t utmz; - double utme, utmn; + double utme; + double utmn; char utmzc; waypoint_count++; diff --git a/tpg.cc b/tpg.cc index 5b21552e3..3fde1c2b7 100644 --- a/tpg.cc +++ b/tpg.cc @@ -160,7 +160,8 @@ TpgFormat::read() void TpgFormat::tpg_waypt_pr(const Waypoint* wpt) { - double lon, lat; + double lon; + double lat; double amt; char ocount; QString shortname; diff --git a/trackfilter.cc b/trackfilter.cc index f9ee348f9..bcb7b77d0 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -309,7 +309,8 @@ void TrackFilter::trackfilter_title() void TrackFilter::trackfilter_pack() { if (!track_list.isEmpty()) { - int i, j; + int i; + int j; for (i = 1, j = 0; i < track_list.size(); i++, j++) { auto prev_last_time = trackfilter_get_last_time(track_list.at(j)); @@ -702,7 +703,8 @@ QDateTime TrackFilter::trackfilter_range_check(const char* timestr) void TrackFilter::trackfilter_range() { - QDateTime start, stop; // constructed such that isValid() is false, unlike gpsbabel::DateTime! + QDateTime start; // constructed such that isValid() is false, unlike gpsbabel::DateTime! + QDateTime stop; // constructed such that isValid() is false, unlike gpsbabel::DateTime! if (opt_start != nullptr) { start = trackfilter_range_check(opt_start); diff --git a/unicsv.cc b/unicsv.cc index 040908078..934df3866 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -227,7 +227,9 @@ UnicsvFormat::unicsv_parse_gc_code(const QString& str) QDate UnicsvFormat::unicsv_parse_date(const char* str, int* consumed) { - int p1, p2, p3; + int p1; + int p2; + int p3; char sep[2]; std::tm tm{}; int lconsumed = 0; @@ -1260,7 +1262,9 @@ UnicsvFormat::unicsv_waypt_enum_cb(const Waypoint* wpt) void UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) { - double lat, lon, alt; + double lat; + double lon; + double alt; const Geocache* gc_data = nullptr; unicsv_waypt_ct++; @@ -1300,7 +1304,8 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) case grid_bng: { char map[3]; - double north, east; + double north; + double east; if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map)) { unicsv_fatal_outside(wpt); @@ -1315,7 +1320,8 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) case grid_utm: { int zone; char zonec; - double north, east; + double north; + double east; if (! GPS_Math_Known_Datum_To_UTM_EN(lat, lon, &east, &north, &zone, &zonec, unicsv_datum_idx)) { @@ -1328,7 +1334,8 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) break; } case grid_swiss: { - double north, east; + double north; + double east; if (! GPS_Math_WGS84_To_Swiss_EN(wpt->latitude, wpt->longitude, &east, &north)) { unicsv_fatal_outside(wpt); diff --git a/xcsv.cc b/xcsv.cc index 747660622..f42a4effa 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -986,9 +986,11 @@ void XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) { QString buff; - double latitude, longitude; + double latitude; + double longitude; int32_t utmz; - double utme, utmn; + double utme; + double utmn; char utmzc; if (oldlon < 900) { @@ -1223,7 +1225,8 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) /* SPECIAL COORDINATES */ case XcsvStyle::XT_MAP_EN_BNG: { char map[3]; - double north, east; + double north; + double east; if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map)) fatal(MYNAME ": Position (%.5f/%.5f) outside of BNG.\n", wpt->latitude, wpt->longitude); From 55e449417497a841cb4a31690bbe58c4cb3c3cf3 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 4 May 2024 11:53:36 -0600 Subject: [PATCH 078/132] clang-tidy modernize-loop-convert (#1275) --- duplicate.cc | 3 +-- shape.cc | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/duplicate.cc b/duplicate.cc index 552b23faf..32378b319 100644 --- a/duplicate.cc +++ b/duplicate.cc @@ -73,8 +73,7 @@ void DuplicateFilter::process() wptfirst->latitude = wptlast->latitude; wptfirst->longitude = wptlast->longitude; } - for (auto it = values.cbegin(); it != values.cend(); ++it) { - Waypoint* wpt = *it; + for (Waypoint* wpt : values) { if (purge_duplicates || (wpt != wptfirst)) { wpt->wpt_flags.marked_for_deletion = 1; } diff --git a/shape.cc b/shape.cc index 42cbe1e57..19af063af 100644 --- a/shape.cc +++ b/shape.cc @@ -220,15 +220,15 @@ ShapeFormat::read() nameidx = -2; const QStringList opt_name_fields = qopt_name.split('+', Qt::SkipEmptyParts); nameindices.reserve(opt_name_fields.size()); - for (int oidx=0; oidx Date: Sat, 4 May 2024 15:39:21 -0600 Subject: [PATCH 079/132] tidy readability-convert-member-functions-to-static (#1276) --- googletakeout.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletakeout.h b/googletakeout.h index fcfe55aac..4754366ca 100644 --- a/googletakeout.h +++ b/googletakeout.h @@ -123,7 +123,7 @@ class GoogleTakeoutFormat : public Format static void takeout_fatal(const QString& message); static void takeout_warning(const QString& message); - Waypoint* takeout_waypoint(int lat_e7, int lon_e7, const QString* shortname, const QString* description, const QString* start_str); + static Waypoint* takeout_waypoint(int lat_e7, int lon_e7, const QString* shortname, const QString* description, const QString* start_str); static bool track_maybe_add_wpt(route_head* route, Waypoint* waypoint); static void title_case(QString& title); void add_place_visit(const QJsonObject& placeVisit); From 15d3d22d85faf595e4ae05e34dc6b598c6637277 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sun, 5 May 2024 16:36:31 -0600 Subject: [PATCH 080/132] add Qt's webengine translations to package. (#1277) --- gui/package_app | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gui/package_app b/gui/package_app index 4b1588bf9..55e7db779 100755 --- a/gui/package_app +++ b/gui/package_app @@ -7,17 +7,18 @@ function convert_qt_translations() { # Combine the Qt translation files we use into local qt_??.qm files. # -# It is recommended to combine Qts .qm files, this script does that for +# It is recommended to combine Qt's .qm files, this script does that for # linux and macos, windeployqt does this for windows. -# https://doc.qt.io/qt-5/linguist-programmers.html#deploying-translations +# https://doc.qt.io/qt-6/localization.html#deploy-translations # -# This script is created from the log of the windows build from windeployqt -# with Qt 5.12.1. +# This script is created from the log of the windows build +# with Qt 6.5.3 using windeployqt with the --verbose 2 option. # From the log you can see which translation files are used which depends on # which Qt modules we use. -# In our case these are qtbase_*.qm, qtdeclarative_*qm and qtserialport_*.qm. +# In our case these are qtbase_*.qm, qtdeclarative_*qm and qtserialport_*.qm, +# and qtwebengine_*.qm. # -# Note with Qt5 the Qt distributed qt_xx.qm files are metacatalogs, and just +# Note with Qt6 the Qt distributed qt_xx.qm files are metacatalogs, and just # copying or converting them won't copy the dependencies. if [ "${machine}" = "Mac" ]; then @@ -50,6 +51,7 @@ function convert_qt_translations() inputs+=("qtbase_${language}.qm") if [ -e "qtdeclarative_${language}.qm" ]; then inputs+=("qtdeclarative_${language}.qm"); fi if [ -e "qtserialport_${language}.qm" ]; then inputs+=("qtserialport_${language}.qm"); fi + if [ -e "qtwebengine_${language}.qm" ]; then inputs+=("qtwebengine_${language}.qm"); fi "${LCONVERT}" -o "${LANGDIR}/qt_${language}.qm" "${inputs[@]}" if [ "${machine}" = "Mac" ]; then From 1b396b5b1b08a3f68d7171c1f4dbfef7c27022e6 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 20 May 2024 08:12:52 -0600 Subject: [PATCH 081/132] fix xcsv RECORD_DELIMITER CR. (#1282) --- xcsv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcsv.cc b/xcsv.cc index f42a4effa..b655b1087 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -167,7 +167,7 @@ const QHash XcsvStyle::xcsv_char_table { { "COLON", ":" }, { "SEMICOLON", ";" }, { "NEWLINE", "\n" }, - { "CR", "\n" }, + { "CR", "\r" }, { "CRNEWLINE", "\r\n" }, { "TAB", "\t" }, { "SPACE", " " }, From ed07a180a0781e49ac033ba59e4930abfa3747b3 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 23 May 2024 09:55:06 -0600 Subject: [PATCH 082/132] refactor interface to jeeps pvt related commands. (#1283) --- garmin.cc | 2 +- jeeps/gpsapp.cc | 19 +++++++++---------- jeeps/gpsapp.h | 4 ++-- jeeps/gpscom.cc | 11 +++++------ jeeps/gpscom.h | 4 ++-- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/garmin.cc b/garmin.cc index ce6fa3207..5c1b8c0ef 100644 --- a/garmin.cc +++ b/garmin.cc @@ -657,7 +657,7 @@ GarminFormat::rd_position(posn_status* posn_status) auto* wpt = new Waypoint; GPS_PPvt_Data pvt = GPS_Pvt_New(); - if (GPS_Command_Pvt_Get(&pvt_fd, &pvt)) { + if (GPS_Command_Pvt_Get(pvt_fd, &pvt)) { pvt2wpt(pvt, wpt); GPS_Pvt_Del(&pvt); diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index 43312fe37..5a091e874 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -361,7 +361,7 @@ static int32_t GPS_A000(const char* port) carry_on: /* Make sure PVT is off as some GPS' have it on by default */ if (gps_pvt_transfer != -1) { - GPS_A800_Off(port,&fd); + GPS_A800_Off(fd); } if (!GPS_Device_Off(fd)) { @@ -6126,12 +6126,11 @@ int32_t GPS_A800_On(const char* port, gpsdevh** fd) ** ** Turn off GPS PVT ** -** @param [r] port [const char *] port -** @param [w] fd [int32 *] file descriptor +** @param [r] fd [int32] file descriptor ** ** @return [int32] success ************************************************************************/ -int32_t GPS_A800_Off(const char* /*unused*/, gpsdevh** fd) +int32_t GPS_A800_Off(gpsdevh* fd) { static UC data[2]; GPS_Packet tra; @@ -6142,10 +6141,10 @@ int32_t GPS_A800_Off(const char* /*unused*/, gpsdevh** fd) COMMAND_ID[gps_device_command].Cmnd_Stop_Pvt_Data); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, data,2); - if (!GPS_Write_Packet(*fd,tra)) { + if (!GPS_Write_Packet(fd,tra)) { return gps_errno; } - if (!GPS_Get_Ack(*fd, &tra, &rec)) { + if (!GPS_Get_Ack(fd, &tra, &rec)) { GPS_Error("A800_Off: Not acknowledged"); return FRAMING_ERROR; } @@ -6162,22 +6161,22 @@ int32_t GPS_A800_Off(const char* /*unused*/, gpsdevh** fd) ** ** make a position packet for sending to the GPS ** -** @param [r] fd [int32 *] file descriptor +** @param [r] fd [int32] file descriptor ** @param [w] packet [GPS_PPvt_Data *] packet ** ** @return [int32] success ************************************************************************/ -int32_t GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet) +int32_t GPS_A800_Get(gpsdevh* fd, GPS_PPvt_Data* packet) { GPS_Packet tra; GPS_Packet rec; - if (!GPS_Packet_Read(*fd, &rec)) { + if (!GPS_Packet_Read(fd, &rec)) { return gps_errno; } - if (!GPS_Send_Ack(*fd, &tra, &rec)) { + if (!GPS_Send_Ack(fd, &tra, &rec)) { return gps_errno; } diff --git a/jeeps/gpsapp.h b/jeeps/gpsapp.h index 52d4ee52f..f06289e99 100644 --- a/jeeps/gpsapp.h +++ b/jeeps/gpsapp.h @@ -51,8 +51,8 @@ void GPS_D700_Get(const GPS_Packet& packet, double* lat, double* lon); void GPS_D700_Send(GPS_Packet& packet, double lat, double lon); int32_t GPS_A800_On(const char* port, gpsdevh** fd); -int32_t GPS_A800_Off(const char* port, gpsdevh** fd); -int32_t GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet); +int32_t GPS_A800_Off(gpsdevh* fd); +int32_t GPS_A800_Get(gpsdevh* fd, GPS_PPvt_Data* packet); void GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt); int32_t GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb); diff --git a/jeeps/gpscom.cc b/jeeps/gpscom.cc index f6fe19e07..afa1239f5 100644 --- a/jeeps/gpscom.cc +++ b/jeeps/gpscom.cc @@ -580,13 +580,12 @@ int32_t GPS_Command_Pvt_On(const char* port, gpsdevh** fd) ** ** Instruct GPS to stop sending Pvt data every second ** -** @param [r] port [const char *] serial port -** @param [w] fd [int32 *] file descriptor +** @param [r] fd [int32] file descriptor ** ** @return [int32] success ************************************************************************/ -int32_t GPS_Command_Pvt_Off(const char* port, gpsdevh** fd) +int32_t GPS_Command_Pvt_Off(gpsdevh* fd) { int32_t ret = 0; @@ -597,7 +596,7 @@ int32_t GPS_Command_Pvt_Off(const char* port, gpsdevh** fd) switch (gps_pvt_transfer) { case pA800: - ret = GPS_A800_Off(port,fd); + ret = GPS_A800_Off(fd); break; default: GPS_Error("Pvt_Off: Unknown position protocol"); @@ -613,13 +612,13 @@ int32_t GPS_Command_Pvt_Off(const char* port, gpsdevh** fd) ** ** Get a single PVT info entry ** -** @param [w] fd [int32 *] file descriptor +** @param [r] fd [int32] file descriptor ** @param [w] pvt [GPS_PPvt_Data *] pvt data structure to fill ** ** @return [int32] success ************************************************************************/ -int32_t GPS_Command_Pvt_Get(gpsdevh** fd, GPS_PPvt_Data* pvt) +int32_t GPS_Command_Pvt_Get(gpsdevh* fd, GPS_PPvt_Data* pvt) { int32_t ret = 0; diff --git a/jeeps/gpscom.h b/jeeps/gpscom.h index bb34cb81f..fa1fc0900 100644 --- a/jeeps/gpscom.h +++ b/jeeps/gpscom.h @@ -14,8 +14,8 @@ int32_t GPS_Command_Get_Position(const char* port, double* lat, double* lon); int32_t GPS_Command_Send_Position(const char* port, double lat, double lon); int32_t GPS_Command_Pvt_On(const char* port, gpsdevh** fd); -int32_t GPS_Command_Pvt_Off(const char* port, gpsdevh** fd); -int32_t GPS_Command_Pvt_Get(gpsdevh** fd, GPS_PPvt_Data* pvt); +int32_t GPS_Command_Pvt_Off(gpsdevh* fd); +int32_t GPS_Command_Pvt_Get(gpsdevh* fd, GPS_PPvt_Data* pvt); int32_t GPS_Command_Get_Almanac(const char* port, GPS_PAlmanac** alm); int32_t GPS_Command_Send_Almanac(const char* port, GPS_PAlmanac* alm, int32_t n); From 44ceb477b0459cf9df2a19269636f2ee45d94e3b Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:41:10 -0600 Subject: [PATCH 083/132] update macos release to Qt 6.5.3 (#1284) --- .github/workflows/macos.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 23b05ca83..25cfb7d89 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -23,21 +23,21 @@ jobs: GENERATOR: 'Ninja' RELEASE: false os: macos-12 - - QT_VERSION: '6.2.4' - XCODE_VERSION: '14.3.1' - GENERATOR: 'Xcode' - RELEASE: false - os: macos-13 - QT_VERSION: '6.2.4' XCODE_VERSION: '14.3.1' GENERATOR: 'Ninja' - RELEASE: true + RELEASE: false os: macos-13 - QT_VERSION: '6.5.3' - XCODE_VERSION: '15.3' - GENERATOR: 'Ninja' + XCODE_VERSION: '15.4' + GENERATOR: 'Xcode' RELEASE: false os: macos-14 + - QT_VERSION: '6.5.3' + XCODE_VERSION: '15.4' + GENERATOR: 'Ninja' + RELEASE: true + os: macos-14 steps: - name: Checkout repository From f7781343f0a542110c8834422067836d87bc6ad4 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:54:29 -0600 Subject: [PATCH 084/132] delete obsolete jeeps functions that were never used (#1285) since introduction in 2002. --- jeeps/gpsutil.cc | 83 ------------------------------------------------ 1 file changed, 83 deletions(-) diff --git a/jeeps/gpsutil.cc b/jeeps/gpsutil.cc index 2628badb7..9da4a9b1d 100644 --- a/jeeps/gpsutil.cc +++ b/jeeps/gpsutil.cc @@ -24,7 +24,6 @@ #include "jeeps/gps.h" #include #include -#include static int32_t gps_endian_called = 0; static int32_t GPS_Little = 0; @@ -358,88 +357,6 @@ void GPS_Util_Put_Float(UC* s, const float v) return; } -#if 0 -/* @func GPS_Util_Canon **************************************************** -** -** Sets or unsets canonical mode -** NB: Must have called this with True before calling with False -** NB: Remember to trun it off (false) eventually -** -** @param [r] state [int32] state=true->raw state=false->normal -** @return [void] -** @@ -****************************************************************************/ - -void GPS_Util_Canon(int32 state) -{ - static struct termios tty; - static struct termios sv; - - - if (state) { - tcgetattr(1,&sv); - tcgetattr(1, &tty); - tty.c_cc[VMIN]='\1'; - tty.c_cc[VTIME]='\0'; - tcsetattr(1,TCSANOW,&tty); - tty.c_lflag &= ~(ICANON | ECHO); - tcsetattr(1, TCSANOW, &tty); - } else { - tcsetattr(1, TCSANOW, &sv); - } - - return; -} -#endif - -#if 0 -/* @func GPS_Util_Block **************************************************** -** -** Sets or unsets blocking -** @modified 13-01-2000 to return an int -** -** @param [r] fd [int32] file descriptor -** @param [r] state [int32] state=true->block state=false->non-block -** -** @return [int32] success -** @@ -****************************************************************************/ - -int32 GPS_Util_Block(int32 fd, int32 state) -{ - static int32 notcalled=1; - static int32 block; - static int32 noblock; - int32 f; - - gps_errno = HARDWARE_ERROR; - - if (notcalled) { - notcalled = 0; - if ((f=fcntl(fd,F_GETFL,0))==-1) { - GPS_Error("Util_Block: FCNTL error"); - return 0; - } - block = f & ~O_NDELAY; - noblock = f | O_NDELAY; - } - - if (state) { - if (fcntl(fd,F_SETFL,block)==-1) { - GPS_Error("Util_Block: Error blocking"); - return 0; - } - } else { - if (fcntl(fd,F_SETFL,noblock)==-1) { - GPS_Error("Util_Block: Error unblocking"); - return 0; - } - } - - return 1; -} -#endif - /* @func GPS_Warning ******************************************************** ** From 00c23a133da89924b3b746260cadafcc8d2a9d20 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 29 Jun 2024 12:49:56 -0600 Subject: [PATCH 085/132] Fix unicsv reader delimiter detection (#1287) * Fix unicsv reader delimiter detection. Any delimiter sequence that is enclosed has never been considered a delimiter when splitting a line into fields. However, previously an enclosed potential delimiter could be detected when scanning the first line, and then erroneously used as the delimiter. * tweak auto * add unicsv delimiter detection test --- csv_util.cc | 9 +++++++- csv_util.h | 3 ++- reference/unidelim.csv | 2 ++ reference/unidelim.gpx | 10 +++++++++ testo.d/unicsv.test | 5 +++++ unicsv.cc | 43 ++++++++++++++++++++++++++------------- unicsv.h | 3 ++- xmldoc/formats/unicsv.xml | 10 ++++++--- 8 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 reference/unidelim.csv create mode 100644 reference/unidelim.gpx diff --git a/csv_util.cc b/csv_util.cc index 1a7ad8420..0fde1d128 100644 --- a/csv_util.cc +++ b/csv_util.cc @@ -148,7 +148,8 @@ csv_dequote(const QString& string, const QString& enclosure) /*****************************************************************************/ QStringList csv_linesplit(const QString& string, const QString& delimited_by, - const QString& enclosed_in, const int line_no, CsvQuoteMethod method) + const QString& enclosed_in, const int line_no, CsvQuoteMethod method, + bool* delimiter_detected) { QStringList retval; @@ -162,6 +163,7 @@ csv_linesplit(const QString& string, const QString& delimited_by, * whitespace eater consume the space. */ QString delimiter = delimited_by; + bool delimiter_seen = false; if (delimited_by == ", ") { delimiter = ","; } @@ -194,8 +196,10 @@ csv_linesplit(const QString& string, const QString& delimited_by, if (!enclosed) { if ((dlen > 0) && string.mid(p).startsWith(delimiter)) { dfound = true; + delimiter_seen = true; } else if (hyper_whitespace_delimiter && string.at(p).isSpace()) { dfound = true; + delimiter_seen = true; while ((p < string.size()) && string.at(p).isSpace()) { p++; } @@ -235,6 +239,9 @@ csv_linesplit(const QString& string, const QString& delimited_by, retval.append(value); } + if (delimiter_detected != nullptr) { + *delimiter_detected = delimiter_seen; + } return retval; } /*****************************************************************************/ diff --git a/csv_util.h b/csv_util.h index 149b4ff00..3a9f96185 100644 --- a/csv_util.h +++ b/csv_util.h @@ -43,7 +43,8 @@ enum class CsvQuoteMethod {historic, rfc4180}; QStringList csv_linesplit(const QString& string, const QString& delimited_by, - const QString& enclosed_in, int line_no, CsvQuoteMethod method = CsvQuoteMethod::historic); + const QString& enclosed_in, int line_no, CsvQuoteMethod method = CsvQuoteMethod::historic, + bool* delimiter_detected = nullptr); int dec_to_intdeg(double d); diff --git a/reference/unidelim.csv b/reference/unidelim.csv new file mode 100644 index 000000000..370084bd5 --- /dev/null +++ b/reference/unidelim.csv @@ -0,0 +1,2 @@ +lat,lon,"foo; bar;","bam wham",name,desc,"zoom|zap",notes +41.90270080,12.49623520,this,that,"Roma, 🇮🇹","my ""roam'n"" holiday",the other thing,fun diff --git a/reference/unidelim.gpx b/reference/unidelim.gpx new file mode 100644 index 000000000..b5812dd96 --- /dev/null +++ b/reference/unidelim.gpx @@ -0,0 +1,10 @@ + + + + + + Roma, 🇮🇹 + my "roam'n" holiday + fun + + diff --git a/testo.d/unicsv.test b/testo.d/unicsv.test index 6c31bba94..99bfdc681 100644 --- a/testo.d/unicsv.test +++ b/testo.d/unicsv.test @@ -54,3 +54,8 @@ gpsbabel -i unicsv -f ${REFERENCE}/pretty_degree.csv -o unicsv,grid=1 -F ${TMPDI compare ${REFERENCE}/pretty_degree1.csv ${TMPDIR}/pretty_degree1.csv gpsbabel -i unicsv -f ${REFERENCE}/pretty_degree.csv -o unicsv,grid=2 -F ${TMPDIR}/pretty_degree2.csv compare ${REFERENCE}/pretty_degree2.csv ${TMPDIR}/pretty_degree2.csv + +# delimiter detection +gpsbabel -i unicsv -f ${REFERENCE}/unidelim.csv -o gpx -F ${TMPDIR}/unidelim.gpx +compare ${REFERENCE}/unidelim.gpx ${TMPDIR}/unidelim.gpx + diff --git a/unicsv.cc b/unicsv.cc index 934df3866..642af6262 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -385,19 +385,27 @@ void UnicsvFormat::unicsv_fondle_header(QString header) { /* Convert the entire header to lower case for convenience. - * If we see a tab in that header, we decree it to be tabsep. */ - unicsv_fieldsep = ","; - if (header.contains('\t')) { - unicsv_fieldsep = "\t"; - } else if (header.contains(';')) { - unicsv_fieldsep = ";"; - } else if (header.contains('|')) { - unicsv_fieldsep = "|"; - } header = header.toLower(); - const QStringList values = csv_linesplit(header, unicsv_fieldsep, "\"", 0, CsvQuoteMethod::rfc4180); + /* Find the separator and split the line into fields. + * If we see an unenclosd tab that is the separator. + * Otherwise, if we see an unenclosed semicolon that is the separator. + * Otherwise, if we see an unenclosed vertical bar that is the separator. + * Otherwise the separator is a comma. + */ + const QList delimiters = {"\t", ";", "|", ","}; + unicsv_fieldsep = delimiters.last(); + QStringList values; + bool delimiter_detected; + for (const auto* delimiter : delimiters) { + values = csv_linesplit(header, delimiter, kUnicsvQuoteChar, unicsv_lineno, CsvQuoteMethod::rfc4180, &delimiter_detected); + if (delimiter_detected) { + unicsv_fieldsep = delimiter; + break; + } + } + for (auto value : values) { value = value.trimmed(); @@ -411,8 +419,12 @@ UnicsvFormat::unicsv_fondle_header(QString header) } f++; } - if ((f->name.isEmpty()) && global_opts.debug_level) { - warning(MYNAME ": Unhandled column \"%s\".\n", qPrintable(value)); + if (global_opts.debug_level) { + if ((f->name.isEmpty()) && global_opts.debug_level) { + warning(MYNAME ": Unhandled column \"%s\".\n", qPrintable(value)); + } else { + warning(MYNAME ": Interpreting column \"%s\" as %s(%d).\n", qPrintable(value), qPrintable(f->name), f->type); + } } /* handle some special items */ @@ -456,10 +468,12 @@ UnicsvFormat::rd_init(const QString& fname) fin = new gpsbabel::TextStream; fin->open(fname, QIODevice::ReadOnly, MYNAME, opt_codec); + unicsv_lineno = 0; if (opt_fields) { QString fields = QString(opt_fields).replace("+", ","); unicsv_fondle_header(fields); - } else if (buff = fin->readLine(), !buff.isNull()) { + } else if (buff = fin->readLine(); !buff.isNull()) { + ++unicsv_lineno; unicsv_fondle_header(buff); } else { unicsv_fieldsep = nullptr; @@ -508,7 +522,7 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) wpt->longitude = kUnicsvUnknown; int column = -1; - const QStringList values = csv_linesplit(ibuf, unicsv_fieldsep, "\"", 0, CsvQuoteMethod::rfc4180); + const QStringList values = csv_linesplit(ibuf, unicsv_fieldsep, kUnicsvQuoteChar, unicsv_lineno, CsvQuoteMethod::rfc4180); for (auto value : values) { if (++column >= unicsv_fields_tab.size()) { break; /* ignore extra fields on line */ @@ -1060,6 +1074,7 @@ UnicsvFormat::read() } while ((buff = fin->readLine(), !buff.isNull())) { + ++unicsv_lineno; buff = buff.trimmed(); if (buff.isEmpty() || buff.startsWith('#')) { continue; diff --git a/unicsv.h b/unicsv.h index a8c86664e..a775e4729 100644 --- a/unicsv.h +++ b/unicsv.h @@ -148,7 +148,7 @@ class UnicsvFormat : public Format /* Constants */ - /* "UNICSV_FIELD_SEP" and "UNICSV_LINE_SEP" are only used by the writer */ + /* "kUnicsvFieldSep" and "kUnicsvLineSep" are only used by the writer */ static constexpr const char* kUnicsvFieldSep = ","; static constexpr const char* kUnicsvLineSep = "\r\n"; @@ -189,6 +189,7 @@ class UnicsvFormat : public Format double unicsv_depthscale{}; double unicsv_proximityscale{}; const char* unicsv_fieldsep{nullptr}; + int unicsv_lineno{0}; gpsbabel::TextStream* fin{nullptr}; gpsbabel::TextStream* fout{nullptr}; gpsdata_type unicsv_data_type{unknown_gpsdata}; diff --git a/xmldoc/formats/unicsv.xml b/xmldoc/formats/unicsv.xml index 297a81a98..d75579c74 100644 --- a/xmldoc/formats/unicsv.xml +++ b/xmldoc/formats/unicsv.xml @@ -4,9 +4,13 @@ figure out what data it has and writes headers and all the data it can. - If the first line contains any tabs, the data lines are assumed - to be tab separated. Otherwise the fields are assumed to be - separated by commas. + Fields may be enclosed in double quotes. To include a double quote inside quotes escape it with another double quote. + + + If the first line contains any unenclosed tabs then the data lines are assumed to be tab separated. + Otherwise if the first line contains any unenclosed semicolons then fields are assumed to be separated by semicolons. + Otherwise if the first line contains any unenclosed vertical bars then fields are assumed to be separated by vertical bars. + Otherwise the fields are assumed to be separated by commas. The list of keywords include: From c0b578786a78019f0a289633ab61b5f248662971 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 29 Jun 2024 13:17:01 -0600 Subject: [PATCH 086/132] exclude qt .ts files from codacy analysis. (#1288) they confuse eslint which thinks they are TypeScript. --- .codacy.yaml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.codacy.yaml b/.codacy.yaml index 478781d09..dcd2f4f7f 100644 --- a/.codacy.yaml +++ b/.codacy.yaml @@ -1,12 +1,14 @@ exclude_paths: - - 'deprecated/**' - - 'mac/libusb/**' - - 'reference/**' - - 'shapelib/**' - - 'strptime/**' - - 'zlib/**' - - coverity_model.cc - - jeeps/gpsproj.cc - - jeeps/gpsproj.h - - tools/qtci/README.md - - tools/uploadtool/README.md + - "coverity_model.cc" + - "deprecated/**" + - "gui/coretool/gpsbabel_*.ts" + - "gui/gpsbabelfe_*.ts" + - "jeeps/gpsproj.cc" + - "jeeps/gpsproj.h" + - "mac/libusb/**" + - "reference/**" + - "shapelib/**" + - "strptime/**" + - "tools/qtci/README.md" + - "tools/uploadtool/README.md" + - "zlib/**" From 563410ff1491f2e47d79d7bf9ef9fa5bd5f28b2c Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:11:02 -0600 Subject: [PATCH 087/132] remove qtci installer code (#1289) * remove qtci which hasn't been used for a long time. * remove another obsolete qtci file. * remove another qtci reference. * delete obsolete travis build code. * rename osx install script * catch ci up with osx travis install script renames. * remove obsolete debug code from qtio installer. --- .codacy.yaml | 1 - .github/workflows/macos.yml | 4 +- tools/Dockerfile_qtio | 116 -------- .../{travis_install_osx => ci_install_osx.sh} | 20 +- tools/ci_install_windows.sh | 16 +- tools/make_docker_qtio_image | 39 --- tools/qtci/LICENSE | 201 -------------- tools/qtci/README.gpsbabel | 1 - tools/qtci/README.md | 164 ----------- tools/qtci/extract-qt-installer | 109 -------- tools/qtci/find_qt_installer | 24 -- tools/qtci/install-qt | 62 ----- tools/qtci/install-qt-online | 62 ----- tools/qtci/qt-install.qs | 256 ------------------ tools/travis_install_linux_coverage | 47 ---- tools/travis_install_linux_local | 64 ----- 16 files changed, 7 insertions(+), 1179 deletions(-) delete mode 100644 tools/Dockerfile_qtio rename tools/{travis_install_osx => ci_install_osx.sh} (73%) delete mode 100755 tools/make_docker_qtio_image delete mode 100644 tools/qtci/LICENSE delete mode 100644 tools/qtci/README.gpsbabel delete mode 100644 tools/qtci/README.md delete mode 100755 tools/qtci/extract-qt-installer delete mode 100755 tools/qtci/find_qt_installer delete mode 100755 tools/qtci/install-qt delete mode 100755 tools/qtci/install-qt-online delete mode 100644 tools/qtci/qt-install.qs delete mode 100755 tools/travis_install_linux_coverage delete mode 100755 tools/travis_install_linux_local diff --git a/.codacy.yaml b/.codacy.yaml index dcd2f4f7f..e55144484 100644 --- a/.codacy.yaml +++ b/.codacy.yaml @@ -9,6 +9,5 @@ exclude_paths: - "reference/**" - "shapelib/**" - "strptime/**" - - "tools/qtci/README.md" - "tools/uploadtool/README.md" - "zlib/**" diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 25cfb7d89..7a143ac06 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -59,9 +59,9 @@ jobs: - name: Qt install if: steps.cache.outputs.cache-hit != 'true' env: - TRAVIS_BUILD_DIR: ${{ github.workspace }} + CI_BUILD_DIR: ${{ github.workspace }} run: | - ./tools/travis_install_osx ${{ matrix.QT_VERSION }} aqt + ./tools/ci_install_osx.sh ${{ matrix.QT_VERSION }} aqt - name: Brew install if: matrix.GENERATOR == 'Ninja' diff --git a/tools/Dockerfile_qtio b/tools/Dockerfile_qtio deleted file mode 100644 index a06f758e2..000000000 --- a/tools/Dockerfile_qtio +++ /dev/null @@ -1,116 +0,0 @@ -# this file is used to build the image gpsbabel_build_environment used by travis. - -FROM ubuntu:bionic as qt_install_prep -WORKDIR /app - -# update environment. -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends \ - apt-utils \ - && apt-get upgrade -y \ - && rm -rf /var/lib/apt/lists/* - -# install packages needed to install Qt -RUN apt-get update && apt-get install -y --no-install-recommends \ - libdbus-1-3 \ - libfreetype6 \ - libfontconfig1 \ - libx11-6 \ - libx11-xcb1 \ - libxext6 \ - libxkbcommon0 \ - libxkbcommon-x11-0 \ - libxrender1 \ - ca-cacert \ - wget \ - && rm -rf /var/lib/apt/lists/* - -FROM qt_install_prep as qt_install -# basic build and test tools -ARG INSTALLER -ARG QT_CI_PACKAGES -ARG QT_VERSION -COPY ./extract-qt-installer ./qt-install.qs ./$INSTALLER /app/ -RUN ./extract-qt-installer $INSTALLER /opt/Qt \ - && rm ./extract-qt-installer ./qt-install.qs ./$INSTALLER \ - && echo "export PATH=/opt/Qt/$QT_VERSION/gcc_64/bin:$PATH" > /opt/qt-$QT_VERSION.env - -FROM ubuntu:bionic -LABEL maintainer="https://github.com/tsteven4" -WORKDIR /app -ARG QT_VERSION - -# update environment. -# bionic needs a newer git than provided by ubuntu:bionic -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends \ - apt-utils \ - software-properties-common \ - && apt-get upgrade -y \ - && add-apt-repository ppa:git-core/ppa \ - && rm -rf /var/lib/apt/lists/* - -# install packages needed for gpsbabel build -# split into multiple commands to limit layer size - -# basic build and test tools -RUN apt-get update && apt-get install -y --no-install-recommends \ - g++ \ - make \ - autoconf \ - git \ - valgrind \ - expat \ - libxml2-utils \ - bear \ - cmake \ - ninja-build \ - && rm -rf /var/lib/apt/lists/* - -# alternative compiler -RUN apt-get update && apt-get install -y --no-install-recommends \ - clang \ - && rm -rf /var/lib/apt/lists/* - -# pkgs needed to build document -RUN apt-get update && apt-get install -y --no-install-recommends \ - fop \ - xsltproc \ - docbook-xml \ - docbook-xsl \ - && rm -rf /var/lib/apt/lists/* - -# pkgs with libraries needed by gpsbabel -RUN apt-get update && apt-get install -y --no-install-recommends \ - libusb-1.0-0-dev \ - pkg-config \ - libudev-dev \ - && rm -rf /var/lib/apt/lists/* - -# dependencies of Qt -RUN apt-get update && apt-get install -y --no-install-recommends \ - libglib2.0-0 \ - libx11-xcb-dev \ - libglu1-mesa-dev \ - libasound2 \ - libxcomposite1 \ - libxcursor1 \ - && rm -rf /var/lib/apt/lists/* - -# Qt -COPY --from=qt_install /opt/qt-$QT_VERSION.env /opt/qtio.env -COPY --from=qt_install /opt/Qt/$QT_VERSION /opt/Qt/$QT_VERSION -COPY --from=qt_install /opt/Qt/Licenses /opt/Qt/Licenses - -# pkgs needed to generate coverage report: -RUN apt-get update && apt-get install -y --no-install-recommends \ - gcovr \ - && rm -rf /var/lib/apt/lists/* - -# install environment for locale test -RUN apt-get update && apt-get install -y --no-install-recommends \ - locales \ - && rm -rf /var/lib/apt/lists/* \ - && sed -i 's/^# *\(en_US ISO-8859-1\)/\1/' /etc/locale.gen \ - && locale-gen \ - && locale -a diff --git a/tools/travis_install_osx b/tools/ci_install_osx.sh similarity index 73% rename from tools/travis_install_osx rename to tools/ci_install_osx.sh index 643e4c929..c3a438406 100755 --- a/tools/travis_install_osx +++ b/tools/ci_install_osx.sh @@ -9,8 +9,6 @@ function version_ge() { test "$(printf "%s\n%s" "$1" "$2" | sort -rV | head -n 1 function debug() { cat "${CACHEDIR}/qt-${QT_VERSION}.env" find "${CACHEDIR}" -maxdepth 3 -ls - cat "${CACHEDIR}/Qt/InstallationLog.txt" - cat "${CACHEDIR}/Qt/components.xml" echo "$1" >&2 exit 1 } @@ -47,16 +45,6 @@ fi if [ -d "${QTDIR}/bin" ]; then echo "Using cached Qt." - echo "If you need to clear the cache see" - echo "https://docs.travis-ci.com/user/caching/#Fetching-and-storing-caches." - if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then - # the cache is being used. modify it to reset expiration date. - date > "${CACHEDIR}/timestamp" - fi - if [ -f "${CACHEDIR}/timestamp" ]; then - echo -n "Cache timestamp: " - cat "${CACHEDIR}/timestamp" - fi else rm -fr "${CACHEDIR}" mkdir -p "${CACHEDIR}" @@ -85,13 +73,11 @@ else ) elif [ "$METHOD" = "aqt" ]; then pip3 install aqtinstall>=2.0.0 - "${TRAVIS_BUILD_DIR}/tools/ci_install_qt.sh" mac "${QT_VERSION}" clang_64 "${CACHEDIR}/Qt" + "${CI_BUILD_DIR}/tools/ci_install_qt.sh" mac "${QT_VERSION}" clang_64 "${CACHEDIR}/Qt" echo "export PATH=${QTDIR}/bin:\$PATH" > "${CACHEDIR}/qt-${QT_VERSION}.env" else - # install-qt creates the install at $PWD/Qt. - QT_VERSION_SHORT=${QT_VERSION//./} - QT_CI_PACKAGES=qt.qt5.${QT_VERSION_SHORT}.clang_64,qt.qt5.${QT_VERSION_SHORT}.qtwebengine QT_CI_DOWNLOADER="wget -nv -c" PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt "${QT_VERSION}" - rm "${CACHEDIR}"/qt-opensource*.dmg + echo "ERROR: unknown installation method ${METHOD}." >&2 + exit 1 fi popd validate diff --git a/tools/ci_install_windows.sh b/tools/ci_install_windows.sh index ad8fd5023..1f2cad96c 100755 --- a/tools/ci_install_windows.sh +++ b/tools/ci_install_windows.sh @@ -49,20 +49,8 @@ else "${CI_BUILD_DIR}/tools/ci_install_qt.sh" windows "${QT_VERSION}" "${PACKAGE_SUFFIX}" "${CACHEDIR}/Qt" echo "export PATH=${QTDIR}/bin:\$PATH" > "${CACHEDIR}/qt.env" else - QT_VERSION_SHORT=${QT_VERSION//./} - QT_VERSION_MAJMIN=${QT_VERSION%.*} - curl -s -L -o "qt-opensource-windows-x86-${QT_VERSION}.exe" "https://download.qt.io/official_releases/qt/${QT_VERSION_MAJMIN}/${QT_VERSION}/qt-opensource-windows-x86-${QT_VERSION}.exe" - ls -l ./*.exe - netsh advfirewall firewall add rule name=dummyupqt dir=out action=block program="$(cygpath -w "${PWD}/qt-opensource-windows-x86-${QT_VERSION}.exe")" - "${PWD}/qt-opensource-windows-x86-${QT_VERSION}.exe" --verbose --script "${CI_BUILD_DIR}/tools/qtci/qt-install.qs" QTCI_OUTPUT="${CACHEDIR}/Qt" QTCI_PACKAGES="qt.qt5.${QT_VERSION_SHORT}.${PACKAGE_SUFFIX},qt.qt5.${QT_VERSION_SHORT}.qtwebengine" - netsh advfirewall firewall delete rule name=dummyupqt - rm "qt-opensource-windows-x86-${QT_VERSION}.exe" - ls "${CACHEDIR}/Qt" - rm -fr "${CACHEDIR}/Qt/Docs" - rm -fr "${CACHEDIR}/Qt/Examples" - rm -fr "${CACHEDIR}/Qt/Tools" - rm -f "${CACHEDIR}/Qt/MaintenanceTool.*" - echo "export PATH=${QTDIR}/bin:\$PATH" > "${CACHEDIR}/qt.env" + echo "ERROR: unknown installation method ${METHOD}." >&2 + exit 1 fi fi validate diff --git a/tools/make_docker_qtio_image b/tools/make_docker_qtio_image deleted file mode 100755 index fb1f73cb4..000000000 --- a/tools/make_docker_qtio_image +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -ex -# you must be logged into docker for the push to succeed. - -#versuffix=${1:+_$1} # tag name must be lower case -versuffix=_qtio -tag=$(date -u +%Y%m%dT%H%M%SZ) - -QT_VERSION=5.15.2 -QT_VERSION_SHORT=${QT_VERSION//./} -QT_CI_PACKAGES="qt.qt5.${QT_VERSION_SHORT}.gcc_64,qt.qt5.${QT_VERSION_SHORT}.qtwebengine" -DOWNLOAD_URL=$(./qtci/find_qt_installer ${QT_VERSION}) -INSTALLER=$(basename $DOWNLOAD_URL) -TMPDIR=$(mktemp -d) - -cp Dockerfile${versuffix} $TMPDIR -cp ./qtci/extract-qt-installer ./qtci/qt-install.qs $TMPDIR -wget -nv -c -N -P $TMPDIR ${DOWNLOAD_URL} - -docker build --pull --file Dockerfile${versuffix} \ - --target qt_install_prep \ - $TMPDIR -docker build --pull --file Dockerfile${versuffix} \ - --network none \ - --build-arg INSTALLER=${INSTALLER} \ - --build-arg QT_CI_PACKAGES=${QT_CI_PACKAGES} \ - --build-arg QT_VERSION=${QT_VERSION} \ - --target qt_install \ - $TMPDIR -docker build --pull --file Dockerfile${versuffix} \ - --build-arg INSTALLER=${INSTALLER} \ - --build-arg QT_CI_PACKAGES=${QT_CI_PACKAGES} \ - --build-arg QT_VERSION=${QT_VERSION} \ - --tag tsteven4/gpsbabel_build_environment${versuffix}:latest \ - --tag tsteven4/gpsbabel_build_environment${versuffix}:$tag \ - $TMPDIR -/bin/rm -fr $TMPDIR -docker push tsteven4/gpsbabel_build_environment${versuffix}:$tag -docker push tsteven4/gpsbabel_build_environment${versuffix}:latest -docker image ls diff --git a/tools/qtci/LICENSE b/tools/qtci/LICENSE deleted file mode 100644 index 8dada3eda..000000000 --- a/tools/qtci/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/qtci/README.gpsbabel b/tools/qtci/README.gpsbabel deleted file mode 100644 index 614c5bd8d..000000000 --- a/tools/qtci/README.gpsbabel +++ /dev/null @@ -1 +0,0 @@ -The files extract-qt-installer, install-qt, qt-install.qs, LICENSE, and README.md are from https://github.com/benlau/qtci diff --git a/tools/qtci/README.md b/tools/qtci/README.md deleted file mode 100644 index d1a7df644..000000000 --- a/tools/qtci/README.md +++ /dev/null @@ -1,164 +0,0 @@ -# QT-CI -This project collects a set of script for building Qt application for Android/iOS in command line environment. - -[![Build Status](https://travis-ci.org/benlau/qtci.svg?branch=master)](https://travis-ci.org/benlau/qtci) - -Check [.travis.yml](https://github.com/benlau/qtci/blob/master/.travis.yml) to see how it works. -It will demonstrate how to build an apk file using QT-CI scripts. - -Installation -============ - -Since this project is a collection of scripts, and the script in the bin folder does not have any dependence on each other. -It is not necessary to clone/download the whole repository into your build environment. -You may simply copy the script you need from this repository. - -**recipes/install-qt** - -To automatically install Qt, you can just download 2 scripts and grant them permission for execution. - -"recipes/install-qt" -"bin/extract-qt-installer" - -Then just run script "recipes/install-qt" with the desired version of Qt -Example: - - bash install-qt 5.9.4 - -Enviroument variables -===================== - -QT_CI_PACKAGES - packages to install. You can check available packages if set VERBOSE to 1. - -Example: - - export VERBOSE=1 - export QT_CI_PACKAGES=qt,qt.594,qt.594.gcc_64,qt.594.doc.qtvirtualkeyboard - -Setup -===== - - git clone https://github.com/benlau/qtci.git - - source qtci/path.env #Add qtci/bin and qtci/recipes to $PATH - - -Script -====== - -**(1) bin/extract-qt-installer** --------------------------------- - -Usage - -``` - extract-qt-installer [--disable-progress-report] qt-installer output_path - extract-qt-installer --list-packages qt-installer -``` - -Extract Qt from the installer to the target path (for Qt 5.5 or above). If --list-packages is given, it will show the available packages from the installer and terminate immediately. - -Example: - - extract-qt-installer qt-opensource-linux-x64-android-5.5.1.run ~/Qt - -**Remarks: The installation path must be absolute path** - -Environment Variables - - VERBOSE [Optional] Set to "true" will enable VERBOSE output - QT_CI_PACKAGES [Optional] Select the components to be installed instead of using default (eg. QT_CI_PACKAGES="qt.59.gcc_64") - QT_CI_LOGIN [Optional] The login name - QT_CI_PASSWORD [Optional] The password of login - -The arguments and environment required could be different due to the installer changes. Check the recipes folder or the wiki of known issues to find out the correct setting. - -**(2) bin/extract-ifw** --------------------------------- - -Extract installer of "Qt installer framework" to the target path - -Example: - - extract-ifw qt-installer-framework-opensource-1.5.0-x64.run ~/QtIfw - -**(3) bin/install-android-sdk** --------------------------------- - -Download and install Android SDK - -Example: - - install-android-sdk platform-tool,build-tools-20.0.0,android-19 - -**(4) bin/build-android-gradle-project** --------------------------------- - -Build a Qt Android project and sign the APK - -Usage: - - build-android-gradle-project project.pro - -Required Environment Variables - - QT_HOME [Required] The home directory of installed Qt. (e.g., ~/Qt/5.7) - KEYSTORE [Optional] The location of keystore. If it is set, it will be used to sign the created apk - KEYALIAS [Optional] The alias of the keystore - KEYPASS [Optional] The password of keystore. - ANDROID_TARGET_SDK_VERSION [Optional] Target Android SDK version. The default value is "19" - -(5) bin/increase-android-version-code --------------------------------- - -Usage - - increase-android-version-code AndroidManifest.xml - -Given an AndroidManifest.xml file, it will increase the value of the versionCode field by one. - -(6) bin/run-unittests ----------------------- - -Usage - - run-unittests project.pro - -Build and run a unit test project in the current folder. If qpm.json were found, it would call `qpm install` first. - -Recipes -======= - - -In the folder "recipes", it contains a set of script that could download and install specific Qt toolchains for a different environment. (Include Android) - -Please feel free to modify and submit a new recipe. - -Example - - apt-get install openjdk-8-jdk p7zip - - source path.env #Add $PWD/bin and $PWD/recipes to $PATH - - #Change to the installation path - - qt-5.5.1-android-19 # Install Qt 5.5.1 and Android SDK - - source qt-5.5.1-android-19.env # Add installed Qt path to $PATH - - -Reference -========= - - 1. [Continuous distribution for Qt applications on desktop and mobile](http://www.slidedeck.io/lasconic/qtci-qtcon2016) - 1. [Andrew's Articles - Continuous deployment for Qt applications](http://andrewdolby.com/articles/2016/continuous-deployment-for-qt-applications/) - -Related Projects -================= - - 1. [benlau/quickpromise](https://github.com/benlau/quickpromise) - Promise library for QML - 2. [benlau/quickcross](https://github.com/benlau/quickcross) - QML Cross Platform Utility Library - 3. [benlau/qsyncable](https://github.com/benlau/qsyncable) - Synchronize data between models - 4. [benlau/testable](https://github.com/benlau/testable) - QML Unit Test Utilities - 5. [benlau/quickflux](https://github.com/benlau/quickflux) - Message Dispatcher / Queue for Qt/QML - 6. [benlau/biginteger](https://github.com/benlau/biginteger) - QML BigInteger library diff --git a/tools/qtci/extract-qt-installer b/tools/qtci/extract-qt-installer deleted file mode 100755 index 073302bdc..000000000 --- a/tools/qtci/extract-qt-installer +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash -# QT-CI Project -# License: Apache-2.0 -# https://github.com/benlau/qtci - -function usage() { - echo "Usage:" - echo "extract-qt-installer qt-installer output_path" - echo "extract-qt-installer --list-packages qt-installer" - exit -1 -} - -LIST_PACKAGES=0 - -getopt --test > /dev/null 2>&1 -GETOPT_RET_CODE=$? - -set -e #quit on error - -if [ "$GETOPT_RET_CODE" != "4" ] -then - echo "Warning: gnu-getopt is not installed. Long parameter like '--list-package' will not be working. Please install gnu-getopt by 'brew install gnu-getopt'" -else - - OPTS=`getopt -o l --long list-packages --long disable-progress-report -n "extract-qt-installer" -- "$@"` - - eval set -- "$OPTS" - - while true - do - case "$1" in - --list-packages) - LIST_PACKAGES=1 - shift;; - --disable-progress-report) - DISABLE_PROGRESS_REPORT=1 - shift;; - --) shift;break;; - *) shift;; - esac - done -fi - - -export PATH=$PATH:$PWD -export WORKDIR=$PWD -INSTALLER=$1 -OUTPUT=$2 -SCRIPT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/qt-install.qs -PACKAGES=$QT_CI_PACKAGES - -if [ $LIST_PACKAGES -gt 0 ] -then - - if [ $# -lt 1 ] - then - usage - fi - - OUTPUT="/tmp/Qt" - -else - - if [ $# -lt 2 ] - then - usage - fi - - if [[ ! "${OUTPUT:0:1}" = "/" ]] - then - echo output path must be an absolute path - exit -1 - fi - -fi - - -chmod u+x $1 -if [ -n "$QT_CI_DEBUG" ] -then - $INSTALLER -v --script $SCRIPT QTCI_LIST_PACKAGES="$LIST_PACKAGES" QTCI_PACKAGES="$PACKAGES" QTCI_OUTPUT="$OUTPUT" | grep "\(QTCI\|operation\)" - exit 0 -fi - -unset DISPLAY - -# platform minimal doesn't work on macos 10.14, 10.15. It did work on 10.13. -# https://bugreports.qt.io/browse/QTIFW-1471 -PLATFORM="--platform minimal" -if [ "$(uname)" = "Darwin" ]; then - vn=$(sw_vers -productVersion | cut -d. -f2,2) - if [ $vn -ge 14 ]; then - unset PLATFORM - fi -fi - -if [ -n "$DISABLE_PROGRESS_REPORT" ] -then - $INSTALLER $PLATFORM --script $SCRIPT QTCI_LIST_PACKAGES="$LIST_PACKAGES" QTCI_PACKAGES="$PACKAGES" QTCI_OUTPUT="$OUTPUT" -else - if [ -n "$VERBOSE" ] - then - $INSTALLER --verbose $PLATFORM --script $SCRIPT QTCI_LIST_PACKAGES="$LIST_PACKAGES" QTCI_PACKAGES="$PACKAGES" QTCI_OUTPUT="$OUTPUT" - else - $INSTALLER --verbose $PLATFORM --script $SCRIPT QTCI_LIST_PACKAGES="$LIST_PACKAGES" QTCI_PACKAGES="$PACKAGES" QTCI_OUTPUT="$OUTPUT" | grep "\(QTCI\|operation\)" - fi -fi - - diff --git a/tools/qtci/find_qt_installer b/tools/qtci/find_qt_installer deleted file mode 100755 index d1b5486fd..000000000 --- a/tools/qtci/find_qt_installer +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -e -# Reference: -# https://github.com/musescore/MuseScore/blob/master/build/travis/job_macos/install.sh - -QT_VERSION=${1:-5.12.0} - -QT_MAJOR_VERSION=$(echo ${QT_VERSION} | cut -d "." -f 1) -QT_MINOR_VERSION=$(echo ${QT_VERSION} | cut -d "." -f 2) -if [ "$(uname)" = "Darwin" ]; then - if { [ "${QT_MAJOR_VERSION}" -eq 5 ] && [ "${QT_MINOR_VERSION}" -ge 9 ]; } || [ "${QT_MAJOR_VERSION}" -ge 6 ]; then - # this was good from 5.9.0 through at least 5.12.0 - DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-mac-x64-${QT_VERSION}.dmg - else - # this was good from 5.2.1 through 5.8.0 - DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-mac-x64-clang-${QT_VERSION}.dmg - fi -elif [ "$(uname)" = "Linux" ]; then - # this was good from 5.2.1 through at least 5.12.0 - DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-linux-x64-${QT_VERSION}.run -else - echo "Unsupported system." >&2 - exit 1 -fi -echo $DOWNLOAD_URL diff --git a/tools/qtci/install-qt b/tools/qtci/install-qt deleted file mode 100755 index 1b1f4f328..000000000 --- a/tools/qtci/install-qt +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -e -# Reference: -# https://github.com/musescore/MuseScore/blob/master/build/travis/job_macos/install.sh - -QT_VERSION=${1:-5.12.0} -QT_TARGET_CATALOG=${2:-$PWD} -QT_CI_DOWNLOADER=${QT_CI_DOWNLOADER:-"wget -c -N"} - -QT_MAJOR_VERSION=$(echo ${QT_VERSION} | cut -d "." -f 1) -QT_MINOR_VERSION=$(echo ${QT_VERSION} | cut -d "." -f 2) -if [ "$(uname)" = "Darwin" ]; then - if { [ "${QT_MAJOR_VERSION}" -eq 5 ] && [ "${QT_MINOR_VERSION}" -ge 9 ]; } || [ "${QT_MAJOR_VERSION}" -ge 6 ]; then - # this was good from 5.9.0 through at least 5.12.0 - DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-mac-x64-${QT_VERSION}.dmg - else - # this was good from 5.2.1 through 5.8.0 - DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-mac-x64-clang-${QT_VERSION}.dmg - fi - COMPILER=clang_64 -elif [ "$(uname)" = "Linux" ]; then - # this was good from 5.2.1 through at least 5.12.0 - DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-linux-x64-${QT_VERSION}.run - COMPILER=gcc_64 -else - echo "Unsupported system." >&2 - exit 1 -fi -INSTALLER=$(basename $DOWNLOAD_URL) -ENVFILE=${QT_TARGET_CATALOG}/qt-${QT_VERSION}.env - -echo Downloading Qt -${QT_CI_DOWNLOADER} ${DOWNLOAD_URL} || exit 1 - -echo Installing Qt -if [ "$(uname)" = "Darwin" ]; then - INSTALLER_NAME=${INSTALLER%.*} - APPFILE=/Volumes/${INSTALLER_NAME}/${INSTALLER_NAME}.app/Contents/MacOS/${INSTALLER_NAME} - hdiutil attach ${PWD}/${INSTALLER} - sandbox-exec -n no-network extract-qt-installer $APPFILE ${QT_TARGET_CATALOG}/Qt - # workaround apparent exit of extract-qt-installer before finished, - # which results in hdiutil "hdiutil: couldn't unmount "disk1" - Resource busy" - # and the install resources not being available. - #hdiutil detach /Volumes/${INSTALLER_NAME} - count=0 - until hdiutil detach /Volumes/${INSTALLER_NAME} || [ $count -ge 12 ] - do - echo "Wait and attempt to detach again" - count=`expr $count + 1` - sleep 5 - done -elif [ "$(uname)" = "Linux" ]; then - unshare -r -n extract-qt-installer ${PWD}/${INSTALLER} ${QT_TARGET_CATALOG}/Qt -fi - -echo Create ${ENVFILE} -if [ -d "${QT_TARGET_CATALOG}/Qt/${QT_VERSION}/${COMPILER}/bin" ]; then - echo "export PATH=${QT_TARGET_CATALOG}/Qt/${QT_VERSION}/${COMPILER}/bin:$PATH" > ${ENVFILE} -elif [ -d "${QT_TARGET_CATALOG}/Qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${COMPILER}/bin" ]; then - # some packages use an abbreviated version x.y in the path instead of x.y.z - echo "export PATH=${QT_TARGET_CATALOG}/Qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${COMPILER}/bin:$PATH" > ${ENVFILE} -fi - diff --git a/tools/qtci/install-qt-online b/tools/qtci/install-qt-online deleted file mode 100755 index 63d686d73..000000000 --- a/tools/qtci/install-qt-online +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -e -# Install Qt by online installer - -function usage() { - echo "Usage:" - echo "install-qt-online \"packages\" [output_path [qt_installer_version]]" - echo "Examples:" - echo "install-qt-online \"qt.qt5.5121.gcc_64\"" - echo "install-qt-online \"qt.qt5.5121.gcc_64\" /opt/Qt" - echo "install-qt-online \"qt.qt5.5121.gcc_64\" /opt/Qt latest" - echo "install-qt-online \"qt.qt5.5121.gcc_64\" /opt/Qt 3.1.1" - exit -1 -} - -if [ $# -lt 1 ] -then - usage -fi - -export QT_CI_PACKAGES=${1} -QT_TARGET_CATALOG=${2:-$PWD} -INSTALLER_VERSION=${3:-latest} # lastest or a version triplet, e.g. 3.1.1 -QT_CI_DOWNLOADER=${QT_CI_DOWNLOADER:-"wget -c -N"} - -if [ "$(uname)" = "Darwin" ]; then - if [ "${INSTALLER_VERSION}" = "latest" ]; then - DOWNLOAD_URL=https://download.qt.io/official_releases/online_installers/qt-unified-mac-x64-online.dmg - else - DOWNLOAD_URL=https://download.qt.io/archive/online_installers/$(echo ${INSTALLER_VERSION} | cut -d . -f1-2)/qt-unified-mac-x64-${INSTALLER_VERSION}-online.dmg - fi - COMPILER=clang_64 -elif [ "$(uname)" = "Linux" ]; then - if [ "${INSTALLER_VERSION}" = "latest" ]; then - DOWNLOAD_URL=https://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run - else - DOWNLOAD_URL=https://download.qt.io/archive/online_installers/$(echo ${INSTALLER_VERSION} | cut -d . -f1-2)/qt-unified-linux-x64-${INSTALLER_VERSION}-online.run - fi - COMPILER=gcc_64 -else - echo "Unsupported system." >&2 - exit 1 -fi - -INSTALLER=$(basename $DOWNLOAD_URL) - -echo Downloading Qt -${QT_CI_DOWNLOADER} ${DOWNLOAD_URL} || exit 1 - -echo Installing Qt - -if [ "$(uname)" = "Darwin" ]; then - hdiutil attach ${PWD}/${INSTALLER} -plist > minfo.plist - MOUNTPOINT=$(/usr/libexec/PlistBuddy -c "Print :system-entities:0:mount-point" minfo.plist || \ - /usr/libexec/PlistBuddy -c "Print :system-entities:1:mount-point" minfo.plist || \ - /usr/libexec/PlistBuddy -c "Print :system-entities:2:mount-point" minfo.plist) - INSTALLER_NAME=$(basename "${MOUNTPOINT}") - APPFILE="${MOUNTPOINT}"/${INSTALLER_NAME}.app/Contents/MacOS/${INSTALLER_NAME} - extract-qt-installer "$APPFILE" "${QT_TARGET_CATALOG}/Qt" - hdiutil detach "${MOUNTPOINT}" -elif [ "$(uname)" = "Linux" ]; then - extract-qt-installer ${PWD}/${INSTALLER} "${QT_TARGET_CATALOG}/Qt" -fi diff --git a/tools/qtci/qt-install.qs b/tools/qtci/qt-install.qs deleted file mode 100644 index d711157d1..000000000 --- a/tools/qtci/qt-install.qs +++ /dev/null @@ -1,256 +0,0 @@ -// QT-CI Project -// License: Apache-2.0 -// https://github.com/benlau/qtci - -function log() { - var msg = ["QTCI: "].concat([].slice.call(arguments)); - console.log(msg.join(" ")); -} - -function printObject(object) { - var lines = []; - for (var i in object) { - lines.push([i, object[i]].join(" ")); - } - log(lines.join(",")); -} - -var status = { - widget: null, - finishedPageVisible: false, - installationFinished: false -} - -function tryFinish() { - if (status.finishedPageVisible && status.installationFinished) { - if (status.widget.LaunchQtCreatorCheckBoxForm) { - // Disable this checkbox for minimal platform - status.widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false); - } - if (status.widget.RunItCheckBox) { - // LaunchQtCreatorCheckBoxForm may not work for newer versions. - status.widget.RunItCheckBox.setChecked(false); - } - log("Press Finish Button"); - gui.clickButton(buttons.FinishButton); - } -} - -function Controller() { - installer.installationFinished.connect(function() { - status.installationFinished = true; - gui.clickButton(buttons.NextButton); - tryFinish(); - }); - installer.setMessageBoxAutomaticAnswer("OverwriteTargetDirectory", QMessageBox.Yes); - installer.setMessageBoxAutomaticAnswer("installationErrorWithRetry", QMessageBox.Ignore); - installer.setMessageBoxAutomaticAnswer("XcodeError", QMessageBox.Ok); - - // Allow to cancel installation for arguments --list-packages - installer.setMessageBoxAutomaticAnswer("cancelInstallation", QMessageBox.Yes); -} - -Controller.prototype.WelcomePageCallback = function() { - log("Welcome Page"); - - gui.clickButton(buttons.NextButton); - - var widget = gui.currentPageWidget(); - - /* - Online installer 3.0.6 - - It must disconnect the completeChanged callback after used, otherwise it will click the 'next' button on another pages - */ - var callback = function() { - gui.clickButton(buttons.NextButton); - widget.completeChanged.disconnect(callback); - } - - widget.completeChanged.connect(callback); -} - -Controller.prototype.CredentialsPageCallback = function() { - - var login = installer.environmentVariable("QT_CI_LOGIN"); - var password = installer.environmentVariable("QT_CI_PASSWORD"); - - if (login === "" || password === "") { - gui.clickButton(buttons.CommitButton); - } - - var widget = gui.currentPageWidget(); - - widget.loginWidget.EmailLineEdit.setText(login); - - widget.loginWidget.PasswordLineEdit.setText(password); - - gui.clickButton(buttons.CommitButton); -} - -Controller.prototype.ComponentSelectionPageCallback = function() { - log("ComponentSelectionPageCallback"); - - function list_packages() { - var components = installer.components(); - log("Available components: " + components.length); - var packages = ["Packages: "]; - - for (var i = 0; i < components.length; i++) { - packages.push(components[i].name); - } - log(packages.join(" ")); - } - - var widget = gui.currentPageWidget(); - - var archiveCheckBox = gui.findChild(widget, "Archive"); - var latestCheckBox = gui.findChild(widget, "Latest releases"); - var fetchButton = gui.findChild(widget, "FetchCategoryButton"); - - if (archiveCheckBox != null) { - // check archive - archiveCheckBox.click(); - } - if (latestCheckBox != null) { - // uncheck latest - latestCheckBox.click(); - } - if (fetchButton != null) { - fetchButton.click() - } - - if (installer.value("QTCI_LIST_PACKAGES", "0") != "0") { - list_packages(); - gui.clickButton(buttons.CancelButton); - return; - } - - log("Select components"); - - function trim(str) { - return str.replace(/^ +/, "").replace(/ *$/, ""); - } - - var packages = trim(installer.value("QTCI_PACKAGES")).split(","); - if (packages.length > 0 && packages[0] !== "") { - widget.deselectAll(); - var components = installer.components(); - var allfound = true; - for (var i in packages) { - var pkg = trim(packages[i]); - var found = false; - for (var j in components) { - if (components[j].name === pkg) { - found = true; - break; - } - } - if (!found) { - allfound = false; - log("ERROR: Package " + pkg + " not found."); - } else { - log("Select " + pkg); - widget.selectComponent(pkg); - } - } - if (!allfound) { - list_packages(); - // TODO: figure out how to set non-zero exit status. - gui.clickButton(buttons.CancelButton); - return; - } - } else { - log("Use default component list"); - } - - gui.clickButton(buttons.NextButton); -} - -Controller.prototype.IntroductionPageCallback = function() { - log("Introduction Page"); - log("Retrieving meta information from remote repository"); - - /* - Online installer 3.0.6 - - Don't click buttons.NextButton directly. It will skip the componenet selection. - */ - - if (installer.isOfflineOnly()) { - gui.clickButton(buttons.NextButton); - } -} - -Controller.prototype.TargetDirectoryPageCallback = function() { - var output = installer.value("QTCI_OUTPUT"); - log("Set target installation page: " + output); - var widget = gui.currentPageWidget(); - - if (widget != null) { - widget.TargetDirectoryLineEdit.setText(output); - } - - gui.clickButton(buttons.NextButton); -} - -Controller.prototype.LicenseAgreementPageCallback = function() { - log("Accept license agreement"); - var widget = gui.currentPageWidget(); - - if (widget != null) { - widget.AcceptLicenseRadioButton.setChecked(true); - } - - gui.clickButton(buttons.NextButton); -} - -Controller.prototype.ReadyForInstallationPageCallback = function() { - log("Ready to install"); - - // Bug? If commit button pressed too quickly finished callback might not show the checkbox to disable running qt creator - // Behaviour started around 5.10. You don't actually have to press this button at all with those versions, even though gui.isButtonEnabled() returns true. - gui.clickButton(buttons.CommitButton, 200); -} - -Controller.prototype.PerformInstallationPageCallback = function() { - log("PerformInstallationPageCallback"); - gui.clickButton(buttons.CommitButton); -} - -Controller.prototype.FinishedPageCallback = function() { - log("FinishedPageCallback"); - - var widget = gui.currentPageWidget(); - - // Bug? Qt 5.9.5 and Qt 5.9.6 installer show finished page before the installation completed - // Don't press "finishButton" immediately - status.finishedPageVisible = true; - status.widget = widget; - tryFinish(); -} - -// Telemetry disabled -Controller.prototype.DynamicTelemetryPluginFormCallback = function() -{ - log("TelemetryPluginFormCallback"); - var page = gui.pageWidgetByObjectName("DynamicTelemetryPluginForm"); - page.statisticGroupBox.disableStatisticRadioButton.setChecked(true); - gui.clickButton(buttons.NextButton); -} - -// On windows installs there is a page about the start menu. -Controller.prototype.StartMenuDirectoryPageCallback = function() { - log("StartMenuDirectoryPageCallback"); - gui.clickButton(buttons.NextButton); -} - -// qt online installer 3.2.1: open source users must now accept the open -// source obligations. -// https://www.qt.io/blog/qt-online-installer-3.2.1-released -Controller.prototype.ObligationsPageCallback = function() -{ - log("ObligationsPageCallback"); - var page = gui.pageWidgetByObjectName("ObligationsPage"); - page.obligationsAgreement.setChecked(true); - page.completeChanged(); - gui.clickButton(buttons.NextButton); -} diff --git a/tools/travis_install_linux_coverage b/tools/travis_install_linux_coverage deleted file mode 100755 index f8ad932e1..000000000 --- a/tools/travis_install_linux_coverage +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -ex -# -# This script is run on travis for the install stage of mac builds. -# - -#debug failed install -function debug() { - cat ${CACHEDIR}/qt-${QT_VERSION}.env - find ${CACHEDIR}/Qt -maxdepth 3 -ls - cat ${CACHEDIR}/Qt/InstallationLog.txt - cat ${CACHEDIR}/Qt/components.xml - echo "$1" >&2 - exit 1 -} - -# validate install -function validate() { - ( - set +e - source ${CACHEDIR}/qt-${QT_VERSION}.env - if [ "$(qmake -query QT_INSTALL_BINS)" != "${QTDIR}/bin" ]; then - debug "ERROR: unexpected Qt location." - fi - if [ "$(qmake -query QT_VERSION)" != "${QT_VERSION}" ]; then - debug "ERROR: wrong Qt version." - fi - ) -} - -QT_VERSION=${1:-5.15.2} -QT_VERSION_SHORT=${QT_VERSION//./} - -# our expectation is that install-qt creates $QTDIR, $QTDIR/bin. -CACHEDIR=${HOME}/Cache -QTDIR=${CACHEDIR}/Qt/${QT_VERSION}/gcc_64 - -if [ -d "${QTDIR}/bin" ]; then - echo "Using cached Qt." - echo "If you need to clear the cache see" - echo "https://docs.travis-ci.com/user/caching/#Fetching-and-storing-caches." -else - rm -fr ${CACHEDIR} - mkdir -p ${CACHEDIR} - QT_CI_DOWNLOADER="wget -nv -c" PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt-online "qt.qt5.${QT_VERSION_SHORT}.gcc_64" ${CACHEDIR} - echo "export PATH=${QTDIR}/bin:$PATH" > ${CACHEDIR}/qt-${QT_VERSION}.env - validate -fi diff --git a/tools/travis_install_linux_local b/tools/travis_install_linux_local deleted file mode 100755 index 8d15672a0..000000000 --- a/tools/travis_install_linux_local +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -ex -# -# This script is run on travis for the install stage of mac builds. -# - -#debug failed install -function debug() { - cat ${CACHEDIR}/qt-${QT_VERSION}.env - find ${CACHEDIR}/Qt -maxdepth 3 -ls - cat ${CACHEDIR}/Qt/InstallationLog.txt - cat ${CACHEDIR}/Qt/components.xml - echo "$1" >&2 - exit 1 -} - -# validate install -function validate() { - ( - set +e - source ${CACHEDIR}/qt-${QT_VERSION}.env - if [ "$(qmake -query QT_INSTALL_BINS)" != "${QTDIR}/bin" ]; then - debug "ERROR: unexpected Qt location." - fi - if [ "$(qmake -query QT_VERSION)" != "${QT_VERSION}" ]; then - debug "ERROR: wrong Qt version." - fi - ) -} - -QT_VERSION=${1:-5.15.2} -QT_VERSION_SHORT=${QT_VERSION//./} - -# our expectation is that install-qt creates $QTDIR, $QTDIR/bin. -CACHEDIR=${HOME}/Cache -QTDIR=${CACHEDIR}/Qt/${QT_VERSION}/gcc_64 - -if [ -d "${QTDIR}/bin" ]; then - echo "Using cached Qt." - echo "If you need to clear the cache see" - echo "https://docs.travis-ci.com/user/caching/#Fetching-and-storing-caches." - if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then - # the cache is being used. modify it to reset expiration date. - date > ${CACHEDIR}/timestamp - fi - if [ -f "${CACHEDIR}/timestamp" ]; then - echo -n "Cache timestamp: " - cat "${CACHEDIR}/timestamp" - fi -else - rm -fr ${CACHEDIR} - mkdir -p ${CACHEDIR} - pushd ${CACHEDIR} - # install-qt creates the install at $PWD/Qt. - QT_CI_PACKAGES=qt.qt5.${QT_VERSION_SHORT}.gcc_64,qt.qt5.${QT_VERSION_SHORT}.qtwebengine QT_CI_DOWNLOADER="wget -nv -c" PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt ${QT_VERSION} - popd - validate - rm ${CACHEDIR}/qt-opensource*.run -fi - -# prepare locale for test_encoding_latin1, requires locales package. -sudo rm -rf /var/lib/apt/lists/* \ - && sudo sed -i 's/^# *\(en_US ISO-8859-1\)/\1/' /etc/locale.gen \ - && sudo locale-gen \ - && locale -a From 9476022dc22304cd363111e4b4c5e584f3d89fd0 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:56:45 -0600 Subject: [PATCH 088/132] fix faulty assertion in garmin. (#1290) the '-' character is legal for some devices, but was excluded in the assertions as it can be a metacharacter. --- garmin.cc | 25 ++++++++++--------------- garmin.h | 3 +-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/garmin.cc b/garmin.cc index 5c1b8c0ef..732f12b09 100644 --- a/garmin.cc +++ b/garmin.cc @@ -21,17 +21,18 @@ #include "garmin.h" -#include // for assert #include // for INT_MAX #include // for atan2, floor, sqrt #include // for fprintf, fflush, snprintf, snprintf +#include // for int32_t #include // for strtol #include // for memcpy, strlen, strncpy, strchr #include // for time_t #include // for as_const #include // for QByteArray -#include // for QRegularExpression +#include // for QChar +#include // for QList<>::const_iterator #include // for QString #include // for QTextCodec #include // for CaseInsensitive @@ -46,7 +47,6 @@ #include "jeeps/gpsapp.h" // for GPS_Set_Baud_Rate, GPS_Init, GPS_Pre... #include "jeeps/gpscom.h" // for GPS_Command_Get_Lap, GPS_Command_Get... #include "jeeps/gpsmem.h" // for GPS_Track_Del, GPS_Way_Del, GPS_Pvt_Del -#include "jeeps/gpsport.h" // for int32 #include "jeeps/gpsprot.h" // for gps_waypt_type, gps_category_type #include "jeeps/gpssend.h" // for GPS_SWay, GPS_PWay, GPS_STrack, GPS_... #include "jeeps/gpsserial.h" // for DEFAULT_BAUD @@ -297,17 +297,7 @@ GarminFormat::rw_init(const QString& fname) fprintf(stdout, "receiver charset detected as %s.\r\n", receiver_charset); } - /* - * Beware, valid_waypt_chars shouldn't contain any character class metacharacters, - * i.e. '\', '^', '-', '[', or ']' - */ - assert(!QString(valid_waypt_chars).contains('\\')); - assert(!QString(valid_waypt_chars).contains('^')); - assert(!QString(valid_waypt_chars).contains('-')); - assert(!QString(valid_waypt_chars).contains('[')); - assert(!QString(valid_waypt_chars).contains(']')); - invalid_char_re = QRegularExpression(QStringLiteral("[^%1]").arg(valid_waypt_chars)); - assert(invalid_char_re.isValid()); + valid_chars = valid_waypt_chars; } void @@ -330,6 +320,8 @@ GarminFormat::rw_deinit() xfree(portname); portname = nullptr; + + valid_chars = QString(); } int @@ -958,7 +950,10 @@ GarminFormat::route_waypt_pr(const Waypoint* wpt) * for the new models, we just release this safety check manually. */ if (receiver_must_upper) { - cleanname = cleanname.toUpper().remove(invalid_char_re); + auto isInvalidChar = [this](const QChar &ch)->bool { + return !valid_chars.contains(ch); + }; + cleanname = cleanname.toUpper().removeIf(isInvalidChar); } write_char_string(rte->ident, str_from_unicode(cleanname).constData(), diff --git a/garmin.h b/garmin.h index 0139a861d..68d42bbfb 100644 --- a/garmin.h +++ b/garmin.h @@ -24,7 +24,6 @@ #include // for size_t #include // for QByteArray -#include // for QRegularExpression #include // for QString #include // for QTextCodec #include // for QVector @@ -135,7 +134,7 @@ class GarminFormat : public Format bool receiver_must_upper = true; QTextCodec* codec{nullptr}; - QRegularExpression invalid_char_re; + QString valid_chars; QVector garmin_args = { { From d9f6127d68074a77a0ad93372ade4fdacb24c44f Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 19 Jul 2024 05:53:30 -0600 Subject: [PATCH 089/132] don't send links with GPS_A200_Send. (#1295) --- jeeps/gpsapp.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index 5a091e874..4b1441ed8 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -3152,9 +3152,6 @@ int32_t GPS_A200_Send(const char* port, GPS_PWay* way, int32_t n) gpsdevh* fd; GPS_Packet tra; GPS_Packet rec; - int32_t i; - int32_t len; - US method; if (!GPS_Device_On(port,&fd)) { return gps_errno; @@ -3172,7 +3169,10 @@ int32_t GPS_A200_Send(const char* port, GPS_PWay* way, int32_t n) } - for (i=0; iisrte) { method = LINK_ID[gps_link_type].Pid_Rte_Hdr; @@ -3190,6 +3190,8 @@ int32_t GPS_A200_Send(const char* port, GPS_PWay* way, int32_t n) GPS_Error("A200_Send: Unknown route protocol"); return PROTOCOL_ERROR; } + } else if (way[i]->islink) { + continue; // links not supported. can cause "Route Waypoint was Deleted" and "Received an Invalid WPT" on device. } else { method = LINK_ID[gps_link_type].Pid_Rte_Wpt_Data; From 0c6e490cdad207919f1d861972ffbd1f78b36c92 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 19 Jul 2024 06:52:44 -0600 Subject: [PATCH 090/132] enhance garmin route writes for devices using D201_Rte_Hdr_Type. (#1297) which use GPS_PWay->rte_cmnt for the route name. --- garmin.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/garmin.cc b/garmin.cc index 732f12b09..9ffb56d5c 100644 --- a/garmin.cc +++ b/garmin.cc @@ -907,6 +907,11 @@ GarminFormat::route_hdr_pr(const route_head* rte) (*cur_tx_routelist_entry)->rte_num = rte->rte_num; (*cur_tx_routelist_entry)->isrte = 1; if (!rte->rte_name.isEmpty()) { + /* for devices that use D201_Rte_Hdr_Type */ + write_char_string((*cur_tx_routelist_entry)->rte_cmnt, + str_from_unicode(rte->rte_name).constData(), + sizeof((*cur_tx_routelist_entry)->rte_cmnt)); + /* for devices that use D202_Rte_Hdr_Type */ write_char_string((*cur_tx_routelist_entry)->rte_ident, str_from_unicode(rte->rte_name).constData(), sizeof((*cur_tx_routelist_entry)->rte_ident)); From 92b4888a829775ad6f28a5efd0e56a357cf68490 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 19 Jul 2024 07:11:59 -0600 Subject: [PATCH 091/132] enhance garmin route write for devices using 16 member icon set. (#1298) --- garmin.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/garmin.cc b/garmin.cc index 9ffb56d5c..cea5e6c4d 100644 --- a/garmin.cc +++ b/garmin.cc @@ -937,7 +937,11 @@ GarminFormat::route_waypt_pr(const Waypoint* wpt) rte->lon = wpt->longitude; rte->lat = wpt->latitude; - rte->smbl = gt_find_icon_number_from_desc(wpt->icon_descr, PCX); + if (gps_rte_type == 103) { + rte->smbl = d103_icon_number_from_symbol(wpt->icon_descr); + } else { + rte->smbl = gt_find_icon_number_from_desc(wpt->icon_descr, PCX); + } // map class so unit doesn't duplicate routepoints as a waypoint. rte->wpt_class = 0x80; From 7c834907b18980b4a279741522e7ecc4a70434dd Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 20 Jul 2024 06:48:06 -0600 Subject: [PATCH 092/132] fix memory leaks writing garmin routes. (#1299) --- garmin.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/garmin.cc b/garmin.cc index cea5e6c4d..29036fd3e 100644 --- a/garmin.cc +++ b/garmin.cc @@ -981,7 +981,7 @@ GarminFormat::route_waypt_pr(const Waypoint* wpt) void GarminFormat::route_write() { - int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */ + const int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */ tx_routelist = (GPS_SWay**) xcalloc(n,sizeof(GPS_PWay)); cur_tx_routelist_entry = tx_routelist; @@ -998,6 +998,12 @@ GarminFormat::route_write() }; route_disp_all(route_hdr_pr_lambda, nullptr, route_waypt_pr_lambda); GPS_Command_Send_Route(portname, tx_routelist, n); + + for (int i = 0; i < n; i++) { + GPS_Way_Del(&tx_routelist[i]); + } + + xfree(tx_routelist); } void From 563c32593f78948a3419a2cfe5c1deffd4bc80c0 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 20 Jul 2024 11:35:52 -0600 Subject: [PATCH 093/132] fix gpsapp copy_char_array that could leave part of a packet uninitialized. (#1301) * fix gpsapp copy_char_array that could leave part of a packet uninitialized. * tidy up a bit. * delete empty statement --- jeeps/gpsapp.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index 4b1441ed8..d56a603e1 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -125,28 +125,31 @@ char gps_save_string[GPS_ARB_LEN]; * we uppercase the string because some models (III's and 12's) react * violently to lower case data. */ -typedef enum { UpperNo = 0, UpperYes = 1 } copycase; +enum copycase { UpperNo, UpperYes }; static -void copy_char_array(UC** dst, char* src, int count, copycase mustupper) +void copy_char_array(UC** dst, const char* src, int count, copycase mustupper) { UC* d = *dst; - int ocount = count; - do { + int copied = 0; + // Copy up to count characters from the source to the desitnation. + for (int i = 0; i < count; ++i) { UC sc = *src++; if (sc == 0) { - while (count--) { - *d++ = ' '; - } break; } if (!isalnum(sc)) { continue; - } else { - *d++ = mustupper == UpperYes ? toupper(sc) : sc; } - } while (--count) ; - *dst += ocount; + *d++ = mustupper == UpperYes ? toupper(sc) : sc; + copied++; + } + // If necessary pad with space characters so that the total count + // of characters written to the destination is count. + for (int i = copied; i < count; ++i) { + *d++ = ' '; + } + *dst += count; } From e48cf1af6cccba3234c9175c9ce295e0219ce44a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:21:05 -0600 Subject: [PATCH 094/132] correct computation of timestamp with garmin real time positioning. (#1302) * correct computation of timestamp with garmin real time positioning. * tweak garmin pvt conversion --- garmin.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/garmin.cc b/garmin.cc index 29036fd3e..ca642c3e7 100644 --- a/garmin.cc +++ b/garmin.cc @@ -22,7 +22,7 @@ #include "garmin.h" #include // for INT_MAX -#include // for atan2, floor, sqrt +#include // for atan2, modf, sqrt #include // for fprintf, fflush, snprintf, snprintf #include // for int32_t #include // for strtol @@ -36,7 +36,7 @@ #include // for QString #include // for QTextCodec #include // for CaseInsensitive -#include // for qPrintable, foreach +#include // for qPrintable, qRound64, Q_INT64_C, qint64 #include "defs.h" #include "formspec.h" // for FormatSpecificDataList @@ -596,11 +596,13 @@ GarminFormat::pvt2wpt(GPS_PPvt_Data pvt, Waypoint* wpt) * 3) The number of leap seconds that offset the current UTC and GPS * reference clocks. */ - double wptime = 631065600.0 + pvt->wn_days * 86400.0 + - pvt->tow - - pvt->leap_scnds; - double wptimes = floor(wptime); - wpt->SetCreationTime(wptimes, 1000000.0 * (wptime - wptimes)); + double tow_integral_part; + double tow_fractional_part = modf(pvt->tow, &tow_integral_part); + qint64 seconds = Q_INT64_C(631065600) + pvt->wn_days * Q_INT64_C(86400) + + qRound64(tow_integral_part) + - pvt->leap_scnds; + qint64 milliseconds = qRound64(1000.0 * tow_fractional_part); + wpt->SetCreationTime(seconds, milliseconds); /* * The Garmin spec fifteen different models that use a different From 0a6bf66088e0255768383bb56aacaf20f9c90b08 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:57:25 -0600 Subject: [PATCH 095/132] correct garmin real time altitude, add geoid height. (#1303) --- garmin.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/garmin.cc b/garmin.cc index ca642c3e7..d676e33df 100644 --- a/garmin.cc +++ b/garmin.cc @@ -579,7 +579,13 @@ GarminFormat::route_read() void GarminFormat::pvt2wpt(GPS_PPvt_Data pvt, Waypoint* wpt) { - wpt->altitude = pvt->alt; + // pvt->alt is height (in meters) above the WGS84 elipsoid. + // pvt->msl_hght is height (in meters) of WGS84 elipsoid above MSL. + // wpt->altitude is height (in meters) above geoid (mean sea level). + // wpt->geoidheight is "Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid." + wpt->set_geoidheight(-pvt->msl_hght); + wpt->altitude = pvt->alt + pvt->msl_hght; + wpt->latitude = pvt->lat; wpt->longitude = pvt->lon; From c86aff1d7068edf9a987860d88ebe02a56674157 Mon Sep 17 00:00:00 2001 From: OlesyaGerasimenko <53296253+OlesyaGerasimenko@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:37:46 +0300 Subject: [PATCH 096/132] Update Russian translation (#1304) * Update Russian translation * Update Russian translation --- gui/coretool/gpsbabel_ru.qm | Bin 31942 -> 32388 bytes gui/coretool/gpsbabel_ru.ts | 6 +++--- gui/gpsbabelfe_ru.qm | Bin 68505 -> 69401 bytes gui/gpsbabelfe_ru.ts | 21 +++++++++++---------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gui/coretool/gpsbabel_ru.qm b/gui/coretool/gpsbabel_ru.qm index fe8b14bf7b7e1bf4e76cb0161ec7fc3663bdb05a..9181089ff2d83fc158f0141879e0961f468e22ca 100644 GIT binary patch delta 1563 zcmYjRc}x^%6#vcaH@iD~%vOlq*!g?UST-Q2?^4ILwRL*W%ZehD_&IO8#v_{TRoO_quDkcY3 zb+IR#BY*)xfg8Zck#=FYqfg}!p)jQe81+!_4Iy^1kAxK$tARzo3H6qNKzXaMdK8fx z_(a&Z;wWGX2yLa^L?%bG@%EtwcZ9CF?*RS`q1)a8%xchEM!p1m3$!%eo-u8=-aTg! zU>T)vxW53Xov45J&rLx72K`p)HDFAS{)5D;z@$q3!DTui?o0il8T2`z@5yun9!YED z?LqHdLr%hNa>Q!zJe~v0J7L%t5(c<88}`>9pt9Qx2VY(R(wU*-+WUYSG@J+!Ou<;g znd$%#z0lC<&!oaT4Ofm+>1K{G+&M-flLr}j7g>oGW78UHfyLX5J2q1ODNBsUc7+1f zKI2ceB7|U3g7NasbAT?!cVaSaEHj8A!V+?iAKjtDF|w<7WUyO*|Y& zdDQ1(=SLwVd!^WU`d4ZlK|I%R3m6ZvOSwla(JS8ggwBp9;?1v#Z%IJBKduZIw^V#~ z!3zxAZVC}vfh?Cv_7hI&r=~f^%RtmRQ$uqov`e}Hqn3Pc`tYqoz>*QBKf){kA2i(( zTgZz&rWa8~z#N}h{3Venmuog=ADXw#JZ~&b%Ai`a+E=i`9&>H43QTR$(pYp@ueq)N z*KYImy`KTD7z>*^6R0|?1sM&HWSM{M5&5@T+ruJEbEjJxqjfY1ziX$MV_D7}%gMVZ zfFaSAn*~&b*$*uDekNBehb_-Kjsl5=R=su=NHAIleoS#L-5Q${2CUp?bswNAgnVaR zJ<>@-eb%}=hFqAx*t+)&HG?6=dTav4-`u3-3z0?NSnmyPBMv`GQr1TDW~UUsiagHU zA-!r>s5fkqm9Z?w%8u4mq_bH5>ofFeWCv0gkUzavrIOHrLZ`b1eql>Crf7; zES06vN}@H1A}MS#ON5LpsC4;I0fkO(cu-C|6*cf1`zM5Mky)zht59UOr(98M{Bo}9 z_4v!w6>@f2wO_3Y80a15RjU+^%G92dsMDDjvw=jxN#Oa~`QlKm*Ag}xBQcsqvuLanXJv#q;Tz*Y8R^OVzd;BZtdstx{E0R-(vW bwM6mCepRliR^(CwD^Y68yo&bu+u{EL^W2_~ delta 1190 zcmW+#dr(w$7(Msy-o1Nw@7|RKS0P)o>pG_nmXTa~dX@o^htd z6tEO<+5q2auzYkK2+l<4^$;Mp8*3s~0@^*ujQA1o8AHLdIAGamYpRjmvc9#_>?ki` zHpI69RX)t-<-tH`GGn_P3q;tN+5>(-&@JZRk;}kFPp17GOMjhAcgk8|>j~!H#dCmn zl3B$y7f=|?sugbmv36EHNcGYmv%-uZAT5Kn?3d|WU^5Pl1JkS6;<9eQoX;K~FU5Q; zdC8vc5`b`qy%~20Fge)2ItcWfCU&B55=iuAC(3C}=$8{1lTW!y(fk_q*<7G#zTE%> z{;oLfMfGd;%MQkX+V-NI3>;-_k0{WqLlGyr8Ea_`S0aE2FLd&NaSU(0nAxe3hMvM+1& zN$uqZviAbj{+!!Lq|!I3#JR74q8K@qHO`LPtIEvs0>pW$x+m*^9p0+OKMnvXWvV7= zHn3n!Zf1>+jc(pt5CqKrg11-}0nwu(Px z{|v|(<2zs71)@jz?t6!UibDQsEtOC8^`+y}f$gi+-|O>8g<0x5NBaSVMLqn`1#J3CPF0vP zk`2P1+9NbCmvJyR;qu-@3K;Po4q7BvBcc0&F`cdNmR@RjHV?in!^r#q6&ikloy3?!8gc zaEsifG-|S=ax`Z&@F^~tWG)w7rfvkU4%JcYu#*-jfb7^n2OV;~W zi1DRz}za<>!!Ql0cNlCT%K^nslu|1zUKe5;a_2+>D9vXHks_3<_e ze!^k>F4t5f{PeBYGJth4a Image Offset Time (+HH:MM or -HH:MM) - + Время смещения расположения (+ЧЧ:ММ или -ЧЧ:ММ) @@ -528,7 +528,7 @@ override codec to use for device - + переопределить кодек для этого устройства @@ -733,7 +733,7 @@ Google Takeout Location History - + Журнал местоположений Google Takeout diff --git a/gui/gpsbabelfe_ru.qm b/gui/gpsbabelfe_ru.qm index 8e1046945faa6b397862bad83f1bc305fcac74cb..c18bfd4ad7ebf766c20cd23a11d7d1d85d6039f5 100644 GIT binary patch delta 3018 zcmc&$X;4&G7XG^5ef|1D(-_4>lTuq8ml)C_2qM8oKm`nf2rj`5gjQM+C>k_^+9<>& zYC;B47|Xa|92u2p8b`(?Iw~=O8!mCnGRA!yM>HmCCT70wu1ZbK{F#44Ro8dlx$mBP z&Ue0Z9yM!3&4;3*i$iS(AQ0#mLF`W)M+_ns5QB*;i35mRi6O*8#8BdQ#DT=8#4x(> zBMu_=BhCU^6+kKn>NXQs5f1~R2FRgJcNREl1C%as;NjFHUVubAX<9@$^9VCG3Y$K2Ujd2RV)z=k0<#b{I)n2YLEh;4db~ zD+G`k3wc{Qu>TdvJNaI50CaT{1MUo6Jp(>D3_4d}ap$27Nnrx1P+Wdm7eHBCOFW9s zg^tU>ninx7eLb-H3Znc;|E4a8?aK_S?<1jRDkGMWlJz0*LjqEce8s@JB2{|`c$$Rq z&AcG$Q>4vo06sr}w5_Ci-yKZwCKD~4k-q)`@aGWZ<+zxvLZRzidzW5s{>2E32N}ZH;j~5=fCLR8h%o5c|U)EQ#WR4%DD|=g^(PT*1 zPGthagQO?NUM4lMBKIg6xtJ>64lM^JSBsJt8Q_Gz;+=Z7Y3We0rI`*s5n_A5N9?!? zv7PlrqEUQYMh(T^@Zf2)Xy``2F(<{jO8Ob?BYtY5-|&^PJdcSw#?{LH8?I8_Bjv#M zt<1Em9O}0d*z!=0*j`DI^^!+M6F&)(lcWb!|5!N%9f0g!^2D%%Kz_WOvxg$gsFG*P zPKx;p`R#f0c#%b3vhxtnH_EG9h{IAmm|5t-{Q2_Q05ki)e+PNp30@G`DA$J4QSB&s zi(f5J(?{MG%7cTu%g%;{bkIp|%w`EPn&igf9u#e}2jkK`IQ=IN7N^U5$1}5r+49NT zXIR=h@|7220Q(*JUM>CFtK{cb{{f6B*S+?FpM%r}>0Yl&0iK=Hy|wH*FWjM<{5>4pM}~ z05YHi&SqPVT%@>}j2B9>?ix$DLm3yw>3Vvive4=1!Ay56<^6fEx(;>fRAhS@9yZxIRO2d>h3`7U46}~yU9?de(%N# zit(`i&;T;?)@FUn!b4Bp+7M^brimg?|2R>l!KP4%<$#mKoH ztX{A7D4)noUr~ESz6UJ+RUJ8Cav=ME;UGiq z5;{JYYACTWfPGPhcjk9xzuOI~4>OSHJj0r-`Fi?*dqjJ^PYwZpNcSmxN=Ay$`|Qb&;DyV58Z8uO{VAWOBN6QX z1#kE~>ik!JT&j%5Go+?SH4bX)z-~x1j=FgVxDaQ|YURgg+F@gUF851z8H@c_0Tag< zSHxfDKNh!)2OlwjpaaJ94~b9j8o$1D3pjt$`0b?%ig>B0N+RTyx^$6jS4$Ma=SG+yQ_6N zO|Ub=_>#tXrQMG@C5wGt2&;37v6II6)l2QWNqt1u%3ZH?(1cW)N1L6U22N`4YZTo@ zq!=OsMUV&=fzCzoyC(qo}yxungKLj>a6L2rh^qE+s#J;-~H};RmHo- z;vzBcL!+h-fFm$LMKlmUCQc%{5uJ#^#L2`I;uPXHL}y|-aVqf~(S`UkaT@U@aV5}H z3J9Bl@_6D7;x<4m23Gh2s_UFr0O}86L{rAQKMLh6A_Fv?1(NfL^MUkK;ED&7*^hvk z&mkVlk2VKg7%Rz>`rBTSf!^FCg9|xs}ZpELdZ~CqWQ@%mZ4lLhN9o9t$iO zm}5pGuyzilu}MJZpCHXS4;-t40#!8$U%m^KnV5Ge)E+@hqyuVmoGXK&E-53%Vp!UJpx`zt& zQ|3Jn;Qbe7SacMA#W7^O3qebE16_|1bm0b2dk^!Kl>2!*LN4+Ek1T|(s0B`LLRk3@ z5~@JB6_seXji}Nt;Ak(B6Z1)6Jkrejyx(Be&XGWTC03mvy4Pcs(fr3d*fPMYdN+~r z8tcE~cyj^%R{Rjy*NJcI?SKda%11vTu^t?5&jhMIf+<7>0wPfVbtDzC#T}s;_+lse zqe&c4=#tWa;AsjU%~IgAXNu4As)2bSibeJPz;{}OF=599;98*~+x`d;*{L{&0A?U5 z?P_#@+gRo3z5!eqqntR0hVk`Ry0``c3k#L*{oTNZqe{S%56|W?~ zUb*#bE8y9$EPAm4n4W0C8%va}Z}WgNuas|`O~C)!je^v`1D>rHY~7-GcS8jGr)|Kj z0AciSZtVNJFxsBXm;Wd@csX&rTrjMzr1U+4p)`qZP7&O)1R%6R@bYFxZKDKV^TA&G z1^;_N^h&Z2*1-eM9}pV;De;QJgvROuURj;+@MH_{#`scr+#1WkuY|s)_bH8ym~@$n z+~^S3IBy0PMT(h&Nieia+)`}-j2iLaMFyz3AXYjY01_99l~?)fcT@aV7Cq!sZNcUS zv35A)dKQT{^BE`LhWO$s<4y~fq;*Vm;d04-&m+b&43Qjd$>hax$=R+3IB;BYtIVg# zzL(~C5^H)Tf1wLFK12$_AYfUC6yahnQ5z|-jwXx>msU$ApfE>Tvu+&_sFJqUoCA6T zq{2(YSsz$1#?^w!UQ&qziA=mJ?P|_v{ZHH^l{queK0E24T^ZfqAyqhYXU(HGxw>+7X-2XUnHqQbN)lKrK=(zFw^K6s>P85fW?zlnJR&%tW$mC z%0TY2YEK23_r9n4eF#k$oUiJ4aRe@9sfE*7Jm9Tb6i8rkgW7R*Ew98^{Z2{mCUv0d zF%Xuj4t8M|ZSGNTG>rsyW~etCjNI6ms@^_<2N>GbJJLt-4i~B4Nf+;<-Zhkg_UP0H zzE1_#9a0~dm0ertr>HPgwh%{ z6RtS1%b(J?c+k|{(0Jzfv7^>#LXB0{Kt_lrL8PnWd^9U;DBTRbCeiUZ6}h3w_(=dt zOEhZ-jR30SG~24)1Hv0LMLYSPm}Aluk2^+%#%WIO&7&D}HRmQ%nUDm{rH$u+)HqGk z#q;#Wzcp_TKVqD5vV37a_f3(tO_Y~K6iGm9yvUW&kui*!*j}@P&}5GnWBNcMmf>nyzd`!;!j_vOXD7}EW-pbqx3Y1~Zjry9@DY%ZZj`sx32d?Da>0S?G)2B#nEErYz*oLA zyM`{$)H-C-BP|B4A*Gr1+@*D2@EbjFOY4312ljy)t)+PulXOp3lX0Y#Lu@4Qbf{Hqqgm2Ut3(wU zPqedIzlcQU|6sM=!OJc8RlCH5oQj`?~1%EjGzW20nGR*)@gc3p`=dx=wE{8(7f?|GT%6&LWVT#aZONvP*!>}O=)2ji!DwFLno8kGHK?c(@mqoVLI&rw@ uF1qnISM)Po^ZoO{KMZLiYR3LysB!aSXH)fQzrhOo{MT($Orh7$xc(o3eBA^9 diff --git a/gui/gpsbabelfe_ru.ts b/gui/gpsbabelfe_ru.ts index 077cb652e..df0e138b5 100644 --- a/gui/gpsbabelfe_ru.ts +++ b/gui/gpsbabelfe_ru.ts @@ -6,7 +6,7 @@ About GPSBabel - О GPSBabel + О программе GPSBabel @@ -54,18 +54,19 @@ p, li { white-space: pre-wrap; } <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">$appname$</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$babelfeversion$</p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Авторское право (C) Robert Lipe, 2009-2022</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Авторское право (C) Robert Lipe, 2009-2023</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Графический интерфейс пользователя разработан и предоставлен S. Khai Mong</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Кристальные значки LGPL авторства Elvarado Coehlo</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Используется модуль $babelversion$)</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Идентификатор установки: $installationId$</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> @@ -335,7 +336,7 @@ Higher number provides more detailed diagnostics. Help - Помощь + Справка @@ -693,7 +694,7 @@ Higher number provides more detailed diagnostics. Help - Помощь + Справка @@ -1051,7 +1052,7 @@ Some GPS data formats support only some subset of waypoints, tracks, and routes. Help - Помощь + Справка @@ -1311,7 +1312,7 @@ Additionally, if you're using this to reverse a route that navigates, say, Track Filters - Фильтр Треков + Фильтр треков @@ -1598,18 +1599,18 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo If checked, times specified here are based on this computer's current time zone. - + Если флажок установлен, указанное здесь время соответствует текущему часовому поясу этого компьютера. If checked, times specified here are UTC. - + Если флажок установлен, указанное здесь время соответствует UTC. UTC - + UTC From b1d2df5c9ccadb058d6edb9310329396d90c6315 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 27 Jul 2024 12:02:57 -0600 Subject: [PATCH 097/132] teach lowranceusr about track segments (#1306) * teach lowranceusr about track segments. lowranceusr versions 2 & 3 have a continuous flag used to indicate dicontinuities in a trail. The lowranceusr version 2 & 3 reader now flags trail discontinuities as new track segements. The lowranceusr version 2 & 3 writer now flags new track segments as discontinuities. Also fix two subtle bugs: 1) when reading a version 2 or 3 trail with the break option we would fail to break the trail if the discontinuity was at the start of a section other than the first section. 2) when writing a version 2 or 3 trail with the merge option if the number of points exceeded MAX_TRAIL_POINTS we would write a header that indicated MAX_TRAIL_POINTS but actually write MAX_TRAIL_POINTS + 1. * add lowranceusr test for track segments. --- lowranceusr.cc | 44 +- lowranceusr.h | 2 +- reference/lowrance-v2-merge~usr.gpx | 3766 ++++++++++++++++++++++++++ reference/lowrance-v2.gpx | 3770 +++++++++++++++++++++++++++ testo.d/lowranceusr.test | 13 + 5 files changed, 7577 insertions(+), 18 deletions(-) create mode 100644 reference/lowrance-v2-merge~usr.gpx create mode 100644 reference/lowrance-v2.gpx diff --git a/lowranceusr.cc b/lowranceusr.cc index c264a7956..92f533a18 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -989,16 +989,20 @@ LowranceusrFormat::lowranceusr_parse_trail(int* trail_num) wpt_tmp->latitude = lat_mm_to_deg(gbfgetint32(file_in)); wpt_tmp->longitude = lon_mm_to_deg(gbfgetint32(file_in)); - // It's not clear if this should be the continuous global or - // a local continuous_flag. char continuous_flag = gbfgetc(file_in); - if (!continuous_flag && opt_seg_break && j) { - /* option to break trails into segments was specified */ - auto* trk_tmp = new route_head; - trk_tmp->rte_num = ++(*trail_num); - trk_tmp->rte_name = trk_head->rte_name; - track_add_head(trk_tmp); - trk_head = trk_tmp; + if (!continuous_flag) { + if (opt_seg_break) { + /* option to break trails into segments was specified */ + if (!trk_head->rte_waypt_empty()) { + auto* trk_tmp = new route_head; + trk_tmp->rte_num = ++(*trail_num); + trk_tmp->rte_name = trk_head->rte_name; + track_add_head(trk_tmp); + trk_head = trk_tmp; + } + } else { + wpt_tmp->wpt_flags.new_trkseg = 1; + } } /* Track Point */ @@ -1589,7 +1593,7 @@ LowranceusrFormat::lowranceusr_trail_hdr(const route_head* trk) gbfputint16(num_trail_points, file_out); gbfputint16(max_trail_size, file_out); gbfputint16(num_section_points, file_out); - trail_point_count=1; + trail_point_count=0; } void @@ -1689,7 +1693,8 @@ LowranceusrFormat::lowranceusr4_route_trl(const route_head* /*unused*/) const void LowranceusrFormat::lowranceusr_trail_disp(const Waypoint* wpt) { - if (trail_point_count <= MAX_TRAIL_POINTS) { + if (trail_point_count < MAX_TRAIL_POINTS) { + trail_point_count++; int lat = lat_deg_to_mm(wpt->latitude); int lon = lon_deg_to_mm(wpt->longitude); @@ -1699,11 +1704,15 @@ LowranceusrFormat::lowranceusr_trail_disp(const Waypoint* wpt) gbfputint32(lat, file_out); gbfputint32(lon, file_out); - gbfwrite(&continuous, 1, 1, file_out); - if (!continuous) { - continuous = 1; - } - trail_point_count++; + /* If this isn't the first point in the outgoing trail, and + * i) the source wpt was the start of a new track segment or + * ii) the source wpt is the first waypoint of a track that is being merged + * then set the continuous flag to 0 to indicate a discontinuity. + * Otherwise set the continous flag to 1. + */ + char continuous_flag = !((trail_point_count > 1) && (wpt->wpt_flags.new_trkseg || merge_new_track)); + merge_new_track = false; + gbfwrite(&continuous_flag, 1, 1, file_out); } } @@ -1757,7 +1766,7 @@ LowranceusrFormat::lowranceusr_merge_trail_tlr(const route_head* /*unused*/) void LowranceusrFormat::lowranceusr_merge_trail_hdr_2(const route_head* /*unused*/) { - continuous = 0; + merge_new_track = true; } void @@ -2038,6 +2047,7 @@ LowranceusrFormat::write() gbfputint16(NumTrails, file_out); if (NumTrails) { trail_count=0; + merge_new_track = false; auto lowranceusr_trail_disp_lambda = [this](const Waypoint* waypointp)->void { lowranceusr_trail_disp(waypointp); }; diff --git a/lowranceusr.h b/lowranceusr.h index efeb6e310..98c21ef69 100644 --- a/lowranceusr.h +++ b/lowranceusr.h @@ -457,7 +457,7 @@ class LowranceusrFormat : public Format unsigned short waypt_out_count{}; int trail_count{}, lowrance_route_count{}; int trail_point_count{}; - char continuous = 1; + bool merge_new_track{false}; short num_section_points{}; char* merge{}; int reading_version{}; diff --git a/reference/lowrance-v2-merge~usr.gpx b/reference/lowrance-v2-merge~usr.gpx new file mode 100644 index 000000000..1cccf20f4 --- /dev/null +++ b/reference/lowrance-v2-merge~usr.gpx @@ -0,0 +1,3766 @@ + + + + + + + Belle River Ridge + Belle River Ridge + Belle River Ridge + diamond 1 + + + + Dumping Ground + Dumping Ground + Dumping Ground + diamond 1 + + + + 001 + 001 + 001 + diamond 1 + + + + 002 + 002 + 002 + diamond 1 + + + + 003 + 003 + 003 + diamond 1 + + + + 004 + 004 + 004 + diamond 1 + + + + 005 + 005 + 005 + diamond 1 + + + + 006 + 006 + 006 + diamond 1 + + + + 007 + 007 + 007 + diamond 1 + + + + 008 + 008 + 008 + diamond 1 + + + + S + S + S + diamond 1 + + + + Dlphn Dprk + Dlphn Dprk + Dlphn Dprk + diamond 1 + + + + Delphine10 + Delphine10 + Delphine10 + diamond 1 + + + + Church Mrn + Church Mrn + Church Mrn + diamond 1 + + + + Del 3Can R + Del 3Can R + Del 3Can R + diamond 1 + + + + Trgh Rkpil + Trgh Rkpil + Trgh Rkpil + diamond 1 + + + + Cn Grspt Shl + Cn Grspt Shl + Cn Grspt Shl + diamond 1 + + + + Gpt Frm Wd + Gpt Frm Wd + Gpt Frm Wd + diamond 1 + + + + Aba1Old + Aba1Old + Aba1Old + fish + + + + Aba4 + Aba4 + Aba4 + fish + + + + Gpyc Wdbed + Gpyc Wdbed + Gpyc Wdbed + diamond 1 + + + + Lman 5Rock + Lman 5Rock + Lman 5Rock + diamond 1 + + + + Lman 5R N + Lman 5R N + Lman 5R N + diamond 1 + + + + Mansion 12 + Mansion 12 + Mansion 12 + diamond 1 + + + + 9Ml Rk Pil + 9Ml Rk Pil + 9Ml Rk Pil + diamond 1 + + + + 9Ml Spintp + 9Ml Spintp + 9Ml Spintp + diamond 1 + + + + Bwal Beds1 + Bwal Beds1 + Bwal Beds1 + diamond 1 + + + + 11Mi Wh Rk + 11Mi Wh Rk + 11Mi Wh Rk + diamond 1 + + + + Bsw 14 1 + Bsw 14 1 + Bsw 14 1 + diamond 1 + + + + Bluswl Way13 + Bluswl Way13 + Bluswl Way13 + diamond 1 + + + + Lmarker + Lmarker + Lmarker + diamond 1 + + + + Cn Memprk Rk + Cn Memprk Rk + Cn Memprk Rk + airplane + + + + Cn Memprk R2 + Cn Memprk R2 + Cn Memprk R2 + airplane + + + + 12Mile Cn + 12Mile Cn + 12Mile Cn + diamond 1 + + + + Wht Pav 8F + Wht Pav 8F + Wht Pav 8F + diamond 1 + + + + Crmr9Plt1 + Crmr9Plt1 + Crmr9Plt1 + tree stand + + + + Cfmr9Plt2 + Cfmr9Plt2 + Cfmr9Plt2 + tree stand + + + + 700 4 Hump + 700 4 Hump + 700 4 Hump + x 3 + + + + Pthurn Cn1 + Pthurn Cn1 + Pthurn Cn1 + diamond 1 + + + + Cn Clnt Flat + Cn Clnt Flat + Cn Clnt Flat + diamond 1 + + + + Bet-Crbc Wrk + Bet-Crbc Wrk + Bet-Crbc Wrk + wreck + + + + Jefs Bigrk + Jefs Bigrk + Jefs Bigrk + x 3 + + + + 011 + 011 + 011 + two fish + + + + 012 + 012 + 012 + two fish + + + + Mch Outbrk + Mch Outbrk + Mch Outbrk + diamond 1 + + + + Mg Midchrck + Mg Midchrck + Mg Midchrck + diamond 1 + + + + Old Ch Gap + Old Ch Gap + Old Ch Gap + diamond 1 + + + + Oldsth Wd7 + Oldsth Wd7 + Oldsth Wd7 + diamond 1 + + + + 12Rk Clsrhmp + 12Rk Clsrhmp + 12Rk Clsrhmp + diamond 1 + + + + 12Rk Sml + 12Rk Sml + 12Rk Sml + diamond 1 + + + + 12Rk Closhmp + 12Rk Closhmp + 12Rk Closhmp + diamond 1 + + + + 12Rk Bigi + 12Rk Bigi + 12Rk Bigi + diamond 1 + + + + Wpt 042* + Wpt 042* + Wpt 042* + fish + + + + Wpt 043* + Wpt 043* + Wpt 043* + fish + + + + Wpt 044* + Wpt 044* + Wpt 044* + fish + + + + 009 + 009 + 009 + diamond 1 + + + + 010 + 010 + 010 + diamond 1 + + + + 013 + 013 + 013 + diamond 1 + + + + 014 + 014 + 014 + diamond 1 + + + + 015 + 015 + 015 + diamond 1 + + + + 016 + 016 + 016 + diamond 1 + + + + 017 + 017 + 017 + diamond 1 + + + + 018 + 018 + 018 + diamond 1 + + + + 019 + 019 + 019 + diamond 1 + + + + 020 + 020 + 020 + diamond 1 + + + + 021 + 021 + 021 + diamond 1 + + + + 012 + 012 + 012 + diamond 1 + + + Event Marker 1 + Event Marker 1 + Event Marker 1 + diamond 1 + + + Event Marker 2 + Event Marker 2 + Event Marker 2 + diamond 1 + + + Trail 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/reference/lowrance-v2.gpx b/reference/lowrance-v2.gpx new file mode 100644 index 000000000..d56df6a1a --- /dev/null +++ b/reference/lowrance-v2.gpx @@ -0,0 +1,3770 @@ + + + + + + + Belle River Ridge + Belle River Ridge + Belle River Ridge + diamond 1 + + + + Dumping Ground + Dumping Ground + Dumping Ground + diamond 1 + + + + 001 + 001 + 001 + diamond 1 + + + + 002 + 002 + 002 + diamond 1 + + + + 003 + 003 + 003 + diamond 1 + + + + 004 + 004 + 004 + diamond 1 + + + + 005 + 005 + 005 + diamond 1 + + + + 006 + 006 + 006 + diamond 1 + + + + 007 + 007 + 007 + diamond 1 + + + + 008 + 008 + 008 + diamond 1 + + + + S + S + S + diamond 1 + + + + Dlphn Dprk + Dlphn Dprk + Dlphn Dprk + diamond 1 + + + + Delphine10 + Delphine10 + Delphine10 + diamond 1 + + + + Church Mrn + Church Mrn + Church Mrn + diamond 1 + + + + Del 3Can R + Del 3Can R + Del 3Can R + diamond 1 + + + + Trgh Rkpil + Trgh Rkpil + Trgh Rkpil + diamond 1 + + + + Cn Grspt Shl + Cn Grspt Shl + Cn Grspt Shl + diamond 1 + + + + Gpt Frm Wd + Gpt Frm Wd + Gpt Frm Wd + diamond 1 + + + + Aba1Old + Aba1Old + Aba1Old + fish + + + + Aba4 + Aba4 + Aba4 + fish + + + + Gpyc Wdbed + Gpyc Wdbed + Gpyc Wdbed + diamond 1 + + + + Lman 5Rock + Lman 5Rock + Lman 5Rock + diamond 1 + + + + Lman 5R N + Lman 5R N + Lman 5R N + diamond 1 + + + + Mansion 12 + Mansion 12 + Mansion 12 + diamond 1 + + + + 9Ml Rk Pil + 9Ml Rk Pil + 9Ml Rk Pil + diamond 1 + + + + 9Ml Spintp + 9Ml Spintp + 9Ml Spintp + diamond 1 + + + + Bwal Beds1 + Bwal Beds1 + Bwal Beds1 + diamond 1 + + + + 11Mi Wh Rk + 11Mi Wh Rk + 11Mi Wh Rk + diamond 1 + + + + Bsw 14 1 + Bsw 14 1 + Bsw 14 1 + diamond 1 + + + + Bluswl Way13 + Bluswl Way13 + Bluswl Way13 + diamond 1 + + + + Lmarker + Lmarker + Lmarker + diamond 1 + + + + Cn Memprk Rk + Cn Memprk Rk + Cn Memprk Rk + airplane + + + + Cn Memprk R2 + Cn Memprk R2 + Cn Memprk R2 + airplane + + + + 12Mile Cn + 12Mile Cn + 12Mile Cn + diamond 1 + + + + Wht Pav 8F + Wht Pav 8F + Wht Pav 8F + diamond 1 + + + + Crmr9Plt1 + Crmr9Plt1 + Crmr9Plt1 + tree stand + + + + Cfmr9Plt2 + Cfmr9Plt2 + Cfmr9Plt2 + tree stand + + + + 700 4 Hump + 700 4 Hump + 700 4 Hump + x 3 + + + + Pthurn Cn1 + Pthurn Cn1 + Pthurn Cn1 + diamond 1 + + + + Cn Clnt Flat + Cn Clnt Flat + Cn Clnt Flat + diamond 1 + + + + Bet-Crbc Wrk + Bet-Crbc Wrk + Bet-Crbc Wrk + wreck + + + + Jefs Bigrk + Jefs Bigrk + Jefs Bigrk + x 3 + + + + 011 + 011 + 011 + two fish + + + + 012 + 012 + 012 + two fish + + + + Mch Outbrk + Mch Outbrk + Mch Outbrk + diamond 1 + + + + Mg Midchrck + Mg Midchrck + Mg Midchrck + diamond 1 + + + + Old Ch Gap + Old Ch Gap + Old Ch Gap + diamond 1 + + + + Oldsth Wd7 + Oldsth Wd7 + Oldsth Wd7 + diamond 1 + + + + 12Rk Clsrhmp + 12Rk Clsrhmp + 12Rk Clsrhmp + diamond 1 + + + + 12Rk Sml + 12Rk Sml + 12Rk Sml + diamond 1 + + + + 12Rk Closhmp + 12Rk Closhmp + 12Rk Closhmp + diamond 1 + + + + 12Rk Bigi + 12Rk Bigi + 12Rk Bigi + diamond 1 + + + + Wpt 042* + Wpt 042* + Wpt 042* + fish + + + + Wpt 043* + Wpt 043* + Wpt 043* + fish + + + + Wpt 044* + Wpt 044* + Wpt 044* + fish + + + + 009 + 009 + 009 + diamond 1 + + + + 010 + 010 + 010 + diamond 1 + + + + 013 + 013 + 013 + diamond 1 + + + + 014 + 014 + 014 + diamond 1 + + + + 015 + 015 + 015 + diamond 1 + + + + 016 + 016 + 016 + diamond 1 + + + + 017 + 017 + 017 + diamond 1 + + + + 018 + 018 + 018 + diamond 1 + + + + 019 + 019 + 019 + diamond 1 + + + + 020 + 020 + 020 + diamond 1 + + + + 021 + 021 + 021 + diamond 1 + + + + 012 + 012 + 012 + diamond 1 + + + Event Marker 1 + Event Marker 1 + Event Marker 1 + diamond 1 + + + Event Marker 2 + Event Marker 2 + Event Marker 2 + diamond 1 + + + Trail 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Trail 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testo.d/lowranceusr.test b/testo.d/lowranceusr.test index e35692ffa..c6592c364 100644 --- a/testo.d/lowranceusr.test +++ b/testo.d/lowranceusr.test @@ -152,3 +152,16 @@ gpsbabel -i lowranceusr -f ${REFERENCE}/lowrance-v6.usr -o unicsv,utc=0 -F ${TMP tail -n +2 ${TMPDIR}/lowrance-v6-unicsv.txt | sed "s/[0-9]*,//" | sort -t , -k 3 > ${TMPDIR}/lowrance-v6-unicsv-sorted.txt compare ${TMPDIR}/lowrance-v4-unicsv-sorted.txt ${TMPDIR}/lowrance-v6-unicsv-sorted.txt +# test translation of version 2, 3 continuous flag to new track segments. +# 1. when reading usr files can we translate the contiuous flag in a usr file to track segments? +gpsbabel -i lowranceusr -f ${REFERENCE}/lowrance-v2.usr -o gpx -F ${TMPDIR}/lowrance-v2.gpx +compare ${REFERENCE}/lowrance-v2.gpx ${TMPDIR}/lowrance-v2.gpx +# 2. if so, when writing a usr file can we translate a track segment to the continuous flag in the usr file? +gpsbabel -i gpx -f ${REFERENCE}/lowrance-v2.gpx -o lowranceusr -F ${TMPDIR}/lowrance-v2~gpx.usr +gpsbabel -i lowranceusr -f ${TMPDIR}/lowrance-v2~gpx.usr -o gpx -F ${TMPDIR}/lowrance-v2~usr.gpx +compare ${REFERENCE}/lowrance-v2.gpx ${TMPDIR}/lowrance-v2~usr.gpx +# 3. can we get the track segments correct when we do a merge? +gpsbabel -i gpx -f ${REFERENCE}/lowrance-v2.gpx -o lowranceusr,merge -F ${TMPDIR}/lowrance-v2-merge~gpx.usr +gpsbabel -i lowranceusr -f ${TMPDIR}/lowrance-v2-merge~gpx.usr -o gpx -F ${TMPDIR}/lowrance-v2-merge~usr.gpx +compare ${REFERENCE}/lowrance-v2-merge~usr.gpx ${TMPDIR}/lowrance-v2-merge~usr.gpx + From 0080d0410305fdd6e4d4516b4c229693690df670 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:31:08 -0600 Subject: [PATCH 098/132] use a signed type for waypt_counts and route counts. (#1307) * use a signed type for waypt_counts and route counts. Although larger in Qt6, the underlying type is signed. * fix -Wformat-signedness warnings introduced by this PR. * fix new -Wsign-conversion warnings. --- defs.h | 10 +++++----- kml.cc | 2 +- kml.h | 2 +- route.cc | 8 ++++---- tpg.h | 2 +- validate.cc | 20 ++++++++++---------- validate.h | 6 +++--- waypt.cc | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/defs.h b/defs.h index 93f2b5d0b..ae382c924 100644 --- a/defs.h +++ b/defs.h @@ -490,7 +490,7 @@ void waypt_init(); void waypt_add(Waypoint* wpt); void waypt_del(Waypoint* wpt); void del_marked_wpts(); -unsigned int waypt_count(); +int waypt_count(); void waypt_status_disp(int total_ct, int myct); //void waypt_disp_all(waypt_cb); /* template */ //void waypt_disp_session(const session_t* se, waypt_cb cb); /* template */ @@ -674,10 +674,10 @@ class RouteList : private QList }; void route_init(); -unsigned int route_waypt_count(); -unsigned int route_count(); -unsigned int track_waypt_count(); -unsigned int track_count(); +int route_waypt_count(); +int route_count(); +int track_waypt_count(); +int track_count(); route_head* route_head_alloc(); void route_add_head(route_head* rte); void route_del_head(route_head* rte); diff --git a/kml.cc b/kml.cc index db5bfbd75..cacf0385c 100644 --- a/kml.cc +++ b/kml.cc @@ -90,7 +90,7 @@ const QVector KmlFormat::mt_fields_def = { { wp_field::sat, "satellites", "Satellites", "int" }, }; -void KmlFormat::kml_init_color_sequencer(unsigned int steps_per_rev) +void KmlFormat::kml_init_color_sequencer(int steps_per_rev) { if (rotate_colors) { float color_step = strtod(opt_rotate_colors, nullptr); diff --git a/kml.h b/kml.h index eef489c57..4ed4d4008 100644 --- a/kml.h +++ b/kml.h @@ -132,7 +132,7 @@ class KmlFormat : public Format /* Member Functions */ - void kml_init_color_sequencer(unsigned int steps_per_rev); + void kml_init_color_sequencer(int steps_per_rev); static constexpr int kml_bgr_to_color(int blue, int green, int red) { return (blue)<<16 | (green)<<8 | (red); diff --git a/route.cc b/route.cc index a065bd5fb..c4c25f56e 100644 --- a/route.cc +++ b/route.cc @@ -46,27 +46,27 @@ route_init() global_track_list = new RouteList; } -unsigned int +int route_waypt_count() { /* total waypoint count -- all routes */ return global_route_list->waypt_count(); } -unsigned int +int route_count() { return global_route_list->count(); /* total # of routes */ } -unsigned int +int track_waypt_count() { /* total waypoint count -- all tracks */ return global_track_list->waypt_count(); } -unsigned int +int track_count() { return global_track_list->count(); /* total # of tracks */ diff --git a/tpg.h b/tpg.h index 6f4b098d3..0fa129b3b 100644 --- a/tpg.h +++ b/tpg.h @@ -75,7 +75,7 @@ class TpgFormat : public Format char* tpg_datum_opt{}; int tpg_datum_idx{}; - unsigned int waypt_out_count{}; + int waypt_out_count{}; QVector tpg_args = { {"datum", &tpg_datum_opt, "Datum (default=NAD27)", "N. America 1927 mean", ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, diff --git a/validate.cc b/validate.cc index 23cf30b81..f3d20d664 100644 --- a/validate.cc +++ b/validate.cc @@ -64,10 +64,10 @@ void ValidateFilter::process() } waypt_disp_all(validate_point_f); if (debug) { - fprintf(stderr, "point ct: %u, waypt_count: %u\n", point_ct, waypt_count()); + fprintf(stderr, "point ct: %d, waypt_count: %d\n", point_ct, waypt_count()); } if (!debug && (point_ct != waypt_count())) { - fatal(MYNAME ":Waypoint count mismatch, expected %u, actual %u\n", waypt_count(), point_ct); + fatal(MYNAME ":Waypoint count mismatch, expected %d, actual %d\n", waypt_count(), point_ct); } head_ct = 0; @@ -78,14 +78,14 @@ void ValidateFilter::process() } route_disp_all(validate_head_f, validate_head_trl_f, validate_point_f); if (debug) { - fprintf(stderr, "route head ct: %u, route_count: %u\n", head_ct, route_count()); - fprintf(stderr, "total route point ct: %u, route_waypt_count: %u\n", point_ct, route_waypt_count()); + fprintf(stderr, "route head ct: %d, route_count: %d\n", head_ct, route_count()); + fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", point_ct, route_waypt_count()); } if (!debug && (head_ct != route_count())) { - fatal(MYNAME ":Route count mismatch, expected %u, actual %u\n", route_count(), head_ct); + fatal(MYNAME ":Route count mismatch, expected %d, actual %d\n", route_count(), head_ct); } if (!debug && (point_ct != route_waypt_count())) { - fatal(MYNAME ":Total route waypoint count mismatch, expected %u, actual %u\n", route_waypt_count(), point_ct); + fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), point_ct); } head_ct = 0; @@ -96,14 +96,14 @@ void ValidateFilter::process() } track_disp_all(validate_head_f, validate_head_trl_f, validate_point_f); if (debug) { - fprintf(stderr, "track head ct: %u, track_count: %u\n", head_ct, track_count()); - fprintf(stderr, "total track point ct: %u, track_waypt_count: %u\n", point_ct, track_waypt_count()); + fprintf(stderr, "track head ct: %d, track_count: %d\n", head_ct, track_count()); + fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", point_ct, track_waypt_count()); } if (!debug && (head_ct != track_count())) { - fatal(MYNAME ":Track count mismatch, expected %u, actual %u\n", track_count(), head_ct); + fatal(MYNAME ":Track count mismatch, expected %d, actual %d\n", track_count(), head_ct); } if (!debug && (point_ct != track_waypt_count())) { - fatal(MYNAME ":Total track waypoint count mismatch, expected %u, actual %u\n", track_waypt_count(), point_ct); + fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), point_ct); } if (checkempty) { diff --git a/validate.h b/validate.h index eff779d5c..7a91388dc 100644 --- a/validate.h +++ b/validate.h @@ -44,9 +44,9 @@ class ValidateFilter:public Filter bool debug{}; char* opt_checkempty{}; bool checkempty{}; - unsigned int point_ct{}; - unsigned int head_ct{}; - unsigned int segment_ct_start{}; + int point_ct{}; + int head_ct{}; + int segment_ct_start{}; const char* segment_type{}; QVector args = { { diff --git a/waypt.cc b/waypt.cc index f7f0783b8..e7c8c1898 100644 --- a/waypt.cc +++ b/waypt.cc @@ -73,7 +73,7 @@ del_marked_wpts() global_waypoint_list->del_marked_wpts(); } -unsigned int +int waypt_count() { return global_waypoint_list->count(); From 4d8a0dde00bbf7e9c356fb1d197a90f5df211513 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 1 Aug 2024 06:52:03 -0600 Subject: [PATCH 099/132] enhance validate filter to report on track segments. (#1308) --- reference/validate_debug.log | 8 ++++---- validate.cc | 39 +++++++++++++++++++++--------------- validate.h | 4 +++- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/reference/validate_debug.log b/reference/validate_debug.log index 85e4f47e9..55630cc0c 100644 --- a/reference/validate_debug.log +++ b/reference/validate_debug.log @@ -3,11 +3,11 @@ Processing waypts point ct: 2, waypt_count: 2 Processing routes -route 0 ct: 2, waypt_count: 2 -route head ct: 1, route_count: 1 +route 0 ct: 2, waypt_count: 2, segments 1 +route head ct: 1, route_count: 1, total segment count: 1 total route point ct: 2, route_waypt_count: 2 Processing tracks -track 0 ct: 2, waypt_count: 2 -track head ct: 1, track_count: 1 +track 0 ct: 2, waypt_count: 2, segments 1 +track head ct: 1, track_count: 1, total segment count: 1 total track point ct: 2, track_waypt_count: 2 diff --git a/validate.cc b/validate.cc index f3d20d664..9c54f34ca 100644 --- a/validate.cc +++ b/validate.cc @@ -30,23 +30,28 @@ void ValidateFilter::validate_head(const route_head* /*unused*/) { head_ct += 1; - segment_ct_start = point_ct; + point_ct = 0; + segment_ct = 0; } void ValidateFilter::validate_head_trl(const route_head* header) { - int segment_waypt_ct = point_ct - segment_ct_start; + total_point_ct += point_ct; + total_segment_ct += segment_ct; if (debug) { - fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num, segment_waypt_ct, header->rte_waypt_ct()); + fprintf(stderr, "%s %d ct: %d, waypt_count: %d, segments %d\n", segment_type, header->rte_num, point_ct, header->rte_waypt_ct(), segment_ct); } - if (!debug && (segment_waypt_ct != header->rte_waypt_ct())) { - fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), segment_waypt_ct); + if (!debug && (point_ct != header->rte_waypt_ct())) { + fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), point_ct); } } -void ValidateFilter::validate_point(const Waypoint* /*unused*/) +void ValidateFilter::validate_point(const Waypoint* wpt) { point_ct += 1; + if (wpt->wpt_flags.new_trkseg) { + segment_ct += 1; + } } void ValidateFilter::process() @@ -71,39 +76,41 @@ void ValidateFilter::process() } head_ct = 0; - point_ct = 0; + total_point_ct = 0; + total_segment_ct = 0; segment_type = "route"; if (debug) { fprintf(stderr, "\nProcessing routes\n"); } route_disp_all(validate_head_f, validate_head_trl_f, validate_point_f); if (debug) { - fprintf(stderr, "route head ct: %d, route_count: %d\n", head_ct, route_count()); - fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", point_ct, route_waypt_count()); + fprintf(stderr, "route head ct: %d, route_count: %d, total segment count: %d\n", head_ct, route_count(), total_segment_ct); + fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", total_point_ct, route_waypt_count()); } if (!debug && (head_ct != route_count())) { fatal(MYNAME ":Route count mismatch, expected %d, actual %d\n", route_count(), head_ct); } - if (!debug && (point_ct != route_waypt_count())) { - fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), point_ct); + if (!debug && (total_point_ct != route_waypt_count())) { + fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), total_point_ct); } head_ct = 0; - point_ct = 0; + total_point_ct = 0; + total_segment_ct = 0; segment_type = "track"; if (debug) { fprintf(stderr, "\nProcessing tracks\n"); } track_disp_all(validate_head_f, validate_head_trl_f, validate_point_f); if (debug) { - fprintf(stderr, "track head ct: %d, track_count: %d\n", head_ct, track_count()); - fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", point_ct, track_waypt_count()); + fprintf(stderr, "track head ct: %d, track_count: %d, total segment count: %d\n", head_ct, track_count(), total_segment_ct); + fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", total_point_ct, track_waypt_count()); } if (!debug && (head_ct != track_count())) { fatal(MYNAME ":Track count mismatch, expected %d, actual %d\n", track_count(), head_ct); } - if (!debug && (point_ct != track_waypt_count())) { - fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), point_ct); + if (!debug && (total_point_ct != track_waypt_count())) { + fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), total_point_ct); } if (checkempty) { diff --git a/validate.h b/validate.h index 7a91388dc..8c81c8587 100644 --- a/validate.h +++ b/validate.h @@ -45,8 +45,10 @@ class ValidateFilter:public Filter char* opt_checkempty{}; bool checkempty{}; int point_ct{}; + int total_point_ct{}; + int segment_ct{}; + int total_segment_ct{}; int head_ct{}; - int segment_ct_start{}; const char* segment_type{}; QVector args = { { From 85dee0bc67d295fa0f119bda2e31544649332bea Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 2 Aug 2024 06:43:27 -0600 Subject: [PATCH 100/132] cleanup datetime.h tidy and g++ warnings. (#1309) Wsign-conversion readability-implicit-bool-conversion readability-else-after-return cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers --- src/core/datetime.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/core/datetime.h b/src/core/datetime.h index 93b60b34f..579c50089 100644 --- a/src/core/datetime.h +++ b/src/core/datetime.h @@ -37,9 +37,11 @@ // "Better" code in the callers. // Consider putting in a namespace instead of prefixing 'gb'. -namespace gpsbabel { +namespace gpsbabel +{ -class DateTime : public QDateTime { +class DateTime : public QDateTime +{ public: // As a crutch, mimic the old behaviour of an uninitialized creation time // being 1/1/1970. @@ -52,35 +54,38 @@ class DateTime : public QDateTime { // Qt::LocalTime compared to Qt::UTC on ubuntu bionic. // Note that these conversions can be required if the Qt::TimeSpec is // set to Qt:LocalTime after construction. - DateTime() : QDateTime(QDateTime::fromMSecsSinceEpoch(0, Qt::UTC)) { + DateTime() : QDateTime(QDateTime::fromMSecsSinceEpoch(0, Qt::UTC)) + { } DateTime(const QDate& date, const QTime& time) : QDateTime(date, time) {} DateTime(const QDateTime& dt) : QDateTime(dt) {} // Temporary: Override the standard, also handle time_t 0 as invalid. - bool isValid() const { + [[nodiscard]] bool isValid() const + { return QDateTime::isValid() && (toSecsSinceEpoch() != 0); } // Like toString, but with subsecond time that's included only when // the trailing digits aren't .000. Always UTC. - QString toPrettyString() const { - if (time().msec()) { + [[nodiscard]] QString toPrettyString() const + { + if (time().msec() != 0) { return toUTC().toString(QStringLiteral("yyyy-MM-ddTHH:mm:ss.zzzZ")); - } else { - return toUTC().toString(QStringLiteral("yyyy-MM-ddTHH:mm:ssZ")); } + return toUTC().toString(QStringLiteral("yyyy-MM-ddTHH:mm:ssZ")); } // QDateTime::toTime_t was deprecated in Qt5.8, and deleted in Qt6. - uint32_t toTime_t() const { + [[nodiscard]] uint32_t toTime_t() const + { if (!QDateTime::isValid()) { - return -1; + return UINT32_MAX; } long long secs_since_epoch = toSecsSinceEpoch(); - if ((secs_since_epoch < 0) || (secs_since_epoch > 0xfffffffe)) { - return -1; + if ((secs_since_epoch < 0) || (secs_since_epoch >= UINT32_MAX)) { + return UINT32_MAX; } return secs_since_epoch; } From e5c26fb2805e2f9abcea7ba52e42fff5fdb574a0 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:12:58 -0600 Subject: [PATCH 101/132] correct WGS84 semi minor axis value. (#1310) It appears the GSR80 value was used instead of the WGS84 value, which is a very small error. However, there was a typo in the value in GPS_Math_XYZ_To_WGS84LatLonH that resulted in an order of magnitude error! This could lead to GPS_Math_XYZ_To_WGS84LatLonH never converging. This may be why skytraq created their own function to convert ECEF to WGS84. --- jeeps/gpsmath.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jeeps/gpsmath.cc b/jeeps/gpsmath.cc index 8da383fa5..c97b6ad48 100644 --- a/jeeps/gpsmath.cc +++ b/jeeps/gpsmath.cc @@ -457,7 +457,7 @@ void GPS_Math_WGS84LatLonH_To_XYZ(double phi, double lambda, double H, double* x, double* y, double* z) { double a = 6378137.000; - double b = 6356752.3141; + double b = 6356752.314245; GPS_Math_LatLonH_To_XYZ(phi,lambda,H,x,y,z,a,b); @@ -510,7 +510,7 @@ void GPS_Math_XYZ_To_WGS84LatLonH(double* phi, double* lambda, double* H, double x, double y, double z) { double a = 6378137.000; - double b = 66356752.3141; + double b = 6356752.314245; GPS_Math_XYZ_To_LatLonH(phi,lambda,H,x,y,z,a,b); From 3230ea5e6c7abf48c37bedb3833ff95d74d9666c Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:04:13 -0600 Subject: [PATCH 102/132] unify access to ellipsoid parameters (#1312) * define constants for often used spherioid parms. * add function to calculate semi-minor axis. * use semi major axis function more. * have semi_minor_axis consume an ellipse * compute semi minor axis in GPS_Ellipse class. add constants for other ellipses that are used directly. --- jeeps/gpsdatum.h | 29 +++++++++-- jeeps/gpsmath.cc | 101 +++++++++++++++---------------------- reference/grid-bng~csv.gpx | 14 ++--- 3 files changed, 71 insertions(+), 73 deletions(-) diff --git a/jeeps/gpsdatum.h b/jeeps/gpsdatum.h index 2cfbb366a..eea7a3612 100644 --- a/jeeps/gpsdatum.h +++ b/jeeps/gpsdatum.h @@ -6,14 +6,33 @@ struct GPS_Ellipse { const char* name; double a; double invf; + + constexpr double b() const { + return a - a/invf; + } }; +// EPSG:7001 +constexpr GPS_Ellipse Airy1830_Ellipse = { "Airy 1830", 6377563.396, 299.3249646 }; + +// EPSG:7002 +constexpr GPS_Ellipse Airy1830Modified_Ellipse = { "Airy 1830 Modified", 6377340.189, 299.3249646 }; + +// EPSG:7004 +constexpr GPS_Ellipse Bessel1841_Ellipse = { "Bessel 1841", 6377397.155, 299.1528128 }; + +// EPSG:7019 +constexpr GPS_Ellipse GRS80_Ellipse = { "GRS80", 6378137.000, 298.257222101 }; + +// EPSG:4326 +constexpr GPS_Ellipse WGS84_Ellipse = { "WGS84", 6378137.000, 298.257223563 }; + const GPS_Ellipse GPS_Ellipses[]= { - { "Airy 1830", 6377563.396, 299.3249646 }, - { "Airy 1830 Modified", 6377340.189, 299.3249646 }, + Airy1830_Ellipse, + Airy1830Modified_Ellipse, { "Australian National", 6378160.000, 298.25 }, { "Bessel 1841 (Namibia)", 6377483.865, 299.1528128 }, - { "Bessel 1841", 6377397.155, 299.1528128 }, + Bessel1841_Ellipse, { "Clarke 1866", 6378206.400, 294.9786982 }, { "Clarke 1880", 6378249.145, 293.465 }, { "Everest (India 1830)", 6377276.345, 300.8017 }, @@ -30,12 +49,12 @@ const GPS_Ellipse GPS_Ellipses[]= { { "Krassovsky 1940", 6378245.000, 298.3 }, { "GRS67", 6378160.000, 6356774.516 }, { "GRS75", 6378140.000, 6356755.288 }, - { "GRS80", 6378137.000, 298.257222101 }, + GRS80_Ellipse, { "S. American 1969", 6378160.000, 298.25 }, { "WGS60", 6378165.000, 298.3 }, { "WGS66", 6378145.000, 298.25 }, { "WGS72", 6378135.000, 298.26 }, - { "WGS84", 6378137.000, 298.257223563 }, + WGS84_Ellipse, { "Clarke 1880 (Benoit)", 6378300.789, 293.466 }, }; diff --git a/jeeps/gpsmath.cc b/jeeps/gpsmath.cc index c97b6ad48..6edfb5a14 100644 --- a/jeeps/gpsmath.cc +++ b/jeeps/gpsmath.cc @@ -429,8 +429,8 @@ void GPS_Math_XYZ_To_LatLonH(double* phi, double* lambda, double* H, void GPS_Math_Airy1830LatLonH_To_XYZ(double phi, double lambda, double H, double* x, double* y, double* z) { - double a = 6377563.396; - double b = 6356256.910; + constexpr double a = Airy1830_Ellipse.a; + constexpr double b = Airy1830_Ellipse.b(); GPS_Math_LatLonH_To_XYZ(phi,lambda,H,x,y,z,a,b); @@ -456,8 +456,8 @@ void GPS_Math_Airy1830LatLonH_To_XYZ(double phi, double lambda, double H, void GPS_Math_WGS84LatLonH_To_XYZ(double phi, double lambda, double H, double* x, double* y, double* z) { - double a = 6378137.000; - double b = 6356752.314245; + constexpr double a = WGS84_Ellipse.a; + constexpr double b = WGS84_Ellipse.b(); GPS_Math_LatLonH_To_XYZ(phi,lambda,H,x,y,z,a,b); @@ -483,8 +483,8 @@ void GPS_Math_WGS84LatLonH_To_XYZ(double phi, double lambda, double H, void GPS_Math_XYZ_To_Airy1830LatLonH(double* phi, double* lambda, double* H, double x, double y, double z) { - double a = 6377563.396; - double b = 6356256.910; + constexpr double a = Airy1830_Ellipse.a; + constexpr double b = Airy1830_Ellipse.b(); GPS_Math_XYZ_To_LatLonH(phi,lambda,H,x,y,z,a,b); @@ -509,8 +509,8 @@ void GPS_Math_XYZ_To_Airy1830LatLonH(double* phi, double* lambda, double* H, void GPS_Math_XYZ_To_WGS84LatLonH(double* phi, double* lambda, double* H, double x, double y, double z) { - double a = 6378137.000; - double b = 6356752.314245; + constexpr double a = WGS84_Ellipse.a; + constexpr double b = WGS84_Ellipse.b(); GPS_Math_XYZ_To_LatLonH(phi,lambda,H,x,y,z,a,b); @@ -643,8 +643,8 @@ void GPS_Math_Airy1830M_LatLonToINGEN(double phi, double lambda, double* E, double F0 = 1.000035; double phi0 = 53.5; double lambda0 = -8.; - double a = 6377340.189; - double b = 6356034.447; + constexpr double a = Airy1830Modified_Ellipse.a; + constexpr double b = Airy1830Modified_Ellipse.b(); GPS_Math_LatLon_To_EN(E,N,phi,lambda,N0,E0,phi0,lambda0,F0,a,b); @@ -674,8 +674,8 @@ void GPS_Math_Airy1830LatLonToNGEN(double phi, double lambda, double* E, double F0 = 0.9996012717; double phi0 = 49.; double lambda0 = -2.; - double a = 6377563.396; - double b = 6356256.910; + constexpr double a = Airy1830_Ellipse.a; + constexpr double b = Airy1830_Ellipse.b(); GPS_Math_LatLon_To_EN(E,N,phi,lambda,N0,E0,phi0,lambda0,F0,a,b); @@ -704,7 +704,7 @@ int32_t GPS_Math_WGS84_To_Swiss_EN(double lat, double lon, double* E, const double lambda0 = 7.43958333; const double E0 = 600000.0; const double N0 = 200000.0; - double phi, lambda, alt, a, b; + double phi, lambda, alt; if (lat < 44.89022757) { return 0; @@ -713,9 +713,8 @@ int32_t GPS_Math_WGS84_To_Swiss_EN(double lat, double lon, double* E, return 0; } - assert(strcmp(GPS_Ellipses[4].name, "Bessel 1841") == 0); - a = GPS_Ellipses[4].a; - b = a - (a / GPS_Ellipses[4].invf); + constexpr double a = Bessel1841_Ellipse.a; + constexpr double b = Bessel1841_Ellipse.b(); GPS_Math_WGS84_To_Known_Datum_M(lat, lon, 0, &phi, &lambda, &alt, 123); GPS_Math_Swiss_LatLon_To_EN(phi, lambda, E, N, phi0, lambda0, E0, N0, a, b); @@ -742,11 +741,10 @@ void GPS_Math_Swiss_EN_To_WGS84(double E, double N, double* lat, double* lon) const double lambda0 = 7.43958333; const double E0 = 600000.0; const double N0 = 200000.0; - double phi, lambda, alt, a, b; + double phi, lambda, alt; - assert(strcmp(GPS_Ellipses[4].name, "Bessel 1841") == 0); - a = GPS_Ellipses[4].a; - b = a - (a / GPS_Ellipses[4].invf); + constexpr double a = Bessel1841_Ellipse.a; + constexpr double b = Bessel1841_Ellipse.b(); GPS_Math_Swiss_EN_To_LatLon(E, N, &phi, &lambda, phi0, lambda0, E0, N0, a, b); GPS_Math_Known_Datum_To_WGS84_M(phi, lambda, 0, lat, lon, &alt, 123); @@ -1112,7 +1110,7 @@ int32_t GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, int32_t ellipse = GPS_Datums[datum].ellipse; a = GPS_Ellipses[ellipse].a; - b = a - (a / GPS_Ellipses[ellipse].invf); + b = GPS_Ellipses[ellipse].b(); GPS_Math_WGS84_To_Known_Datum_M(lat, lon, 0, &phi, &lambda, &alt, datum); GPS_Math_Cassini_LatLon_To_EN(phi, lambda, E, N, @@ -1148,7 +1146,7 @@ void GPS_Math_ICS_EN_To_WGS84(double E, double N, double* lat, double* lon) int32_t ellipse = GPS_Datums[datum].ellipse; a = GPS_Ellipses[ellipse].a; - b = a - (a / GPS_Ellipses[ellipse].invf); + b = GPS_Ellipses[ellipse].b(); GPS_Math_Cassini_EN_To_LatLon(E, N, &phi, &lambda, phi0, lambda0, E0, N0, a, b); @@ -1307,8 +1305,8 @@ void GPS_Math_NGENToAiry1830LatLon(double E, double N, double* phi, double F0 = 0.9996012717; double phi0 = 49.; double lambda0 = -2.; - double a = 6377563.396; - double b = 6356256.910; + constexpr double a = Airy1830_Ellipse.a; + constexpr double b = Airy1830_Ellipse.b(); GPS_Math_EN_To_LatLon(E,N,phi,lambda,N0,E0,phi0,lambda0,F0,a,b); @@ -1337,8 +1335,8 @@ void GPS_Math_INGENToAiry1830MLatLon(double E, double N, double* phi, double F0 = 1.000035; double phi0 = 53.5; double lambda0 = -8.; - double a = 6377340.189; - double b = 6356034.447; + constexpr double a = Airy1830Modified_Ellipse.a; + constexpr double b = Airy1830Modified_Ellipse.b(); GPS_Math_EN_To_LatLon(E,N,phi,lambda,N0,E0,phi0,lambda0,F0,a,b); @@ -1539,15 +1537,13 @@ void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, { double Sa; double Sif; - double Da; - double Dif; double x; double y; double z; int32_t idx; - Da = 6378137.0; - Dif = 298.257223563; + constexpr double Da = WGS84_Ellipse.a; + constexpr double Dif = WGS84_Ellipse.invf; idx = GPS_Datums[n].ellipse; Sa = GPS_Ellipses[idx].a; @@ -1581,8 +1577,6 @@ void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, int32_t n) { - double Sa; - double Sif; double Da; double Dif; double x; @@ -1590,8 +1584,8 @@ void GPS_Math_WGS84_To_Known_Datum_M(double Sphi, double Slam, double SH, double z; int32_t idx; - Sa = 6378137.0; - Sif = 298.257223563; + constexpr double Sa = WGS84_Ellipse.a; + constexpr double Sif = WGS84_Ellipse.invf; idx = GPS_Datums[n].ellipse; Da = GPS_Ellipses[idx].a; @@ -1628,9 +1622,6 @@ void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, double Sa; double Sif; double Sb; - double Da; - double Dif; - double Db; double x; double y; double z; @@ -1639,9 +1630,8 @@ void GPS_Math_Known_Datum_To_WGS84_C(double Sphi, double Slam, double SH, double sy; double sz; - Da = 6378137.0; - Dif = 298.257223563; - Db = Da - (Da / Dif); + constexpr double Da = WGS84_Ellipse.a; + constexpr double Db = WGS84_Ellipse.b(); idx = GPS_Datums[n].ellipse; Sa = GPS_Ellipses[idx].a; @@ -1682,23 +1672,19 @@ void GPS_Math_WGS84_To_Known_Datum_C(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, int32_t n) { - double Sa; - double Sif; double Da; double Dif; double x; double y; double z; int32_t idx; - double Sb; double Db; double dx; double dy; double dz; - Sa = 6378137.0; - Sif = 298.257223563; - Sb = Sa - (Sa / Sif); + constexpr double Sa = WGS84_Ellipse.a; + constexpr double Sb = WGS84_Ellipse.b(); idx = GPS_Datums[n].ellipse; Da = GPS_Ellipses[idx].a; @@ -1803,9 +1789,7 @@ void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, double* DH, int32_t n1, int32_t n2) { double Sa; - double Sif; double Da; - double Dif; double x1; double y1; double z1; @@ -1824,8 +1808,7 @@ void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, idx1 = GPS_Datums[n1].ellipse; Sa = GPS_Ellipses[idx1].a; - Sif = GPS_Ellipses[idx1].invf; - Sb = Sa - (Sa / Sif); + Sb = GPS_Ellipses[idx1].b(); x1 = GPS_Datums[n1].dx; y1 = GPS_Datums[n1].dy; @@ -1833,8 +1816,7 @@ void GPS_Math_Known_Datum_To_Known_Datum_C(double Sphi, double Slam, double SH, idx2 = GPS_Datums[n2].ellipse; Da = GPS_Ellipses[idx2].a; - Dif = GPS_Ellipses[idx2].invf; - Db = Da - (Da / Dif); + Db = GPS_Ellipses[idx2].b(); x2 = GPS_Datums[n2].dx; y2 = GPS_Datums[n2].dy; @@ -2116,8 +2098,6 @@ int32_t GPS_Math_NAD83_To_UTM_EN(double lat, double lon, double* E, double N0; double E0; double F0; - double a; - double b; if (!GPS_Math_LatLon_To_UTM_Param(lat,lon,zone,zc,&lambda0,&E0, &N0,&F0)) { @@ -2126,9 +2106,8 @@ int32_t GPS_Math_NAD83_To_UTM_EN(double lat, double lon, double* E, phi0 = 0.0; - assert(strcmp(GPS_Ellipses[21].name, "GRS80") == 0); - a = GPS_Ellipses[21].a; - b = a - (a / GPS_Ellipses[21].invf); + constexpr double a = GRS80_Ellipse.a; + constexpr double b = GRS80_Ellipse.b(); GPS_Math_LatLon_To_EN(E,N,lat,lon,N0,E0,phi0,lambda0,F0,a,b); @@ -2294,7 +2273,7 @@ int32_t GPS_Math_Known_Datum_To_UTM_EN(double lat, double lon, double* E, idx = GPS_Datums[n].ellipse; a = GPS_Ellipses[idx].a; - b = a - (a / GPS_Ellipses[idx].invf); + b = GPS_Ellipses[idx].b(); GPS_Math_LatLon_To_EN(E,N,lat,lon,N0,E0,phi0,lambda0,F0,a,b); @@ -2517,7 +2496,7 @@ void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, //found at http://www.gpsy.com/gpsinfo/geotoutm/index.html double k0 = 0.9996; - double a, b; + double a, f; double eccSquared; double eccPrimeSquared; double e1; @@ -2526,8 +2505,8 @@ void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, double x, y; a = GPS_Ellipses[ReferenceEllipsoid].a; - b = 1 / GPS_Ellipses[ReferenceEllipsoid].invf; - eccSquared = b * (2.0 - b); + f = 1 / GPS_Ellipses[ReferenceEllipsoid].invf; + eccSquared = f * (2.0 - f); e1 = (1-sqrt(1-eccSquared))/(1+sqrt(1-eccSquared)); x = UTMEasting - E0; //remove false easting diff --git a/reference/grid-bng~csv.gpx b/reference/grid-bng~csv.gpx index 0c361caec..ddcb600ea 100644 --- a/reference/grid-bng~csv.gpx +++ b/reference/grid-bng~csv.gpx @@ -1,8 +1,8 @@ - - + + AlineLodge Aline Lodge @@ -16,7 +16,7 @@ Caernarfon City (Small) - + Camborne Camborne @@ -37,28 +37,28 @@ Forfar City (Small) - + Hawick Hawick Hawick City (Small) - + Hosta Hosta Hosta City (Small) - + IsleofRhum Isle of Rhum Isle of Rhum City (Small) - + Lerwick Lerwick From bc88336ac4a5f24191d1e2174756fdd2f86e672d Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 7 Aug 2024 16:30:29 -0600 Subject: [PATCH 103/132] spell Datum (#1313) --- defs.h | 2 +- exif.cc | 2 +- garmin_txt.cc | 4 ++-- main.cc | 2 +- nmea.cc | 4 ++-- ozi.cc | 2 +- parse.cc | 6 +++--- unicsv.cc | 20 ++++++++++---------- xcsv.cc | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/defs.h b/defs.h index ae382c924..85465104c 100644 --- a/defs.h +++ b/defs.h @@ -116,7 +116,7 @@ constexpr double MPH_TO_MPS(double a) { return a * kMPSPerMPH;} constexpr double KNOTS_TO_MPS(double a) {return a * kMPSPerKnot;} constexpr int kDatumOSGB36 = 86; // GPS_Lookup_Datum_Index("OSGB36") -constexpr int kDautmWGS84 = 118; // GPS_Lookup_Datum_Index("WGS 84") +constexpr int kDatumWGS84 = 118; // GPS_Lookup_Datum_Index("WGS 84") /* diff --git a/exif.cc b/exif.cc index 14d194865..4982f5989 100644 --- a/exif.cc +++ b/exif.cc @@ -851,7 +851,7 @@ ExifFormat::exif_waypt_from_exif_app(ExifApp* app) const if (idatum < 0) { fatal(MYNAME ": Unknown GPSMapDatum \"%s\"!\n", datum.constData()); } - if (idatum != kDautmWGS84) { + if (idatum != kDatumWGS84) { GPS_Math_WGS84_To_Known_Datum_M(wpt->latitude, wpt->longitude, 0.0, &wpt->latitude, &wpt->longitude, &alt, idatum); } diff --git a/garmin_txt.cc b/garmin_txt.cc index db0db9a84..bf429eae0 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -119,7 +119,7 @@ GarminTxtFormat::convert_datum(const Waypoint* wpt, double* dest_lat, double* de { double alt; - if (datum_index == kDautmWGS84) { + if (datum_index == kDatumWGS84) { *dest_lat = wpt->latitude; *dest_lon = wpt->longitude; } else GPS_Math_WGS84_To_Known_Datum_M(wpt->latitude, wpt->longitude, 0.0, @@ -697,7 +697,7 @@ GarminTxtFormat::wr_init(const QString& fname) datum_index = kDatumOSGB36; break; case grid_swiss: /* force datum to WGS84 */ - datum_index = kDautmWGS84; + datum_index = kDatumWGS84; break; default: datum_index = gt_lookup_datum_index(datum_str, MYNAME); diff --git a/main.cc b/main.cc index 690950b4a..7667c1af9 100644 --- a/main.cc +++ b/main.cc @@ -804,7 +804,7 @@ main(int argc, char* argv[]) } assert(GPS_Lookup_Datum_Index("OSGB36") == kDatumOSGB36); - assert(GPS_Lookup_Datum_Index("WGS 84") == kDautmWGS84); + assert(GPS_Lookup_Datum_Index("WGS 84") == kDatumWGS84); Vecs::Instance().init_vecs(); FilterVecs::Instance().init_filter_vecs(); diff --git a/nmea.cc b/nmea.cc index e4087aa21..2a2c90d0d 100644 --- a/nmea.cc +++ b/nmea.cc @@ -191,7 +191,7 @@ NmeaFormat::nmea_add_wpt(Waypoint* wpt, route_head* trk) const // This also indicates to nmea_release_wpt that ownership has been // transferred to either the global_waypoint_list or global_track_list. wpt->extra_data = nullptr; - if (datum != kDautmWGS84) { + if (datum != kDatumWGS84) { double lat; double lon; double alt; @@ -223,7 +223,7 @@ NmeaFormat::rd_init(const QString& fname) { curr_waypt = nullptr; last_waypt = nullptr; - datum = kDautmWGS84; + datum = kDatumWGS84; had_checksum = false; CHECK_BOOL(opt_gprmc); diff --git a/ozi.cc b/ozi.cc index 8b981c4da..83d343b2b 100644 --- a/ozi.cc +++ b/ozi.cc @@ -126,7 +126,7 @@ OziFormat::ozi_set_time_str(const QString& str, Waypoint* waypointp) void OziFormat::ozi_convert_datum(Waypoint* wpt) const { - if (datum != kDautmWGS84) { + if (datum != kDatumWGS84) { double lat; double lon; double alt; diff --git a/parse.cc b/parse.cc index c1cb6b2ea..bd03cb42e 100644 --- a/parse.cc +++ b/parse.cc @@ -214,7 +214,7 @@ parse_coordinates(const char* str, int datum, const grid_type grid, break; case grid_bng: - datum = kDautmWGS84; /* fix */ + datum = kDatumWGS84; /* fix */ format = "%2s %lf %lf%n"; ct = sscanf(str, format, map, &lx, &ly, @@ -246,7 +246,7 @@ parse_coordinates(const char* str, int datum, const grid_type grid, double east; double north; - datum = kDautmWGS84; /* fix */ + datum = kDatumWGS84; /* fix */ format = "%lf %lf%n"; ct = sscanf(str, format, &east, &north, &result); @@ -273,7 +273,7 @@ parse_coordinates(const char* str, int datum, const grid_type grid, lon = -lon; } - if (datum != kDautmWGS84) { + if (datum != kDatumWGS84) { double alt; GPS_Math_Known_Datum_To_WGS84_M(lat, lon, 0.0, &lat, &lon, &alt, datum); diff --git a/unicsv.cc b/unicsv.cc index 642af6262..ab1534de9 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -606,7 +606,7 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) &wpt->latitude, &wpt->longitude, MYNAME); /* coordinates from parse_coordinates are in WGS84 don't convert a second time */ - src_datum = kDautmWGS84; + src_datum = kDatumWGS84; break; case fld_bng: @@ -614,7 +614,7 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) &wpt->latitude, &wpt->longitude, MYNAME); /* coordinates from parse_coordinates are in WGS84 don't convert a second time */ - src_datum = kDautmWGS84; + src_datum = kDatumWGS84; break; case fld_bng_zone: @@ -630,11 +630,11 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) break; case fld_swiss: - parse_coordinates(value, kDautmWGS84, grid_swiss, + parse_coordinates(value, kDatumWGS84, grid_swiss, &wpt->latitude, &wpt->longitude, MYNAME); /* coordinates from parse_coordinates are in WGS84 don't convert a second time */ - src_datum = kDautmWGS84; + src_datum = kDatumWGS84; break; case fld_swiss_easting: @@ -1029,15 +1029,15 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) fatal(MYNAME ": Unable to convert BNG coordinates (%s %.f %.f)!\n", CSTR(bng_zone), bng_easting, bng_northing); } - src_datum = kDautmWGS84; /* don't convert afterwards */ + src_datum = kDatumWGS84; /* don't convert afterwards */ } else if ((swiss_easting != kUnicsvUnknown) && (swiss_northing != kUnicsvUnknown)) { GPS_Math_Swiss_EN_To_WGS84(swiss_easting, swiss_northing, &wpt->latitude, &wpt->longitude); - src_datum = kDautmWGS84; /* don't convert afterwards */ + src_datum = kDatumWGS84; /* don't convert afterwards */ } } - if ((src_datum != kDautmWGS84) && + if ((src_datum != kDatumWGS84) && (wpt->latitude != kUnicsvUnknown) && (wpt->longitude != kUnicsvUnknown)) { double alt; GPS_Math_Known_Datum_To_WGS84_M(wpt->latitude, wpt->longitude, 0.0, @@ -1286,7 +1286,7 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) QString shortname = wpt->shortname; const garmin_fs_t* gmsd = garmin_fs_t::find(wpt); - if (unicsv_datum_idx == kDautmWGS84) { + if (unicsv_datum_idx == kDatumWGS84) { lat = wpt->latitude; lon = wpt->longitude; alt = wpt->altitude; @@ -1684,7 +1684,7 @@ UnicsvFormat::wr_init(const QString& fname) unicsv_outp_flags.reset(); unicsv_grid_idx = grid_unknown; - unicsv_datum_idx = kDautmWGS84; + unicsv_datum_idx = kDatumWGS84; unicsv_fieldsep = kUnicsvFieldSep; unicsv_waypt_ct = 0; @@ -1709,7 +1709,7 @@ UnicsvFormat::wr_init(const QString& fname) } else if (unicsv_grid_idx == grid_swiss) /* ! ignore parameter "Datum" ! */ { - unicsv_datum_idx = kDautmWGS84; /* internal, becomes CH1903 */ + unicsv_datum_idx = kDatumWGS84; /* internal, becomes CH1903 */ } else { unicsv_datum_idx = gt_lookup_datum_index(opt_datum, MYNAME); } diff --git a/xcsv.cc b/xcsv.cc index b655b1087..23266cd6a 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -907,7 +907,7 @@ XcsvFormat::read() wpt_tmp->longitude = -wpt_tmp->longitude; } - if ((xcsv_file->gps_datum_idx > -1) && (xcsv_file->gps_datum_idx != kDautmWGS84)) { + if ((xcsv_file->gps_datum_idx > -1) && (xcsv_file->gps_datum_idx != kDatumWGS84)) { double alt; GPS_Math_Known_Datum_To_WGS84_M(wpt_tmp->latitude, wpt_tmp->longitude, 0.0, &wpt_tmp->latitude, &wpt_tmp->longitude, &alt, xcsv_file->gps_datum_idx); @@ -918,7 +918,7 @@ XcsvFormat::read() &wpt_tmp->longitude, parse_data.utm_easting, parse_data.utm_northing, parse_data.utm_zone, parse_data.utm_zonec, - kDautmWGS84); + kDatumWGS84); } if (parse_data.link_) { @@ -1036,7 +1036,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) description = shortname; } - if ((xcsv_file->gps_datum_idx > -1) && (xcsv_file->gps_datum_idx != kDautmWGS84)) { + if ((xcsv_file->gps_datum_idx > -1) && (xcsv_file->gps_datum_idx != kDatumWGS84)) { double alt; GPS_Math_WGS84_To_Known_Datum_M(latitude, longitude, 0.0, &latitude, &longitude, &alt, xcsv_file->gps_datum_idx); From 3911278e2aaa01a0bd8af3555d8b811089396f5a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:07:18 -0600 Subject: [PATCH 104/132] Use Helmert transform for conversions between OSGB36 and WSG84 (#1311) * use Helmert transform for OSBG36 <-> WGS84. * adjust unicsv_grids reference for Helmert xform. * update copyright. * use constexpr to select helmert inversion method. * tweak helmert. --- garmin_txt.cc | 4 +- jeeps/gpsmath.cc | 237 ++++++++++++++++++++++++++++++++++++- jeeps/gpsmath.h | 14 +++ parse.cc | 2 +- reference/bngtest.csv | 3 + reference/bngtest.gpx | 17 +++ reference/grid-bng~csv.gpx | 28 ++--- testo.d/unicsv.test | 5 + unicsv.cc | 8 +- xcsv.cc | 4 +- 10 files changed, 298 insertions(+), 24 deletions(-) create mode 100644 reference/bngtest.csv create mode 100644 reference/bngtest.gpx diff --git a/garmin_txt.cc b/garmin_txt.cc index bf429eae0..07fd83051 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -56,7 +56,7 @@ #include "formspec.h" // for FormatSpecificDataList #include "garmin_fs.h" // for garmin_fs_t #include "garmin_tables.h" // for gt_display_modes_e, gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, gt_get_mps_grid_longname, gt_lookup_datum_index, gt_lookup_grid_type, GDB, gt_get_icao_cc, gt_get_icao_country, gt_get_mps_datum_name, gt_waypt_class_names, GT_DISPLAY_MODE... -#include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS84_To_UKOSMap_M +#include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS84_To_UKOSMap_H #include "src/core/datetime.h" // for DateTime #include "src/core/logging.h" // for FatalMsg #include "src/core/textstream.h" // for TextStream @@ -243,7 +243,7 @@ GarminTxtFormat::print_position(const Waypoint* wpt) case grid_bng: - valid = GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map); + valid = GPS_Math_WGS84_To_UKOSMap_H(wpt->latitude, wpt->longitude, &east, &north, map); if (valid) { *fout << QString::asprintf("%s %5.0f %5.0f\t", map, east, north); } diff --git a/jeeps/gpsmath.cc b/jeeps/gpsmath.cc index 6edfb5a14..6c539f94f 100644 --- a/jeeps/gpsmath.cc +++ b/jeeps/gpsmath.cc @@ -4,6 +4,7 @@ ** @author Copyright (C) 1999 Alan Bleasby ** @version 1.0 ** @modified Dec 28 1999 Alan Bleasby. First version +** @modified Copyright (C) 2024 Robert Lipe ** @@ ** ** This library is free software; you can redistribute it and/or @@ -23,7 +24,6 @@ ********************************************************************/ #include "jeeps/gpsmath.h" -#include // for assert #include // for sin, tan, cos, pow, log, sqrt, asin, atan, exp, fabs, round #include // for int32_t #include // for abs @@ -35,6 +35,7 @@ #include "defs.h" // for case_ignore_strcmp, fatal, CSTR #include "jeeps/gpsdatum.h" // for GPS_ODatum, GPS_OEllipse, GPS_Datums, GPS_Ellipses, UKNG, GPS_SDatum_Alias, GPS_SDatum, GPS_DatumAliases, GPS_PDatum, GPS_PDatum_Alias +static constexpr bool use_exact_helmert_inverse = false; static int32_t GPS_Math_LatLon_To_UTM_Param(double lat, double lon, int32_t* zone, char* zc, double* Mc, double* E0, @@ -1516,6 +1517,96 @@ void GPS_Math_Molodensky(double Sphi, double Slam, double SH, double Sa, } +/* @func GPS_Math_Helmert ******************************************* +** +** Transform one datum to another +** +** @param [r] Sx [double] source X +** @param [r] Sy [double] source Y +** @param [r] Sz [double] source Z +** @param [w] Dx [double*] converted X +** @param [w] Dy [double*] converted Y +** @param [w] Dz [double*] converted Z +** @param [r] tX [double] translation along x axis (meters) +** @param [r] tY [double] translation along y axis (meters) +** @param [r] tZ [double] translation along z axis (meters) +** @param [r] sppm [double] scale factor - 1 (ppm) +** @param [r] rXs [double] rotation about x axis (seconds) +** @param [r] rYs [double] rotation about y axis (seconds) +** @param [r] rZs [double] rotation about z axis (seconds) +** +** @return [void] +************************************************************************/ +void GPS_Math_Helmert(double Sx, double Sy, double Sz, + double* Dx, double* Dy, double* Dz, + double tX, double tY, double tZ, + double sppm, + double rXs, double rYs, double rZs) +{ + double s = sppm * 1e-6; + constexpr double radians_per_second = (1.0/(60.0*60.0)) * GPS_PI/180.0; + double rX = rXs * radians_per_second; /* radians */ + double rY = rYs * radians_per_second; /* radians */ + double rZ = rZs * radians_per_second; /* radians */ + + // rotation/scaling matrix = [1+s -rz ry;rz 1+s -rx;-ry rx 1+s]; + *Dx = tX + (1 + s)*Sx + -rZ*Sy + rY*Sz; + *Dy = tY + rZ*Sx + (1 + s)*Sy + -rX*Sz; + *Dz = tZ + -rY*Sx + rX*Sy + (1 + s)*Sz; +} + +/* @func GPS_Math_Inverse_Helmert *********************************** +** +** Transform from source to coverted datum. +** translation, scale and rotation parameters are the Helmert parameters +** to traslate from the converted to source datum! +** +** @param [r] Sx [double] source X +** @param [r] Sy [double] source Y +** @param [r] Sz [double] source Z +** @param [w] Dx [double*] converted X +** @param [w] Dy [double*] converted Y +** @param [w] Dz [double*] converted Z +** @param [r] tX [double] translation along x axis (meters) +** @param [r] tY [double] translation along y axis (meters) +** @param [r] tZ [double] translation along z axis (meters) +** @param [r] sppm [double] scale factor - 1 (ppm) +** @param [r] rXs [double] rotation about x axis (seconds) +** @param [r] rYs [double] rotation about y axis (seconds) +** @param [r] rZs [double] rotation about z axis (seconds) +** +** @return [void] +************************************************************************/ +void GPS_Math_Inverse_Helmert(double Sx, double Sy, double Sz, + double* Dx, double* Dy, double* Dz, + double tX, double tY, double tZ, + double sppm, + double rXs, double rYs, double rZs) +{ + double s = sppm * 1e-6; + constexpr double radians_per_second = (1.0/(60.0*60.0)) * GPS_PI/180.0; + double rX = rXs * radians_per_second; /* radians */ + double rY = rYs * radians_per_second; /* radians */ + double rZ = rZs * radians_per_second; /* radians */ + + // forward rotation/scaling matrix is [1+s -rz ry;rz 1+s -rx;-ry rx 1+s] + // compute inverse of forward Helmert rotation/scaling matrix + // https://www.wolframalpha.com/input?i2d=true&i=Power%5B%7B%7B1%2Bs%2C-Subscript%5Br%2Cz%5D%2CSubscript%5Br%2Cy%5D%7D%2C%7BSubscript%5Br%2Cz%5D%2C1%2Bs%2C-Subscript%5Br%2Cx%5D%7D%2C%7B-Subscript%5Br%2Cy%5D%2CSubscript%5Br%2Cx%5D%2C1%2Bs%7D%7D%2C-1%5D + double gain = 1/((s + 1) * (rX*rX + rY*rY + rZ*rZ + s*s + 2*s + 1)); + double r11 = rX*rX + s*s + 2*s + 1; + double r12 = s*rZ + rX*rY + rZ; + double r13 = -s*rY + rX*rZ - rY; + double r21 = -s*rZ + rX*rY - rZ; + double r22 = rY*rY + s*s + 2*s + 1; + double r23 = s*rX + rX + rY*rZ; + double r31 = s*rY + rX*rZ + rY; + double r32 = -s*rX - rX + rY*rZ; + double r33 = rZ*rZ + s*s + 2*s + 1; + + *Dx = gain * ((r11 * (Sx-tX)) + (r12 * (Sy-tY)) + (r13 * (Sz-tZ))); + *Dy = gain * ((r21 * (Sx-tX)) + (r22 * (Sy-tY)) + (r23 * (Sz-tZ))); + *Dz = gain * ((r31 * (Sx-tX)) + (r32 * (Sy-tY)) + (r33 * (Sz-tZ))); +} /* @func GPS_Math_Known_Datum_To_WGS84_M ********************************** ** @@ -1904,6 +1995,150 @@ int32_t GPS_Math_UKOSMap_To_WGS84_M(const char* map, double mE, double mN, } +/* @func GPS_Math_WGS84_To_UKOSMap_H *********************************** +** +** Convert WGS84 lat/lon to Ordnance survey map code and easting and +** northing. Uses Helmert. +** +** @param [r] lat [double] WGS84 latitude (deg) +** @param [r] lon [double] WGS84 longitude (deg) +** @param [w] mE [double *] map easting (metres) +** @param [w] mN [double *] map northing (metres) +** @param [w] map [char *] map two letter code +** +** @return [int32] success +************************************************************************/ +int32_t GPS_Math_WGS84_To_UKOSMap_H(double lat, double lon, double* mE, + double* mN, char* map) +{ + double x; + double y; + double z; + double ax; + double ay; + double az; + double alat; + double alon; + double ah; + double aE; + double aN; + + + GPS_Math_WGS84LatLonH_To_XYZ(lat, lon, 0, + &x, &y, &z); + + /* Helmert transformation + * https://www.ordnancesurvey.co.uk/documents/resources/guide-coordinate-systems-great-britain.pdf + * 6.2 Helmert datum transformations + * 6.6 Approximate WGS84 to OSGB36/ODN transformation + */ + // WGS84 -> OSGB36 + constexpr double tX = -446.448; /* meters */ + constexpr double tY = +125.157; /* meters */ + constexpr double tZ = -542.060; /* meters */ + constexpr double s = +20.4894; /* ppm */ + constexpr double rX = -0.1502; /* seconds */ + constexpr double rY = -0.2470; /* seconds */ + constexpr double rZ = -0.8421; /* seconds */ + + GPS_Math_Helmert(x, y, z, + &ax, &ay, &az, + tX, tY, tZ, + s, + rX, rY, rZ); + + GPS_Math_XYZ_To_Airy1830LatLonH(&alat, &alon, &ah, + ax, ay, az); + GPS_Math_Airy1830LatLonToNGEN(alat, alon, + &aE, &aN); + if (!GPS_Math_EN_To_UKOSNG_Map(aE,aN,mE,mN,map)) { + return 0; + } + + return 1; +} + + +/* @func GPS_Math_UKOSMap_To_WGS84_H *********************************** +** +** Transform UK Ordnance survey map position to WGS84 lat/lon +** Uses Helmert transformation +** +** @param [r] map [const char *] map two letter code +** @param [r] mE [double] map easting (metres) +** @param [r] mN [double] map northing (metres) +** @param [w] lat [double *] WGS84 latitude (deg) +** @param [w] lon [double *] WGS84 longitude (deg) +** +** @return [int32] success +************************************************************************/ +int32_t GPS_Math_UKOSMap_To_WGS84_H(const char* map, double mE, double mN, + double* lat, double* lon) +{ + double E; + double N; + double alat; + double alon; + double ht; + double ax; + double ay; + double az; + double x; + double y; + double z; + + if (!GPS_Math_UKOSNG_Map_To_EN(map,mE,mN,&E,&N)) { + return 0; + } + + GPS_Math_NGENToAiry1830LatLon(E,N,&alat,&alon); + GPS_Math_Airy1830LatLonH_To_XYZ(alat, alon, 0.0, &ax, &ay, &az); + + /* Helmert transformation + * https://www.ordnancesurvey.co.uk/documents/resources/guide-coordinate-systems-great-britain.pdf + * 6.2 Helmert datum transformations + * 6.6 Approximate WGS84 to OSGB36/ODN transformation + */ + if constexpr(use_exact_helmert_inverse) { + // Actually invert the Helmert transform from WGS84 to OSGB36. + // WGS84 -> OSGB36 + constexpr double tX = -446.448; /* meters */ + constexpr double tY = +125.157; /* meters */ + constexpr double tZ = -542.060; /* meters */ + constexpr double s = +20.4894; /* ppm */ + constexpr double rX = -0.1502; /* seconds */ + constexpr double rY = -0.2470; /* seconds */ + constexpr double rZ = -0.8421; /* seconds */ + + GPS_Math_Inverse_Helmert(ax, ay, az, + &x, &y, &z, + tX, tY, tZ, + s, + rX, rY, rZ); + } else { + // Approximate the transform from OSGB36 to WGS84 by using the standard + // helmert transform with parameters that all have the opposite signs of + // those used to transform from WGS84 to OSGB36. + constexpr double tX = +446.448; /* meters */ + constexpr double tY = -125.157; /* meters */ + constexpr double tZ = +542.060; /* meters */ + constexpr double s = -20.4894; /* ppm */ + constexpr double rX = +0.1502; /* seconds */ + constexpr double rY = +0.2470; /* seconds */ + constexpr double rZ = +0.8421; /* seconds */ + + GPS_Math_Helmert(ax, ay, az, + &x, &y, &z, + tX, tY, tZ, + s, + rX, rY, rZ); + } + + GPS_Math_XYZ_To_WGS84LatLonH(lat, lon, &ht, x, y, z); + + return 1; +} + /* @func GPS_Math_WGS84_To_UKOSMap_C *********************************** ** diff --git a/jeeps/gpsmath.h b/jeeps/gpsmath.h index 19451987d..feac1c97b 100644 --- a/jeeps/gpsmath.h +++ b/jeeps/gpsmath.h @@ -72,6 +72,16 @@ void GPS_Math_Molodensky(double Sphi, double Slam, double SH, double Sa, double Sif, double* Dphi, double* Dlam, double* DH, double Da, double Dif, double dx, double dy, double dz); +void GPS_Math_Helmert(double Sx, double Sy, double Sz, + double* Dx, double* Dy, double* Dz, + double tX, double tY, double tZ, + double sppm, + double rXs, double rYs, double rZs); +void GPS_Math_Inverse_Helmert(double Sx, double Sy, double Sz, + double* Dx, double* Dy, double* Dz, + double tX, double tY, double tZ, + double sppm, + double rXs, double rYs, double rZs); void GPS_Math_Known_Datum_To_WGS84_M(double Sphi, double Slam, double SH, double* Dphi, double* Dlam, double* DH, int32_t n); @@ -96,6 +106,10 @@ int32_t GPS_Math_WGS84_To_UKOSMap_M(double lat, double lon, double* mE, double* mN, char* map); int32_t GPS_Math_UKOSMap_To_WGS84_M(const char* map, double mE, double mN, double* lat, double* lon); +int32_t GPS_Math_WGS84_To_UKOSMap_H(double lat, double lon, double* mE, + double* mN, char* map); +int32_t GPS_Math_UKOSMap_To_WGS84_H(const char* map, double mE, double mN, + double* lat, double* lon); int32_t GPS_Math_WGS84_To_UKOSMap_C(double lat, double lon, double* mE, double* mN, char* map); int32_t GPS_Math_UKOSMap_To_WGS84_C(const char* map, double mE, double mN, diff --git a/parse.cc b/parse.cc index bd03cb42e..5dacd5016 100644 --- a/parse.cc +++ b/parse.cc @@ -221,7 +221,7 @@ parse_coordinates(const char* str, int datum, const grid_type grid, &result); valid = (ct == 3); if (valid) { - if (! GPS_Math_UKOSMap_To_WGS84_M(map, lx, ly, &lat, &lon)) + if (! GPS_Math_UKOSMap_To_WGS84_H(map, lx, ly, &lat, &lon)) fatal("%s: Unable to convert BNG coordinates (%s)!\n", module, str); } diff --git a/reference/bngtest.csv b/reference/bngtest.csv new file mode 100644 index 000000000..c3cf5be0d --- /dev/null +++ b/reference/bngtest.csv @@ -0,0 +1,3 @@ +No,BNG-Zone,BNG-East,BNG-North,Name,Description,Date,Time +1,ST,96552, 3097,"Badbury Rings Trig Point","Test Point 1",2024/08/05,00:00:00 +2,ST,91437, 1894,"Spettisbury Rings Trig Point","Test Point 2",2024/08/05,00:00:00 diff --git a/reference/bngtest.gpx b/reference/bngtest.gpx new file mode 100644 index 000000000..cc75b4677 --- /dev/null +++ b/reference/bngtest.gpx @@ -0,0 +1,17 @@ + + + + + + + Badbury Rings Trig Point + Test Point 1 + Test Point 1 + + + + Spettisbury Rings Trig Point + Test Point 2 + Test Point 2 + + diff --git a/reference/grid-bng~csv.gpx b/reference/grid-bng~csv.gpx index ddcb600ea..babec11c2 100644 --- a/reference/grid-bng~csv.gpx +++ b/reference/grid-bng~csv.gpx @@ -1,92 +1,92 @@ - - + + AlineLodge Aline Lodge Aline Lodge City (Small) - + Caernarfon Caernarfon Caernarfon City (Small) - + Camborne Camborne Camborne City (Small) - + Exeter Exeter Exeter City (Medium) - + Forfar Forfar Forfar City (Small) - + Hawick Hawick Hawick City (Small) - + Hosta Hosta Hosta City (Small) - + IsleofRhum Isle of Rhum Isle of Rhum City (Small) - + Lerwick Lerwick Lerwick City (Small) - + Nethertown Nethertown Nethertown City (Small) - + Norwich Norwich Norwich City (Medium) - + Selsey Selsey Selsey City (Small) - + Sheffield Sheffield diff --git a/testo.d/unicsv.test b/testo.d/unicsv.test index 99bfdc681..93a89e341 100644 --- a/testo.d/unicsv.test +++ b/testo.d/unicsv.test @@ -59,3 +59,8 @@ compare ${REFERENCE}/pretty_degree2.csv ${TMPDIR}/pretty_degree2.csv gpsbabel -i unicsv -f ${REFERENCE}/unidelim.csv -o gpx -F ${TMPDIR}/unidelim.gpx compare ${REFERENCE}/unidelim.gpx ${TMPDIR}/unidelim.gpx +gpsbabel -i unicsv,utc -f ${REFERENCE}/bngtest.csv -o gpx -F ${TMPDIR}/bngtest~csv.gpx +compare ${REFERENCE}/bngtest.gpx ${TMPDIR}/bngtest~csv.gpx +gpsbabel -i gpx -f ${REFERENCE}/bngtest.gpx -o unicsv,grid=bng,utc -F ${TMPDIR}/bngtest~gpx.csv +compare ${REFERENCE}/bngtest.csv ${TMPDIR}/bngtest~gpx.csv + diff --git a/unicsv.cc b/unicsv.cc index ab1534de9..84800e98e 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -46,7 +46,7 @@ #include "garmin_fs.h" // for garmin_fs_t #include "garmin_tables.h" // for gt_lookup_datum_index, gt_get_mps_grid_longname, gt_lookup_grid_type #include "geocache.h" // for Geocache, Geocache::status_t, Geoc... -#include "jeeps/gpsmath.h" // for GPS_Math_UKOSMap_To_WGS84_M, GPS_Math_EN_To_UKOSNG_Map, GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_Swiss_EN_To_WGS84, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS... +#include "jeeps/gpsmath.h" // for GPS_Math_UKOSMap_To_WGS84_H, GPS_Math_EN_To_UKOSNG_Map, GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_Swiss_EN_To_WGS84, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS... #include "session.h" // for session_t #include "src/core/datetime.h" // for DateTime #include "src/core/logging.h" // for Warning, Fatal @@ -1017,13 +1017,13 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) fatal(MYNAME ": Unable to convert BNG coordinates (%.f %.f)!\n", bng_easting, bng_northing); } - if (! GPS_Math_UKOSMap_To_WGS84_M( + if (! GPS_Math_UKOSMap_To_WGS84_H( bngz, bnge, bngn, &wpt->latitude, &wpt->longitude)) fatal(MYNAME ": Unable to convert BNG coordinates (%s %.f %.f)!\n", bngz, bnge, bngn); } else { // traditional zone easting northing - if (! GPS_Math_UKOSMap_To_WGS84_M( + if (! GPS_Math_UKOSMap_To_WGS84_H( CSTR(bng_zone), bng_easting, bng_northing, &wpt->latitude, &wpt->longitude)) fatal(MYNAME ": Unable to convert BNG coordinates (%s %.f %.f)!\n", @@ -1322,7 +1322,7 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) double north; double east; - if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map)) { + if (! GPS_Math_WGS84_To_UKOSMap_H(wpt->latitude, wpt->longitude, &east, &north, map)) { unicsv_fatal_outside(wpt); } auto fieldWidth = fout->fieldWidth(); diff --git a/xcsv.cc b/xcsv.cc index 23266cd6a..c64d9c4d8 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -56,7 +56,7 @@ #include "garmin_fs.h" // for garmin_fs_t #include "geocache.h" // for Geocache, Geocache::status_t, Geoc... #include "grtcirc.h" // for RAD, gcdist, radtometers -#include "jeeps/gpsmath.h" // for GPS_Math_WGS84_To_UTM_EN, GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_UKOSMap_M +#include "jeeps/gpsmath.h" // for GPS_Math_WGS84_To_UTM_EN, GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_UKOSMap_H #include "jeeps/gpsport.h" // for int32 #include "session.h" // for session_t #include "src/core/datetime.h" // for DateTime @@ -1227,7 +1227,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) char map[3]; double north; double east; - if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map)) + if (! GPS_Math_WGS84_To_UKOSMap_H(wpt->latitude, wpt->longitude, &east, &north, map)) fatal(MYNAME ": Position (%.5f/%.5f) outside of BNG.\n", wpt->latitude, wpt->longitude); buff = QString::asprintf(fmp.printfc.constData(), map, qRound(east), qRound(north)); From c8f87090b9bcec6f6ac4be64e7d0cee3076123c5 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:33:29 -0600 Subject: [PATCH 105/132] use constexpr for constants, match parms in declaration and definition. (#1314) * use constexpr for constants, match parms in declaration and definition. * increase precision of GPS_PI. --- jeeps/gpsmath.cc | 74 ++++++++++++++++++++++++------------------------ jeeps/gpsmath.h | 4 +-- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/jeeps/gpsmath.cc b/jeeps/gpsmath.cc index 6c539f94f..69680c1b2 100644 --- a/jeeps/gpsmath.cc +++ b/jeeps/gpsmath.cc @@ -639,11 +639,11 @@ void GPS_Math_LatLon_To_EN(double* E, double* N, double phi, void GPS_Math_Airy1830M_LatLonToINGEN(double phi, double lambda, double* E, double* N) { - double N0 = 250000; - double E0 = 200000; - double F0 = 1.000035; - double phi0 = 53.5; - double lambda0 = -8.; + constexpr double N0 = 250000; + constexpr double E0 = 200000; + constexpr double F0 = 1.000035; + constexpr double phi0 = 53.5; + constexpr double lambda0 = -8.; constexpr double a = Airy1830Modified_Ellipse.a; constexpr double b = Airy1830Modified_Ellipse.b(); @@ -670,11 +670,11 @@ void GPS_Math_Airy1830M_LatLonToINGEN(double phi, double lambda, double* E, void GPS_Math_Airy1830LatLonToNGEN(double phi, double lambda, double* E, double* N) { - double N0 = -100000; - double E0 = 400000; - double F0 = 0.9996012717; - double phi0 = 49.; - double lambda0 = -2.; + constexpr double N0 = -100000; + constexpr double E0 = 400000; + constexpr double F0 = 0.9996012717; + constexpr double phi0 = 49.; + constexpr double lambda0 = -2.; constexpr double a = Airy1830_Ellipse.a; constexpr double b = Airy1830_Ellipse.b(); @@ -701,10 +701,10 @@ void GPS_Math_Airy1830LatLonToNGEN(double phi, double lambda, double* E, int32_t GPS_Math_WGS84_To_Swiss_EN(double lat, double lon, double* E, double* N) { - const double phi0 = 46.95240556; - const double lambda0 = 7.43958333; - const double E0 = 600000.0; - const double N0 = 200000.0; + constexpr double phi0 = 46.95240556; + constexpr double lambda0 = 7.43958333; + constexpr double E0 = 600000.0; + constexpr double N0 = 200000.0; double phi, lambda, alt; if (lat < 44.89022757) { @@ -738,10 +738,10 @@ int32_t GPS_Math_WGS84_To_Swiss_EN(double lat, double lon, double* E, ************************************************************************/ void GPS_Math_Swiss_EN_To_WGS84(double E, double N, double* lat, double* lon) { - const double phi0 = 46.95240556; - const double lambda0 = 7.43958333; - const double E0 = 600000.0; - const double N0 = 200000.0; + constexpr double phi0 = 46.95240556; + constexpr double lambda0 = 7.43958333; + constexpr double E0 = 600000.0; + constexpr double N0 = 200000.0; double phi, lambda, alt; constexpr double a = Bessel1841_Ellipse.a; @@ -1098,10 +1098,10 @@ void GPS_Math_Cassini_EN_To_LatLon(double E, double N, double* phi, int32_t GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, double* N) { - double const phi0 = 31.73409694444; // 31 44 2.749 - double const lambda0 = 35.21208055556; // 35 12 43.49 - double const E0 = 170251.555; - double const N0 = 1126867.909; + constexpr double phi0 = 31.73409694444; // 31 44 2.749 + constexpr double lambda0 = 35.21208055556; // 35 12 43.49 + constexpr double E0 = 170251.555; + constexpr double N0 = 1126867.909; double phi, lambda, alt, a, b; int32_t datum = GPS_Lookup_Datum_Index("Palestine 1923"); @@ -1135,10 +1135,10 @@ int32_t GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, ************************************************************************/ void GPS_Math_ICS_EN_To_WGS84(double E, double N, double* lat, double* lon) { - double const phi0 = 31.73409694444; // 31 44 2.749 - double const lambda0 = 35.21208055556; // 35 12 43.49 - double const E0 = 170251.555; - double const N0 = 1126867.909; + constexpr double phi0 = 31.73409694444; // 31 44 2.749 + constexpr double lambda0 = 35.21208055556; // 35 12 43.49 + constexpr double E0 = 170251.555; + constexpr double N0 = 1126867.909; double phi, lambda, alt, a, b; int32_t datum = GPS_Lookup_Datum_Index("Palestine 1923"); if (datum < 0) { @@ -1301,11 +1301,11 @@ void GPS_Math_EN_To_LatLon(double E, double N, double* phi, void GPS_Math_NGENToAiry1830LatLon(double E, double N, double* phi, double* lambda) { - double N0 = -100000; - double E0 = 400000; - double F0 = 0.9996012717; - double phi0 = 49.; - double lambda0 = -2.; + constexpr double N0 = -100000; + constexpr double E0 = 400000; + constexpr double F0 = 0.9996012717; + constexpr double phi0 = 49.; + constexpr double lambda0 = -2.; constexpr double a = Airy1830_Ellipse.a; constexpr double b = Airy1830_Ellipse.b(); @@ -1331,11 +1331,11 @@ void GPS_Math_NGENToAiry1830LatLon(double E, double N, double* phi, void GPS_Math_INGENToAiry1830MLatLon(double E, double N, double* phi, double* lambda) { - double N0 = 250000; - double E0 = 200000; - double F0 = 1.000035; - double phi0 = 53.5; - double lambda0 = -8.; + constexpr double N0 = 250000; + constexpr double E0 = 200000; + constexpr double F0 = 1.000035; + constexpr double phi0 = 53.5; + constexpr double lambda0 = -8.; constexpr double a = Airy1830Modified_Ellipse.a; constexpr double b = Airy1830Modified_Ellipse.b(); @@ -2730,7 +2730,7 @@ void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, //based on code written by Chuck Gantz- chuck.gantz@globalstar.com //found at http://www.gpsy.com/gpsinfo/geotoutm/index.html - double k0 = 0.9996; + constexpr double k0 = 0.9996; double a, f; double eccSquared; double eccPrimeSquared; diff --git a/jeeps/gpsmath.h b/jeeps/gpsmath.h index feac1c97b..e4adcfb0e 100644 --- a/jeeps/gpsmath.h +++ b/jeeps/gpsmath.h @@ -7,7 +7,7 @@ #include // for QString -constexpr double GPS_PI = 3.141592653589; +constexpr double GPS_PI = 3.14159265358979323846; double GPS_Math_Deg_To_Rad(double v); @@ -149,7 +149,7 @@ int32_t GPS_Math_WGS84_To_ICS_EN(double lat, double lon, double* E, double* N); void GPS_Math_ICS_EN_To_WGS84(double E, double N, double* lat, double* lon); -int32_t GPS_Math_WGS84_To_Swiss_EN(double phi, double lambda, double* E, double* N); +int32_t GPS_Math_WGS84_To_Swiss_EN(double lat, double lon, double* E, double* N); void GPS_Math_Swiss_EN_To_WGS84(double E, double N, double* lat, double* lon); void GPS_Math_UTM_EN_to_LatLon(int ReferenceEllipsoid, From be1168b400285a6ca953a111e95b13bd17af56c9 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:02:46 -0600 Subject: [PATCH 106/132] move floor to C++20 (#1206) * move floor to c++20 drop Visual Studio 2017. use default member intializers for bit-fields. * use more bit-field default initializers * try Xcod 14.3.1 on macOS 13. * echo clang version which can be useful with homebrew fails_with * use std::numbers * finish eradication of M_PI. * fix some whitespace --- CMakeLists.txt | 2 +- defs.h | 45 +++++++++----------------------- garmin.cc | 2 +- garmin_fs.h | 60 ++++++++++++++----------------------------- geocache.h | 38 ++++++++------------------- googletakeout.h | 2 +- grtcirc.cc | 3 ++- grtcirc.h | 4 ++- humminbird.cc | 19 +++++++------- jeeps/gpsmath.h | 3 ++- lowranceusr.cc | 7 ++--- lowranceusr.h | 5 ++-- main.cc | 4 +-- precompiled_headers.h | 2 +- skytraq.cc | 11 ++++---- src/core/nvector.cc | 15 +++++------ src/core/nvector.h | 8 +++--- 17 files changed, 90 insertions(+), 140 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55ac322d9..2193b851b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ include(CheckIncludeFile) include(gbversion.cmake) project(gpsbabel LANGUAGES C CXX VERSION ${GB.VERSION}) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) # Do this after we set up common variables but before creating other diff --git a/defs.h b/defs.h index 85465104c..df3e8c3aa 100644 --- a/defs.h +++ b/defs.h @@ -19,7 +19,6 @@ #ifndef DEFS_H_INCLUDED_ #define DEFS_H_INCLUDED_ -#include // for M_PI #include // for NULL, nullptr_t, size_t #include // for int32_t, uint32_t #include // for NULL, fprintf, FILE, stdout @@ -36,7 +35,6 @@ #include // for QString #include // for QStringView #include // for QTextCodec -#include // for QVector #include // for CaseInsensitive #include // for QForeachContainer, qMakeForeachContainer, foreach, qint64 @@ -50,12 +48,6 @@ #define CSTR(qstr) ((qstr).toUtf8().constData()) #define CSTRc(qstr) ((qstr).toLatin1().constData()) -/* - * Amazingly, this constant is not specified in the standard... - */ -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif /* * The constants marked "exact in decimal notation" may be more accurately @@ -235,17 +227,11 @@ class UrlList : public QList class wp_flags { public: - wp_flags() : - shortname_is_synthetic(0), - fmt_use(0), - is_split(0), - new_trkseg(0), - marked_for_deletion(0) {} - unsigned int shortname_is_synthetic:1; - unsigned int fmt_use:2; /* lightweight "extra data" */ - unsigned int is_split:1; /* the waypoint represents a split */ - unsigned int new_trkseg:1; /* True if first in new trkseg. */ - unsigned int marked_for_deletion:1; /* True if schedulded for deletion. */ + unsigned int shortname_is_synthetic:1{0}; + unsigned int fmt_use:2{0}; /* lightweight "extra data" */ + unsigned int is_split:1{0}; /* the waypoint represents a split */ + unsigned int new_trkseg:1{0}; /* True if first in new trkseg. */ + unsigned int marked_for_deletion:1{0}; /* True if schedulded for deletion. */ }; /* @@ -275,21 +261,14 @@ class Waypoint class op_flags { public: - op_flags() : - temperature(false), - proximity(false), - course(false), - speed(false), - geoidheight(false), - depth(false) {} - bool temperature:1; /* temperature field is set */ - bool proximity:1; /* proximity field is set */ - bool course:1; /* course field is set */ - bool speed:1; /* speed field is set */ - bool geoidheight:1; /* geoidheight field is set */ - bool depth:1; /* depth field is set */ + bool temperature:1{false}; /* temperature field is set */ + bool proximity:1{false}; /* proximity field is set */ + bool course:1{false}; /* course field is set */ + bool speed:1{false}; /* speed field is set */ + bool geoidheight:1{false}; /* geoidheight field is set */ + bool depth:1{false}; /* depth field is set */ /* !ToDo! - unsigned int altitude:1; /+ altitude field is set +/ + unsigned int altitude:1{false}; /+ altitude field is set +/ ... and hdop,pdop,vdop,fix,sat,heartrate,cadence,power, odometer_distance */ diff --git a/garmin.cc b/garmin.cc index d676e33df..7c20fc836 100644 --- a/garmin.cc +++ b/garmin.cc @@ -1010,7 +1010,7 @@ GarminFormat::route_write() for (int i = 0; i < n; i++) { GPS_Way_Del(&tx_routelist[i]); } - + xfree(tx_routelist); } diff --git a/garmin_fs.h b/garmin_fs.h index 00c16074b..5ed17e9ae 100644 --- a/garmin_fs.h +++ b/garmin_fs.h @@ -50,48 +50,26 @@ struct garmin_ilink_t { struct garmin_fs_flags_t { public: - garmin_fs_flags_t() : - icon(0), - wpt_class(0), - display(0), - category(0), - city(0), - state(0), - facility(0), - cc(0), - cross_road(0), - addr(0), - country(0), - phone_nr(0), - phone_nr2(0), - fax_nr(0), - postal_code(0), - email(0), - duration(0) -#ifdef GMSD_EXPERIMENTAL - , subclass(0) -#endif - {} - - unsigned int icon:1; - unsigned int wpt_class:1; - unsigned int display:1; - unsigned int category:1; - unsigned int city:1; - unsigned int state:1; - unsigned int facility:1; - unsigned int cc:1; - unsigned int cross_road:1; - unsigned int addr:1; - unsigned int country:1; - unsigned int phone_nr:1; - unsigned int phone_nr2:1; - unsigned int fax_nr:1; - unsigned int postal_code:1; - unsigned int email:1; - unsigned int duration:1; + + unsigned int icon:1{0}; + unsigned int wpt_class:1{0}; + unsigned int display:1{0}; + unsigned int category:1{0}; + unsigned int city:1{0}; + unsigned int state:1{0}; + unsigned int facility:1{0}; + unsigned int cc:1{0}; + unsigned int cross_road:1{0}; + unsigned int addr:1{0}; + unsigned int country:1{0}; + unsigned int phone_nr:1{0}; + unsigned int phone_nr2:1{0}; + unsigned int fax_nr:1{0}; + unsigned int postal_code:1{0}; + unsigned int email:1{0}; + unsigned int duration:1{0}; #ifdef GMSD_EXPERIMENTAL - unsigned int subclass:1; + unsigned int subclass:1{0}; #endif }; diff --git a/geocache.h b/geocache.h index e53cc7193..a2d73d294 100644 --- a/geocache.h +++ b/geocache.h @@ -79,22 +79,6 @@ class Geocache QString utf_string; }; - /* Special Member Functions */ - - Geocache() : - id(0), - type(type_t::gt_unknown), - container(container_t::gc_unknown), - diff(0), - terr(0), - is_archived(status_t::gs_unknown), - is_available(status_t::gs_unknown), - is_memberonly(status_t::gs_unknown), - has_customcoords(status_t::gs_unknown), - placer_id(0), - favorite_points(0) - {} - /* Member Functions */ void set_type(const QString& type_name); @@ -105,22 +89,22 @@ class Geocache /* Data Members */ - long long id; /* The decimal cache number */ - type_t type:5; - container_t container:4; - unsigned int diff:6; /* (multiplied by ten internally) */ - unsigned int terr:6; /* (likewise) */ - status_t is_archived:2; - status_t is_available:2; - status_t is_memberonly:2; - status_t has_customcoords:2; + long long id{0}; /* The decimal cache number */ + type_t type:5{type_t::gt_unknown}; + container_t container:4{container_t::gc_unknown}; + unsigned int diff:6{0}; /* (multiplied by ten internally) */ + unsigned int terr:6{0}; /* (likewise) */ + status_t is_archived:2{status_t::gs_unknown}; + status_t is_available:2{status_t::gs_unknown}; + status_t is_memberonly:2{status_t::gs_unknown}; + status_t has_customcoords:2{status_t::gs_unknown}; gpsbabel::DateTime last_found; QString placer; /* Placer name */ - int placer_id; /* Placer id */ + int placer_id{0}; /* Placer id */ QString hint; /* all these UTF8, XML entities removed, May be not HTML. */ UtfString desc_short; UtfString desc_long; - int favorite_points; + int favorite_points{0}; QString personal_note; private: diff --git a/googletakeout.h b/googletakeout.h index 4754366ca..3d805562a 100644 --- a/googletakeout.h +++ b/googletakeout.h @@ -120,7 +120,7 @@ class GoogleTakeoutFormat : public Format }; /* Member Functions */ - + static void takeout_fatal(const QString& message); static void takeout_warning(const QString& message); static Waypoint* takeout_waypoint(int lat_e7, int lon_e7, const QString* shortname, const QString* description, const QString* start_str); diff --git a/grtcirc.cc b/grtcirc.cc index 94ea141f9..b4d80d7c0 100644 --- a/grtcirc.cc +++ b/grtcirc.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include static constexpr double EARTH_RAD = 6378137.0; @@ -276,7 +277,7 @@ double linedistprj(double lat1, double lon1, } } else { /* lp is 0 when 3 is 90 degrees from the great circle */ - return M_PI / 2; + return std::numbers::pi / 2; } } else { /* la is 0 when 1 and 2 are either the same point or 180 degrees apart */ diff --git a/grtcirc.h b/grtcirc.h index 70641f183..821eccef4 100644 --- a/grtcirc.h +++ b/grtcirc.h @@ -22,6 +22,8 @@ #ifndef GRTCIRC_H #define GRTCIRC_H +#include // for inv_pi + double gcdist(double lat1, double lon1, double lat2, double lon2); double heading(double lat1, double lon1, double lat2, double lon2); double heading_true_degrees(double lat1, double lon1, double lat2, double lon2); @@ -45,7 +47,7 @@ void linepart(double lat1, double lon1, double* reslat, double* reslon); /* Degrees to radians */ -constexpr double kDegreesPerRadian = 180.0 / M_PI; +constexpr double kDegreesPerRadian = 180.0 * std::numbers::inv_pi; constexpr double DEG(double x) { return x * kDegreesPerRadian; } /* Radians to degrees */ diff --git a/humminbird.cc b/humminbird.cc index ea3f2f3a8..d4a597b26 100644 --- a/humminbird.cc +++ b/humminbird.cc @@ -25,9 +25,10 @@ #include // for CaseInsensitive #include // for qRound -#include // for atan, tan, M_PI, log, sinh +#include // for atan, tan, log, sinh #include // for snprintf, SEEK_SET #include // for strncpy, memcpy, memset +#include // for inv_pi, pi #include "defs.h" // for Waypoint, be_read32, be_read16, be_write32, fatal, xfree, be_write16, route_head, xcalloc, track_add_wpt, xstrndup #include "mkshort.h" // for MakeShort @@ -61,7 +62,7 @@ Still, they're useful in the code as a plain signature. #define WPT_MAGIC2 0x02030024L // New for 2013. No visible diff?! #define RTE_MAGIC 0x03030088L -#define EAST_SCALE 20038297.0 /* this is i1924_equ_axis*M_PI */ +#define EAST_SCALE 20038297.0 /* this is i1924_equ_axis*pi */ #define i1924_equ_axis 6378388.0 #define i1924_polar_axis 6356911.946 @@ -173,9 +174,9 @@ HumminbirdBase::geodetic_to_geocentric_hwr(const double gd_lat) { constexpr double cos_ae = 0.9966349016452; constexpr double cos2_ae = cos_ae * cos_ae; - const double gdr = gd_lat *M_PI / 180.0; + const double gdr = gd_lat * std::numbers::pi / 180.0; - return atan(cos2_ae * tan(gdr)) * 180.0/M_PI; + return atan(cos2_ae * tan(gdr)) * 180.0 * std::numbers::inv_pi; } /* Takes a latitude in degrees, @@ -185,9 +186,9 @@ HumminbirdBase::geocentric_to_geodetic_hwr(const double gc_lat) { constexpr double cos_ae = 0.9966349016452; constexpr double cos2_ae = cos_ae * cos_ae; - const double gcr = gc_lat *M_PI / 180.0; + const double gcr = gc_lat * std::numbers::pi / 180.0; - return atan(tan(gcr)/cos2_ae) * 180.0/M_PI; + return atan(tan(gcr)/cos2_ae) * 180.0 * std::numbers::inv_pi; } /* Takes a projected "north" value, returns latitude in degrees. */ @@ -196,15 +197,15 @@ HumminbirdBase::gudermannian_i1924(const double x) { const double norm_x = x/i1924_equ_axis; - return atan(sinh(norm_x)) * 180.0/M_PI; + return atan(sinh(norm_x)) * 180.0 * std::numbers::inv_pi; } /* Takes latitude in degrees, returns projected "north" value. */ double HumminbirdBase::inverse_gudermannian_i1924(const double x) { - const double x_r = x/180.0 * M_PI; - const double guder = log(tan(M_PI/4.0 + x_r/2.0)); + const double x_r = x/180.0 * std::numbers::pi; + const double guder = log(tan(std::numbers::pi/4.0 + x_r/2.0)); return guder * i1924_equ_axis; } diff --git a/jeeps/gpsmath.h b/jeeps/gpsmath.h index e4adcfb0e..dadd2863f 100644 --- a/jeeps/gpsmath.h +++ b/jeeps/gpsmath.h @@ -3,11 +3,12 @@ #include // for int32_t #include // for time_t +#include // for pi #include // for QString -constexpr double GPS_PI = 3.14159265358979323846; +constexpr double GPS_PI = std::numbers::pi; double GPS_Math_Deg_To_Rad(double v); diff --git a/lowranceusr.cc b/lowranceusr.cc index 92f533a18..8e38e6f8a 100644 --- a/lowranceusr.cc +++ b/lowranceusr.cc @@ -88,11 +88,12 @@ #include "lowranceusr.h" #include // for PRId64 -#include // for M_PI, round, atan, exp, log, tan +#include // for round, atan, exp, log, tan #include // for printf, sprintf, SEEK_CUR #include // for int64_t #include // for abs #include // for strcmp, strlen +#include // for pi #include // for as_const #include // for QByteArray @@ -377,7 +378,7 @@ LowranceusrFormat::lon_mm_to_deg(double x) double LowranceusrFormat::lat_mm_to_deg(double x) { - return (2.0 * atan(exp(x / SEMIMINOR)) - M_PI / 2.0) / DEGREESTORADIANS; + return (2.0 * atan(exp(x / SEMIMINOR)) - std::numbers::pi / 2.0) / DEGREESTORADIANS; } long @@ -389,7 +390,7 @@ LowranceusrFormat::lon_deg_to_mm(double x) long LowranceusrFormat::lat_deg_to_mm(double x) { - return round(SEMIMINOR * log(tan((x * DEGREESTORADIANS + M_PI / 2.0) / 2.0))); + return round(SEMIMINOR * log(tan((x * DEGREESTORADIANS + std::numbers::pi / 2.0) / 2.0))); } void diff --git a/lowranceusr.h b/lowranceusr.h index 98c21ef69..ee54fc46d 100644 --- a/lowranceusr.h +++ b/lowranceusr.h @@ -87,8 +87,9 @@ #ifndef LOWRANCEUSR_H_INCLUDED_ #define LOWRANCEUSR_H_INCLUDED_ -#include // for M_PI, round, atan, exp, log, tan +#include // for round, atan, exp, log, tan #include // for int64_t +#include // for pi #include // for QList #include // for QString @@ -378,7 +379,7 @@ class LowranceusrFormat : public Format static constexpr int MAXUSRSTRINGSIZE = 256; static constexpr double SEMIMINOR = 6356752.3142; - static constexpr double DEGREESTORADIANS = M_PI/180.0; + static constexpr double DEGREESTORADIANS = std::numbers::pi/180.0; static constexpr int MAX_TRAIL_POINTS = 9999; static constexpr double UNKNOWN_USR_ALTITUDE = METERS_TO_FEET(-10000); /* -10000ft is how the unit stores unknown */ static constexpr int64_t base_time_secs = 946706400; /* Jan 1, 2000 00:00:00 */ diff --git a/main.cc b/main.cc index 7667c1af9..9e62fde52 100644 --- a/main.cc +++ b/main.cc @@ -742,8 +742,8 @@ main(int argc, char* argv[]) #error This version of Qt is not supported. #endif -#if defined(_MSC_VER) && (_MSC_VER < 1920) /* MSVC 2017 or earlier */ -#error MSVC 2017 and earlier are not supported. Please use MSVC 2019 or MSVC 2022. +#if defined(_MSC_VER) && (_MSC_VER < 1920) /* Visual Studio 2017 or earlier */ +#error Visual Studio 2017 and earlier are not supported. Please use Visual Studio 2019 or 2022. #endif if constexpr (DEBUG_LOCALE) { diff --git a/precompiled_headers.h b/precompiled_headers.h index 47705c843..bcf1b63b0 100644 --- a/precompiled_headers.h +++ b/precompiled_headers.h @@ -21,12 +21,12 @@ #if defined __cplusplus #include // for sort, stable_sort -#include // for M_PI #include // for va_list #include // for NULL, nullptr_t, size_t #include // for int32_t, uint32_t #include // for NULL, fprintf, FILE, stdout #include // for time_t +#include // for inv_pi, pi #include // for optional #include // for move diff --git a/skytraq.cc b/skytraq.cc index 180547cbd..f6df657af 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -24,11 +24,12 @@ */ #include // for isprint -#include // for cos, sin, atan2, pow, sqrt, M_PI +#include // for cos, sin, atan2, pow, sqrt #include // for va_end, va_list, va_start #include // for sscanf, snprintf, vprintf, SEEK_SET #include // for free #include // for memset +#include // for inv_pi, pi #include // for QByteArray #include // for QChar @@ -581,8 +582,8 @@ SkytraqBase::ECEF_to_LLA(double x, double y, long z, double* lat, double* lon, d /* height above ellipsoid (in meters): */ *alt = AP/cos(*lat) - CA/sqrt(1 - CE2 * pow(sin(*lat), 2)); - *lat = *lat /M_PI*180; - *lon = *lon /M_PI*180; + *lat = *lat * std::numbers::inv_pi * 180; + *lon = *lon * std::numbers::inv_pi * 180; } void @@ -1322,8 +1323,8 @@ void MinihomerFormat::lla2ecef(double lat, double lng, double alt, double* ecef_ long double a = 6378137.0; long double esqr = 6.69437999014e-3; - long double llat = lat*M_PI/180; - long double llng = lng*M_PI/180; + long double llat = lat * std::numbers::pi / 180; + long double llng = lng * std::numbers::pi / 180; long double lalt = alt; long double s = sin(llat); diff --git a/src/core/nvector.cc b/src/core/nvector.cc index a35efc691..f6e8ad894 100644 --- a/src/core/nvector.cc +++ b/src/core/nvector.cc @@ -20,14 +20,13 @@ // https://en.wikipedia.org/wiki/N-vector // http://www.navlab.net/Publications/A_Nonsingular_Horizontal_Position_Representation.pdf -#include -#include -#include -#include -#include +#include "src/core/nvector.h" -#include "nvector.h" -#include "vector3d.h" +#include // for DBL_EPSILON +#include // for sqrt, atan2, cos, nan, sin, cbrt +#include // for pair + +#include "src/core/vector3d.h" // for Vector3D namespace gpsbabel { @@ -401,7 +400,7 @@ double NVector::crossTrackDistance(const NVector& n_EA_E, const NVector& n_EB_E, { Vector3D c_E = crossProduct(n_EA_E, n_EB_E).normalize(); double result = fabs((atan2(crossProduct(c_E, n_EX_E).norm(), - dotProduct(c_E, n_EX_E)) - M_PI/2.0)) * MEAN_EARTH_RADIUS_METERS; + dotProduct(c_E, n_EX_E)) - std::numbers::pi/2.0)) * MEAN_EARTH_RADIUS_METERS; return result; } #else diff --git a/src/core/nvector.h b/src/core/nvector.h index 4cd7b820f..03d4c7f6f 100644 --- a/src/core/nvector.h +++ b/src/core/nvector.h @@ -20,8 +20,10 @@ #ifndef NVECTOR_H #define NVECTOR_H -#include "defs.h" -#include "vector3d.h" +#include // for pi +#include // for pair + +#include "src/core/vector3d.h" // for Vector3D namespace gpsbabel { @@ -42,7 +44,7 @@ constexpr double WGS84_ASPECT_RATIO = 1.0 - WGS84_FLATTENING; // b/a constexpr double WGS84_SEMI_MINOR_AXIS_METERS = WGS84_SEMI_MAJOR_AXIS_METERS * WGS84_ASPECT_RATIO; // b constexpr double WGS84_ECCENTRICITY_SQUARED = 1.0 - (WGS84_ASPECT_RATIO * WGS84_ASPECT_RATIO); -constexpr double kRadiansPerDegree = M_PI/180.0; +constexpr double kRadiansPerDegree = std::numbers::pi / 180.0; constexpr double kDegreesPerRadian = 1.0/kRadiansPerDegree; class PVector; From cfd661ded29e4ff264da5a7e0813c65faa402c35 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 10 Aug 2024 14:23:50 -0600 Subject: [PATCH 107/132] have jeeps use std::endian (#1315) * have jeeps use std::endian * detect unsupported endian platforms. --- jeeps/gpsapp.cc | 2 -- jeeps/gpscom.cc | 2 -- jeeps/gpsutil.cc | 56 +++++++++++++----------------------------------- jeeps/gpsutil.h | 2 -- 4 files changed, 15 insertions(+), 47 deletions(-) diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index d56a603e1..e810c9f3c 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -168,8 +168,6 @@ int32_t GPS_Init(const char* port) { int32_t ret; - (void) GPS_Util_Little(); - ret = GPS_A000(port); if (ret<0) { return ret; diff --git a/jeeps/gpscom.cc b/jeeps/gpscom.cc index afa1239f5..dcc56634d 100644 --- a/jeeps/gpscom.cc +++ b/jeeps/gpscom.cc @@ -44,8 +44,6 @@ int32_t GPS_Command_Off(const char* port) GPS_Packet tra; GPS_Packet rec; - GPS_Util_Little(); - if (!GPS_Device_On(port, &fd)) { return gps_errno; } diff --git a/jeeps/gpsutil.cc b/jeeps/gpsutil.cc index 9da4a9b1d..d88d3e57f 100644 --- a/jeeps/gpsutil.cc +++ b/jeeps/gpsutil.cc @@ -22,11 +22,14 @@ ** Boston, MA 02110-1301, USA. ********************************************************************/ #include "jeeps/gps.h" +#include #include #include -static int32_t gps_endian_called = 0; -static int32_t GPS_Little = 0; +static_assert((std::endian::native == std::endian::little) != + (std::endian::native == std::endian::big), + "Only big or little endian platforms are supported."); +static constexpr bool GPS_Little = std::endian::native == std::endian::little; int32_t gps_warning = 0; int32_t gps_error = 0; @@ -34,35 +37,6 @@ int32_t gps_user = 0; int32_t gps_show_bytes = 0; int32_t gps_errno = 0; -/* @func GPS_Util_Little *********************************************** -** -** Determine endian nature of host -** -** @return [int32] true if little-endian -************************************************************************/ - -int32_t GPS_Util_Little() -{ - static union lb { - char chars[sizeof(int32_t)]; - int32_t i; - } - data; - - if (!gps_endian_called) { - gps_endian_called = 1; - data.i = 0; - *data.chars = '\1'; - if (data.i == 1) { - GPS_Little = 1; - } else { - GPS_Little = 0; - } - } - - return GPS_Little; -} - /* @func GPS_Util_Get_Short ******************************************** ** @@ -78,7 +52,7 @@ US GPS_Util_Get_Short(const UC* s) p = (UC*)&ret; - if (!GPS_Little) { + if constexpr(!GPS_Little) { *p++ = *(s+1); *p = *s; } else { @@ -105,7 +79,7 @@ void GPS_Util_Put_Short(UC* s, const US v) { const auto* p = reinterpret_cast(&v); - if (!GPS_Little) { + if constexpr(!GPS_Little) { *s++ = *(p+1); *s = *p; } else { @@ -134,7 +108,7 @@ double GPS_Util_Get_Double(const UC* s) p = (UC*)&ret; - if (!GPS_Little) + if constexpr(!GPS_Little) for (i=sizeof(double)-1; i>-1; --i) { *p++ = s[i]; } @@ -164,7 +138,7 @@ void GPS_Util_Put_Double(UC* s, const double v) const auto* p = reinterpret_cast(&v); - if (!GPS_Little) + if constexpr(!GPS_Little) for (i=sizeof(double)-1; i>-1; --i) { s[i] = *p++; } @@ -195,7 +169,7 @@ int32_t GPS_Util_Get_Int(const UC* s) p = (UC*)&ret; - if (!GPS_Little) + if constexpr(!GPS_Little) for (i=sizeof(int32_t)-1; i>-1; --i) { *p++ = s[i]; } @@ -225,7 +199,7 @@ void GPS_Util_Put_Int(UC* s, const int32_t v) const auto* p = reinterpret_cast(&v); - if (!GPS_Little) + if constexpr(!GPS_Little) for (i=sizeof(int32_t)-1; i>-1; --i) { s[i] = *p++; } @@ -255,7 +229,7 @@ uint32_t GPS_Util_Get_Uint(const UC* s) p = (UC*)&ret; - if (!GPS_Little) + if constexpr(!GPS_Little) for (i=sizeof(uint32_t)-1; i>-1; --i) { *p++ = s[i]; } @@ -285,7 +259,7 @@ void GPS_Util_Put_Uint(UC* s, const uint32_t v) const auto* p = reinterpret_cast(&v); - if (!GPS_Little) + if constexpr(!GPS_Little) for (i=sizeof(uint32_t)-1; i>-1; --i) { s[i] = *p++; } @@ -315,7 +289,7 @@ float GPS_Util_Get_Float(const UC* s) p = (UC*)&ret; - if (!GPS_Little) + if constexpr(!GPS_Little) for (i=sizeof(float)-1; i>-1; --i) { *p++ = s[i]; } @@ -345,7 +319,7 @@ void GPS_Util_Put_Float(UC* s, const float v) const auto* p = reinterpret_cast(&v); - if (!GPS_Little) + if constexpr(!GPS_Little) for (i=sizeof(float)-1; i>-1; --i) { s[i] = *p++; } diff --git a/jeeps/gpsutil.h b/jeeps/gpsutil.h index 0e50f703a..5560eda29 100644 --- a/jeeps/gpsutil.h +++ b/jeeps/gpsutil.h @@ -4,8 +4,6 @@ #include "jeeps/gps.h" -int32_t GPS_Util_Little(); - US GPS_Util_Get_Short(const UC* s); void GPS_Util_Put_Short(UC* s, US v); int32_t GPS_Util_Get_Int(const UC* s); From 430bd187998fa624a3b4d7ab56317993f92f149d Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 12 Aug 2024 06:37:08 -0600 Subject: [PATCH 108/132] correct simplify filter with maximum allowable error option and the metric being overall route length or relative error (#1316) * add test for simplify w/ relative+error opts. * fix simplify filter error+length operation. * fix simplify relative+error * remove debug statement * simplify error unit tests and documentation. * format parse, update includes. * prune redundant test case --- parse.cc | 17 +- reference/simplify_error_length.gpx | 206 +++++++++++----------- smplrout.cc | 32 ++-- testo.d/simplify-relative.test | 3 + testo.d/simplify.test | 7 +- xmldoc/filters/options/simplify-error.xml | 3 +- 6 files changed, 143 insertions(+), 125 deletions(-) diff --git a/parse.cc b/parse.cc index 5dacd5016..b14c27227 100644 --- a/parse.cc +++ b/parse.cc @@ -20,11 +20,15 @@ */ -#include "defs.h" -#include "jeeps/gpsmath.h" -#include -#include -#include //strtod +#include // for isspace +#include // for fabs +#include // for sscanf +#include // for strtod + +#include // for QString + +#include "defs.h" // for case_ignore_strcmp, fatal, KPH_TO_MPS, MPH_TO_MPS, warning, FEET_TO_METERS, KNOTS_TO_MPS, CSTR, FATHOMS_TO_METERS, MILES_TO_METERS, NMILES_TO_METERS, kDatumWGS84, grid_type, parse_coordinates, parse_distance, parse_speed, grid_bng, grid_lat_lon_ddd, grid_lat_lo... +#include "jeeps/gpsmath.h" // for GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_Swiss_EN_To_WGS84, GPS_Math_UKOSMap_To_WGS84_H, GPS_Math_UTM_EN_To_Known_Datum /* * parse_distance: @@ -83,7 +87,8 @@ parse_distance(const char* str, double* val, double scale, const char* module) } int -parse_distance(const QString& str, double* val, double scale, const char* module) { +parse_distance(const QString& str, double* val, double scale, const char* module) +{ return parse_distance(CSTR(str), val, scale, module); } diff --git a/reference/simplify_error_length.gpx b/reference/simplify_error_length.gpx index 48a4357ab..2ba09ce7a 100644 --- a/reference/simplify_error_length.gpx +++ b/reference/simplify_error_length.gpx @@ -1,7 +1,7 @@ - + LAP001 LAP001 @@ -34,6 +34,16 @@ 3.088000 + + 510.200 + + 5.925000 + + + 510.200 + + 6.637000 + 511.400 @@ -151,6 +161,11 @@ 6.169000 + + 519.200 + + 6.248000 + 520.400 @@ -251,11 +266,6 @@ 7.546000 - - 540.800 - - 8.935000 - 538.600 @@ -281,6 +291,11 @@ 4.329000 + + 536.600 + + 5.039000 + 536.600 @@ -306,6 +321,11 @@ 8.963000 + + 538.600 + + 8.420000 + 538.600 @@ -336,10 +356,10 @@ 7.927000 - + 536.400 - - 8.233000 + + 8.272000 536.400 @@ -371,11 +391,6 @@ 8.439000 - - 538.800 - - 8.476000 - 538.800 @@ -516,11 +531,6 @@ 5.373000 - - 541.600 - - 6.961000 - 537.200 @@ -646,16 +656,6 @@ 6.347000 - - 533.600 - - 6.408000 - - - 533.600 - - 6.192000 - 538.400 @@ -720,6 +720,16 @@ 7.587000 + + 542.000 + + 6.804000 + + + 542.000 + + 6.545000 + 543.200 @@ -755,10 +765,10 @@ 5.492000 - - 543.000 - - 7.660000 + + 544.000 + + 7.097000 542.200 @@ -815,6 +825,11 @@ 4.790000 + + 521.400 + + 4.333000 + 520.000 @@ -850,6 +865,11 @@ 5.026000 + + 520.000 + + 6.505000 + 520.000 @@ -950,6 +970,16 @@ 8.019000 + + 526.400 + + 1.765000 + + + 526.400 + + 1.335000 + @@ -1068,16 +1098,6 @@ 7.009000 - - 535.400 - - 6.641000 - - - 539.400 - - 6.555000 - 542.400 @@ -1088,6 +1108,11 @@ 5.426000 + + 543.800 + + 5.012000 + 548.000 @@ -1118,21 +1143,6 @@ 11.715000 - - 540.800 - - 10.787000 - - - 540.000 - - 10.409000 - - - 539.000 - - 10.124000 - 538.600 @@ -1198,11 +1208,6 @@ 10.073000 - - 536.400 - - 10.149000 - 535.400 @@ -1223,11 +1228,6 @@ 7.019000 - - 532.000 - - 7.612000 - 532.000 @@ -1313,11 +1313,6 @@ 9.152000 - - 529.600 - - 9.009000 - 529.600 @@ -1348,6 +1343,16 @@ 6.158000 + + 527.600 + + 6.444000 + + + 527.600 + + 6.139000 + 527.600 @@ -1383,6 +1388,11 @@ 6.457000 + + 529.600 + + 7.202000 + 529.600 @@ -1403,11 +1413,6 @@ 8.735000 - - 528.200 - - 9.047000 - 527.800 @@ -1448,6 +1453,11 @@ 6.894000 + + 521.000 + + 8.741000 + 521.000 @@ -1478,11 +1488,6 @@ 6.483000 - - 521.000 - - 8.439000 - 521.000 @@ -1508,6 +1513,11 @@ 6.395000 + + 525.200 + + 7.643000 + 525.200 @@ -1553,26 +1563,11 @@ 5.394000 - - 533.600 - - 6.307000 - - - 536.400 - - 5.016000 - 539.400 4.804000 - - 540.200 - - 4.605000 - 540.200 @@ -1583,6 +1578,16 @@ 4.724000 + + 542.400 + + 4.880000 + + + 542.400 + + 5.821000 + 542.400 @@ -1593,11 +1598,6 @@ 6.516000 - - 542.400 - - 6.389000 - 542.400 diff --git a/smplrout.cc b/smplrout.cc index 5570991d7..6a71295b3 100644 --- a/smplrout.cc +++ b/smplrout.cc @@ -57,7 +57,7 @@ */ #include -#include // for strtol +#include // for strtod, strtol #include // for prev #include // for QDateTime @@ -103,12 +103,12 @@ double SimplifyRouteFilter::compute_track_error(const neighborhood& nb) const break; case metric_t::length: track_error = radtomiles( - gcdist(wpt1->latitude, wpt1->longitude, - wpt3->latitude, wpt3->longitude) + - gcdist(wpt3->latitude, wpt3->longitude, - wpt2->latitude, wpt2->longitude) - - gcdist(wpt1->latitude, wpt1->longitude, - wpt2->latitude, wpt2->longitude)); + gcdist(RAD(wpt1->latitude), RAD(wpt1->longitude), + RAD(wpt3->latitude), RAD(wpt3->longitude)) + + gcdist(RAD(wpt3->latitude), RAD(wpt3->longitude), + RAD(wpt2->latitude), RAD(wpt2->longitude)) - + gcdist(RAD(wpt1->latitude), RAD(wpt1->longitude), + RAD(wpt2->latitude), RAD(wpt2->longitude))); break; case metric_t::relative: default: // eliminate false positive warning with g++ 11.3.0: ‘error’ may be used uninitialized in this function [-Wmaybe-uninitialized] @@ -125,8 +125,8 @@ double SimplifyRouteFilter::compute_track_error(const neighborhood& nb) const wpt2->latitude, wpt2->longitude, frac, &reslat, &reslon); track_error = radtometers(gcdist( - wpt3->latitude, wpt3->longitude, - reslat, reslon)); + RAD(wpt3->latitude), RAD(wpt3->longitude), + RAD(reslat), RAD(reslon))); } else { // else distance to connecting line track_error = radtometers(linedist( wpt1->latitude, wpt1->longitude, @@ -297,11 +297,15 @@ void SimplifyRouteFilter::init() count = strtol(countopt, nullptr, 10); break; case limit_basis_t::error: { - int res = parse_distance(erroropt, &error, 1.0, MYNAME); - if (res == 0) { - error = 0; - } else if (res == 2) { /* parameter with unit */ - error = METERS_TO_MILES(error); + if (metric == metric_t::relative) { + error = strtod(erroropt, nullptr); + } else { + int res = parse_distance(erroropt, &error, 1.0, MYNAME); + if (res == 0) { + error = 0; + } else if (res == 2) { /* parameter with unit */ + error = METERS_TO_MILES(error); + } } } break; diff --git a/testo.d/simplify-relative.test b/testo.d/simplify-relative.test index cb39a2e7f..3286faa2b 100644 --- a/testo.d/simplify-relative.test +++ b/testo.d/simplify-relative.test @@ -4,3 +4,6 @@ gpsbabel -i gpx -f ${REFERENCE}/track/simplify-relative.gpx -x simplify,relative,count=33 -o gpx -F ${TMPDIR}/simplify-relative2.gpx compare ${REFERENCE}/track/simplify-relative2.gpx ${TMPDIR}/simplify-relative2.gpx +gpsbabel -i gpx -f ${REFERENCE}/track/simplify-relative.gpx -x simplify,relative,error=0.61 -o gpx -F ${TMPDIR}/simplify-relative3.gpx +compare ${REFERENCE}/track/simplify-relative2.gpx ${TMPDIR}/simplify-relative3.gpx + diff --git a/testo.d/simplify.test b/testo.d/simplify.test index 7771702bb..6429f9028 100644 --- a/testo.d/simplify.test +++ b/testo.d/simplify.test @@ -19,7 +19,12 @@ gpsbabel -i gpx -f ${REFERENCE}/track/garmin-edge-800-output.gpx \ compare ${REFERENCE}/simplify_error_crosstrack.gpx ${TMPDIR}/simplify_error.gpx gpsbabel -i gpx -f ${REFERENCE}/track/garmin-edge-800-output.gpx \ - -x simplify,error=1000m,length \ + -x simplify,error=20.34m,length \ -o gpx -F ${TMPDIR}/simplify_error_length.gpx compare ${REFERENCE}/simplify_error_length.gpx ${TMPDIR}/simplify_error_length.gpx +# check default error units are miles +gpsbabel -i gpx -f ${REFERENCE}/track/garmin-edge-800-output.gpx \ + -x simplify,error=0.01263869,length \ + -o gpx -F ${TMPDIR}/simplify_error_length_miles.gpx +compare ${REFERENCE}/simplify_error_length.gpx ${TMPDIR}/simplify_error_length_miles.gpx diff --git a/xmldoc/filters/options/simplify-error.xml b/xmldoc/filters/options/simplify-error.xml index 4e6a18417..8d7e8e5e8 100644 --- a/xmldoc/filters/options/simplify-error.xml +++ b/xmldoc/filters/options/simplify-error.xml @@ -3,7 +3,8 @@ This option specifies the maximum allowable error that may be introduced by removing a single point. Used with the and methods, the value of this option is a distance, specified in miles by default. You may also specify the distance in -kilometers by adding a 'k' to the end of the number. +kilometers by adding a 'k' to the end of the number, meters by adding a 'm', or +feet by adding 'ft'. For the method it is a dimensionless quantity. From 089b93b23af8c97688c99b7fedfd62768e9a8b50 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 12 Aug 2024 07:05:53 -0600 Subject: [PATCH 109/132] cleanup great circle. (#1318) * cleanup great circle. * fix whitespace --- grtcirc.cc | 34 +++++++++++++++------------------- grtcirc.h | 1 - 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/grtcirc.cc b/grtcirc.cc index b4d80d7c0..90c0e0850 100644 --- a/grtcirc.cc +++ b/grtcirc.cc @@ -19,15 +19,15 @@ */ -#include "defs.h" #include "grtcirc.h" -#include -#include -#include -#include -#include -#include +#include // for clamp +#include // for errno, EDOM +#include // for cos, sin, fabs, atan2, sqrt, asin, atan, isnan +#include // for pi +#include // for make_tuple, tuple + +#include "defs.h" // for METERS_TO_MILES static constexpr double EARTH_RAD = 6378137.0; @@ -59,7 +59,7 @@ static double dotproduct(double x1, double y1, double z1, double radtomiles(double rads) { - const double radmiles = METERS_TO_MILES(EARTH_RAD); + constexpr double radmiles = METERS_TO_MILES(EARTH_RAD); return (rads * radmiles); } @@ -77,11 +77,7 @@ double gcdist(double lat1, double lon1, double lat2, double lon2) double res = sqrt(sdlat * sdlat + cos(lat1) * cos(lat2) * sdlon * sdlon); - if (res > 1.0) { - res = 1.0; - } else if (res < -1.0) { - res = -1.0; - } + res = std::clamp(res, -1.0, 1.0); res = asin(res); @@ -96,10 +92,10 @@ double gcdist(double lat1, double lon1, double lat2, double lon2) /* This value is the heading you'd leave point 1 at to arrive at point 2. * Inputs and outputs are in radians. */ -double heading(double lat1, double lon1, double lat2, double lon2) +static double heading(double lat1, double lon1, double lat2, double lon2) { - double v1 = sin(lon1 - lon2) * cos(lat2); - double v2 = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon1 - lon2); + double v1 = sin(lon2 - lon1) * cos(lat2); + double v2 = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon2 - lon1); /* rounding error protection */ if (fabs(v1) < 1e-15) { v1 = 0.0; @@ -113,7 +109,7 @@ double heading(double lat1, double lon1, double lat2, double lon2) /* As above, but outputs is in degrees from 0 - 359. Inputs are still radians. */ double heading_true_degrees(double lat1, double lon1, double lat2, double lon2) { - double h = 360.0 - DEG(heading(lat1, lon1, lat2, lon2)); + double h = 360.0 + DEG(heading(lat1, lon1, lat2, lon2)); if (h >= 360.0) { h -= 360.0; } @@ -160,9 +156,9 @@ double linedistprj(double lat1, double lon1, lat3 = RAD(lat3); lon3 = RAD(lon3); - int newpoints = 1; + bool newpoints = true; if (lat1 == _lat1 && lat2 == _lat2 && lon1 == _lon1 && lon2 == _lon2) { - newpoints = 0; + newpoints = false; } else { _lat1 = lat1; _lat2 = lat2; diff --git a/grtcirc.h b/grtcirc.h index 821eccef4..981f87228 100644 --- a/grtcirc.h +++ b/grtcirc.h @@ -25,7 +25,6 @@ #include // for inv_pi double gcdist(double lat1, double lon1, double lat2, double lon2); -double heading(double lat1, double lon1, double lat2, double lon2); double heading_true_degrees(double lat1, double lon1, double lat2, double lon2); double linedistprj(double lat1, double lon1, From ba542e9dff6839e9723b7a436c69ff2b05d55181 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:24:28 -0600 Subject: [PATCH 110/132] fix bend filter usage of linepart. (#1320) * fix bend filter usage of linepart. * fix new bend filter test. * make new reference files valid kml. * debug macos fails * workaround rounding errors in problematic kml lookat range. --- bend.cc | 51 +- bend.h | 9 +- reference/route/bend-expected.gpx | 770 ++++++++++++++-------------- reference/route/bendgc-expected.gpx | 71 +++ reference/route/bendgc-input.kml | 169 ++++++ testo.d/bend.test | 4 + tools/ci_script_osx.sh | 4 +- 7 files changed, 657 insertions(+), 421 deletions(-) create mode 100644 reference/route/bendgc-expected.gpx create mode 100644 reference/route/bendgc-input.kml diff --git a/bend.cc b/bend.cc index 29cc1d488..774bea92e 100644 --- a/bend.cc +++ b/bend.cc @@ -53,34 +53,38 @@ void BendFilter::init() route_flush_all_routes(); } -Waypoint* BendFilter::create_wpt_dest(const Waypoint* wpt_orig, double lat_orig, - double long_orig, double lat_orig_adj, double long_orig_adj) const +Waypoint* BendFilter::create_wpt_dest(const Waypoint* wpt_orig, const Waypoint* wpt_orig_adj) const { - double distance = gcdist(lat_orig, long_orig, - lat_orig_adj, long_orig_adj); - double lat_dest; - double long_dest; - distance = radtometers(distance); + double distance = radtometers(gcdist(RAD(wpt_orig->latitude), RAD(wpt_orig->longitude), + RAD(wpt_orig_adj->latitude), RAD(wpt_orig_adj->longitude))); if (distance <= maxDist) { return nullptr; } double frac = maxDist / distance; - linepart(lat_orig, long_orig, lat_orig_adj, long_orig_adj, frac, - &lat_dest, &long_dest); - auto* wpt_dest = new Waypoint(*wpt_orig); - wpt_dest->latitude = DEG(lat_dest); - wpt_dest->longitude = DEG(long_dest); + linepart(wpt_orig->latitude, wpt_orig->longitude, + wpt_orig_adj->latitude, wpt_orig_adj->longitude, + frac, + &wpt_dest->latitude, &wpt_dest->longitude); return wpt_dest; } -int BendFilter::is_small_angle(double lat_orig, double long_orig, double lat_orig_prev, - double long_orig_prev, double lat_orig_next, - double long_orig_next) const +int BendFilter::is_small_angle(const Waypoint* wpt_orig, + const Waypoint* wpt_orig_prev, + const Waypoint* wpt_orig_next) const { + double lat_orig = RAD(wpt_orig->latitude); + double long_orig = RAD(wpt_orig->longitude); + + double lat_orig_prev = RAD(wpt_orig_prev->latitude); + double long_orig_prev = RAD(wpt_orig_prev->longitude); + + double lat_orig_next = RAD(wpt_orig_next->latitude); + double long_orig_next = RAD(wpt_orig_next->longitude); + double heading_prev = heading_true_degrees(lat_orig, long_orig, lat_orig_prev, long_orig_prev); double heading_next = heading_true_degrees(lat_orig, long_orig, @@ -106,28 +110,17 @@ void BendFilter::process_route(const route_head* route_orig, route_head* route_d route_add_wpt(route_dest, waypoint_dest); } } else { - double lat_orig = RAD(wpt_orig->latitude); - double long_orig = RAD(wpt_orig->longitude); - - double lat_orig_prev = RAD(wpt_orig_prev->latitude); - double long_orig_prev = RAD(wpt_orig_prev->longitude); - - double lat_orig_next = RAD(wpt_orig_next->latitude); - double long_orig_next = RAD(wpt_orig_next->longitude); - if (is_small_angle(lat_orig, long_orig, lat_orig_prev, - long_orig_prev, lat_orig_next, long_orig_next)) { + if (is_small_angle(wpt_orig, wpt_orig_prev, wpt_orig_next)) { auto* waypoint_dest = new Waypoint(*wpt_orig); route_add_wpt(route_dest, waypoint_dest); } else { - Waypoint* wpt_dest_prev = create_wpt_dest(wpt_orig, - lat_orig, long_orig, lat_orig_prev, long_orig_prev); + Waypoint* wpt_dest_prev = create_wpt_dest(wpt_orig, wpt_orig_prev); if (wpt_dest_prev != nullptr) { route_add_wpt(route_dest, wpt_dest_prev); } - Waypoint* wpt_dest_next = create_wpt_dest(wpt_orig, - lat_orig, long_orig, lat_orig_next, long_orig_next); + Waypoint* wpt_dest_next = create_wpt_dest(wpt_orig, wpt_orig_next); if (wpt_dest_next != nullptr) { route_add_wpt(route_dest, wpt_dest_next); diff --git a/bend.h b/bend.h index a87d8c758..69cc59c70 100644 --- a/bend.h +++ b/bend.h @@ -61,11 +61,10 @@ class BendFilter:public Filter }, }; - Waypoint* create_wpt_dest(const Waypoint* wpt_orig, double lat_orig, - double long_orig, double lat_orig_adj, double long_orig_adj) const; - int is_small_angle(double lat_orig, double long_orig, double lat_orig_prev, - double long_orig_prev, double lat_orig_next, - double long_orig_next) const; + Waypoint* create_wpt_dest(const Waypoint* wpt_orig, const Waypoint* wpt_adj) const; + int is_small_angle(const Waypoint* wpt_orig, + const Waypoint* wpt_orig_prev, + const Waypoint* wpt_orig_next) const; void process_route(const route_head* route_orig, route_head* route_dest); void process_route_orig(const route_head* route_orig); diff --git a/reference/route/bend-expected.gpx b/reference/route/bend-expected.gpx index 78deb90f1..3b6ed9f78 100644 --- a/reference/route/bend-expected.gpx +++ b/reference/route/bend-expected.gpx @@ -1,7 +1,7 @@ - + santander Generated from track santander @@ -9,15 +9,15 @@ 34.733 RPT001 - + 34.252 RPT002 - + 34.252 RPT002 - + 31.369 RPT003 @@ -25,71 +25,71 @@ 31.369 RPT003 - + 28.965 RPT004 - + 24.159 RPT005 - + 24.159 RPT005 - + 22.236 RPT006 - + 22.236 RPT006 - + 29.927 RPT007 - + 29.927 RPT007 - + 37.617 RPT008 - + 37.617 RPT008 - + 56.843 RPT009 - + 56.843 RPT009 - + 52.998 RPT010 - + 52.998 RPT010 - + 52.998 RPT011 - + 52.998 RPT011 - + 43.385 RPT012 - + 43.385 RPT012 @@ -97,31 +97,31 @@ 29.927 RPT013 - + 29.927 RPT013 - + 20.794 RPT014 - + 20.794 RPT014 - + 19.833 RPT015 - + 19.833 RPT015 - + 15.507 RPT016 - + 15.507 RPT016 @@ -129,23 +129,23 @@ 15.026 RPT017 - + 15.026 RPT017 - + 11.662 RPT018 - + 11.662 RPT018 - + 11.181 RPT019 - + 11.181 RPT019 @@ -153,83 +153,83 @@ 11.662 RPT020 - + 11.662 RPT020 - + 7.816 RPT021 - + 7.816 RPT021 - + 14.546 RPT022 - + 14.546 RPT022 - + 17.430 RPT023 - + 17.430 RPT023 - + 16.468 RPT024 - + 16.468 RPT024 - + 19.352 RPT025 - + 19.352 RPT025 - + 17.910 RPT026 - + 17.910 RPT026 - + 26.081 RPT027 - + 26.081 RPT027 - + 27.523 RPT028 - + 27.523 RPT028 - + 28.965 RPT029 - + 28.965 RPT029 - + 36.175 RPT030 @@ -241,103 +241,103 @@ 40.501 RPT031 - + 40.501 RPT031 - + 51.075 RPT032 - + 51.075 RPT032 - + 49.153 RPT033 - + 49.153 RPT033 - + 52.037 RPT034 - + 52.037 RPT034 - + 56.843 RPT035 - + 56.843 RPT035 - + 59.246 RPT036 - + 59.246 RPT036 - + 58.766 RPT037 - + 58.766 RPT037 - + 62.611 RPT038 - + 62.611 RPT038 - + 65.014 RPT039 - + 65.014 RPT039 - + 65.014 RPT040 - + 65.014 RPT040 - + 67.418 RPT041 - + 67.418 RPT041 - + 62.130 RPT042 - + 62.130 RPT042 - + 64.534 RPT043 - + 64.534 RPT043 @@ -345,27 +345,27 @@ 66.456 RPT044 - + 66.456 RPT044 - + 53.479 RPT045 - + 53.479 RPT045 - + 46.750 RPT046 - + 46.750 RPT046 - + 56.843 RPT047 @@ -373,11 +373,11 @@ 56.843 RPT047 - + 58.766 RPT048 - + 62.611 RPT049 @@ -385,11 +385,11 @@ 62.611 RPT049 - + 60.688 RPT050 - + 29.927 RPT051 @@ -401,51 +401,51 @@ 29.446 RPT052 - + 29.446 RPT052 - + 12.623 RPT053 - + 12.623 RPT053 - + 35.214 RPT054 - + 35.214 RPT054 - + 26.081 RPT055 - + 35.694 RPT056 - + 36.656 RPT057 - + 36.656 RPT057 - + 38.578 RPT058 - + 38.578 RPT058 - + 32.811 RPT059 @@ -453,19 +453,19 @@ 32.811 RPT059 - + 32.811 RPT060 - + 32.811 RPT060 - + 31.369 RPT061 - + 31.369 RPT061 @@ -473,51 +473,51 @@ 29.927 RPT062 - + 29.927 RPT062 - + 25.120 RPT063 - + 25.120 RPT063 - + 9.258 RPT064 - + 9.258 RPT064 - + 6.374 RPT065 - + 6.374 RPT065 - + 5.413 RPT066 - + 5.413 RPT066 - + 5.894 RPT067 - + 5.894 RPT067 - + 7.816 RPT068 @@ -529,43 +529,43 @@ 6.374 RPT069 - + 6.374 RPT069 - + 2.529 RPT070 - + 2.529 RPT070 - + 2.529 RPT071 - + 2.529 RPT071 - + 3.971 RPT072 - + 3.971 RPT072 - + 1.568 RPT073 - + 1.568 RPT073 - + 0.126 RPT074 @@ -573,35 +573,35 @@ 0.126 RPT074 - + 2.049 RPT075 - + 2.049 RPT075 - + 0.126 RPT076 - + 0.126 RPT076 - + 2.049 RPT077 - + 2.049 RPT077 - + 3.490 RPT078 - + 3.971 RPT079 @@ -609,19 +609,19 @@ 3.971 RPT079 - + 4.932 RPT080 - + 2.049 RPT081 - + 2.049 RPT081 - + 0.607 RPT082 @@ -629,19 +629,19 @@ 0.607 RPT082 - + 2.529 RPT083 - + 1.568 RPT084 - + 1.568 RPT084 - + 2.529 RPT085 @@ -653,15 +653,15 @@ 3.971 RPT086 - + 5.413 RPT087 - + 5.413 RPT087 - + 1.087 RPT088 @@ -669,27 +669,27 @@ 1.087 RPT088 - + 3.971 RPT089 - + 12.142 RPT090 - + 12.142 RPT090 - + 8.297 RPT091 - + 8.297 RPT091 - + -0.835 RPT092 @@ -701,19 +701,19 @@ 5.413 RPT093 - + 5.413 RPT093 - + 25.120 RPT094 - + 25.120 RPT094 - + 25.120 RPT095 @@ -721,43 +721,43 @@ 25.120 RPT095 - + 23.197 RPT096 - + 26.562 RPT097 - + 26.562 RPT097 - + 26.081 RPT098 - + 26.081 RPT098 - + 26.562 RPT099 - + 26.562 RPT099 - + 26.081 RPT100 - + 26.081 RPT100 - + 30.888 RPT101 @@ -769,11 +769,11 @@ 25.601 RPT102 - + 25.601 RPT102 - + 20.794 RPT103 @@ -785,43 +785,43 @@ 17.430 RPT104 - + 17.430 RPT104 - + 6.374 RPT105 - + 6.374 RPT105 - + 4.932 RPT106 - + 4.932 RPT106 - + 2.529 RPT107 - + 2.529 RPT107 - + 15.507 RPT108 - + 15.507 RPT108 - + 19.833 RPT109 @@ -829,11 +829,11 @@ 19.833 RPT109 - + 20.313 RPT110 - + 11.181 RPT111 @@ -841,63 +841,63 @@ 11.181 RPT111 - + 2.049 RPT112 - + 2.049 RPT112 - + 6.374 RPT113 - + 6.374 RPT113 - + 7.336 RPT114 - + 7.336 RPT114 - + 11.662 RPT115 - + 11.662 RPT115 - + 12.142 RPT116 - + 12.142 RPT116 - + 15.026 RPT117 - + 15.026 RPT117 - + 13.584 RPT118 - + 13.584 RPT118 - + 10.220 RPT119 @@ -905,27 +905,27 @@ 10.220 RPT119 - + 9.258 RPT120 - + 14.065 RPT121 - + 14.065 RPT121 - + 11.662 RPT122 - + 11.662 RPT122 - + 6.855 RPT123 @@ -933,139 +933,139 @@ 6.855 RPT123 - + 4.932 RPT124 - + 3.971 RPT125 - + 3.971 RPT125 - + 5.894 RPT126 - + 5.894 RPT126 - + 5.413 RPT127 - + 5.413 RPT127 - + 22.717 RPT128 - + 22.717 RPT128 - + 38.578 RPT129 - + 38.578 RPT129 - + 58.766 RPT130 - + 58.766 RPT130 - + 66.456 RPT131 - + 66.456 RPT131 - + 62.611 RPT132 - + 62.611 RPT132 - + 64.053 RPT133 - + 64.053 RPT133 - + 65.976 RPT134 - + 65.976 RPT134 - + 66.456 RPT135 - + 66.456 RPT135 - + 61.169 RPT136 - + 61.169 RPT136 - + 62.611 RPT137 - + 62.611 RPT137 - + 61.650 RPT138 - + 61.650 RPT138 - + 46.269 RPT139 - + 46.269 RPT139 - + 36.175 RPT140 - + 36.175 RPT140 - + 18.391 RPT141 @@ -1077,27 +1077,27 @@ 10.220 RPT142 - + 18.391 RPT143 - + 18.391 RPT143 - + 37.136 RPT144 - + 37.136 RPT144 - + 31.369 RPT145 - + 31.369 RPT145 @@ -1105,19 +1105,19 @@ 4.932 RPT146 - + 13.584 RPT147 - + 13.584 RPT147 - + 24.639 RPT148 - + 24.639 RPT148 @@ -1125,91 +1125,91 @@ 27.523 RPT149 - + 27.523 RPT149 - + 22.717 RPT150 - + 22.717 RPT150 - + 45.307 RPT151 - + 45.307 RPT151 - + 26.562 RPT152 - + 26.562 RPT152 - + 34.733 RPT153 - + 34.733 RPT153 - + 26.562 RPT154 - + 26.562 RPT154 - + 34.252 RPT155 - + 34.252 RPT155 - + 28.965 RPT156 - + 28.965 RPT156 - + 24.159 RPT157 - + 24.159 RPT157 - + 23.197 RPT158 - + 23.197 RPT158 - + 21.755 RPT159 - + 21.755 RPT160 - + 23.197 RPT161 @@ -1221,63 +1221,63 @@ 9.739 RPT162 - + 9.739 RPT162 - + 11.181 RPT163 - + 11.181 RPT163 - + 12.623 RPT164 - + 12.623 RPT164 - + 22.236 RPT165 - + 22.236 RPT165 - + 38.098 RPT166 - + 38.098 RPT166 - + 24.639 RPT167 - + 24.639 RPT167 - + 16.949 RPT168 - + 16.949 RPT168 - + 19.833 RPT169 - + 19.833 RPT169 @@ -1285,31 +1285,31 @@ 3.010 RPT170 - + 18.871 RPT171 - + 18.871 RPT171 - + 15.507 RPT172 - + 15.507 RPT172 - + 23.678 RPT173 - + 23.678 RPT173 - + 36.656 RPT174 @@ -1317,19 +1317,19 @@ 36.656 RPT174 - + 39.540 RPT175 - + 40.501 RPT176 - + 40.501 RPT176 - + 46.269 RPT177 @@ -1337,15 +1337,15 @@ 46.269 RPT177 - + 55.709 RPT178 - + 55.709 RPT178 - + 70.709 RPT179 @@ -1353,11 +1353,11 @@ 70.709 RPT179 - + 75.709 RPT180 - + 90.267 RPT181 @@ -1365,55 +1365,55 @@ 90.267 RPT181 - + 95.964 RPT182 - + 95.964 RPT182 - + 100.102 RPT183 - + 100.102 RPT183 - + 93.373 RPT184 - + 93.373 RPT184 - + 90.970 RPT185 - + 90.970 RPT185 - + 88.086 RPT186 - + 88.086 RPT186 - + 87.605 RPT187 - + 87.605 RPT187 - + 102.986 RPT188 @@ -1425,15 +1425,15 @@ 126.058 RPT189 - + 126.058 RPT189 - + 144.803 RPT190 - + 144.803 RPT190 @@ -1441,11 +1441,11 @@ 180.372 RPT191 - + 180.372 RPT191 - + 191.427 RPT192 @@ -1453,15 +1453,15 @@ 191.427 RPT192 - + 197.195 RPT193 - + 210.653 RPT194 - + 210.653 RPT194 @@ -1469,39 +1469,39 @@ 231.802 RPT195 - + 208.730 RPT196 - + 208.730 RPT196 - + 195.272 RPT197 - + 195.272 RPT197 - + 187.101 RPT198 - + 187.101 RPT198 - + 155.378 RPT199 - + 155.378 RPT199 - + 148.168 RPT200 @@ -1513,27 +1513,27 @@ 183.736 RPT201 - + 183.736 RPT201 - + 200.079 RPT202 - + 200.079 RPT202 - + 208.730 RPT203 - + 208.730 RPT203 - + 221.228 RPT204 @@ -1541,11 +1541,11 @@ 221.228 RPT204 - + 235.166 RPT205 - + 235.166 RPT205 @@ -1553,23 +1553,23 @@ 226.034 RPT206 - + 226.034 RPT206 - + 201.521 RPT207 - + 201.521 RPT207 - + 188.543 RPT208 - + 188.543 RPT208 @@ -1577,183 +1577,183 @@ 144.803 RPT209 - + 144.803 RPT209 - + 141.919 RPT210 - + 141.919 RPT210 - + 136.151 RPT211 - + 136.151 RPT211 - + 110.196 RPT212 - + 110.196 RPT212 - + 86.163 RPT213 - + 86.163 RPT213 - + 75.589 RPT214 - + 75.589 RPT214 - + 71.263 RPT215 - + 71.263 RPT215 - + 66.937 RPT216 - + 66.937 RPT216 - + 63.092 RPT217 - + 63.092 RPT217 - + 61.650 RPT218 - + 61.650 RPT218 - + 59.727 RPT219 - + 59.727 RPT219 - + 55.882 RPT220 - + 55.882 RPT220 - + 53.479 RPT221 - + 53.479 RPT221 - + 55.401 RPT222 - + 55.401 RPT222 - + 52.037 RPT223 - + 52.037 RPT223 - + 49.153 RPT224 - + 49.153 RPT224 - + 46.750 RPT225 - + 46.750 RPT225 - + 48.672 RPT226 - + 48.672 RPT226 - + 44.827 RPT227 - + 44.827 RPT227 - + 44.827 RPT228 - + 44.827 RPT228 - + 44.346 RPT229 - + 44.346 RPT229 - + 45.307 RPT230 - + 45.307 RPT230 - + 42.904 RPT231 - + 42.904 RPT231 diff --git a/reference/route/bendgc-expected.gpx b/reference/route/bendgc-expected.gpx new file mode 100644 index 000000000..e6b35637d --- /dev/null +++ b/reference/route/bendgc-expected.gpx @@ -0,0 +1,71 @@ + + + + + + RPT001 + <table> +<tr><td>Longitude: 140.615728</td></tr> +<tr><td>Latitude: 35.752604</td></tr> +</table> + <table> +<tr><td>Longitude: 140.615728</td></tr> +<tr><td>Latitude: 35.752604</td></tr> +</table> + + + RPT002 + <table> +<tr><td>Longitude: 166.492918</td></tr> +<tr><td>Latitude: 42.992831</td></tr> +</table> + <table> +<tr><td>Longitude: 166.492918</td></tr> +<tr><td>Latitude: 42.992831</td></tr> +</table> + + + RPT003 + <table> +<tr><td>Longitude: -157.876012</td></tr> +<tr><td>Latitude: 46.203079</td></tr> +</table> + <table> +<tr><td>Longitude: -157.876012</td></tr> +<tr><td>Latitude: 46.203079</td></tr> +</table> + + + RPT004 + <table> +<tr><td>Longitude: -127.622914</td></tr> +<tr><td>Latitude: 42.925678</td></tr> +</table> + <table> +<tr><td>Longitude: -127.622914</td></tr> +<tr><td>Latitude: 42.925678</td></tr> +</table> + + + Path + Generated from track Path + + RPT001 + + + RPT002 + + + RPT002 + + + RPT003 + + + RPT003 + + + RPT004 + + + diff --git a/reference/route/bendgc-input.kml b/reference/route/bendgc-input.kml new file mode 100644 index 000000000..a5de804e5 --- /dev/null +++ b/reference/route/bendgc-input.kml @@ -0,0 +1,169 @@ + + + + GPS device + Created Mon Aug 12 01:46:31 2024 GMT + + 186.496407 + 40.977841 + 9571750.976741 + + + + + + + + normal + #route_n + + + highlight + #route_h + + + + + + + + + normal + #waypoint_n + + + highlight + #waypoint_h + + + + + Routes + + + Points + + RPT001 + + +Longitude: 140.615728 +Latitude: 35.752604 + +]]> + + 140.615728 + 35.752604 + 66 + + #route + + 140.615728,35.752604 + + + + RPT002 + + +Longitude: 166.492918 +Latitude: 42.992831 + +]]> + + 166.492918 + 42.992831 + 66 + + #route + + 166.492918,42.992831 + + + + RPT003 + + +Longitude: -157.876012 +Latitude: 46.203079 + +]]> + + -157.876012 + 46.203079 + 66 + + #route + + -157.876012,46.203079 + + + + RPT004 + + +Longitude: -127.622914 +Latitude: 42.925678 + +]]> + + -127.622914 + 42.925678 + 66 + + #route + + -127.622914,42.925678 + + + + + Path + #lineStyle + + 1 + +140.615728,35.752604 +166.492918,42.992831 +-157.876012,46.203079 +-127.622914,42.925678 + + + + + + + diff --git a/testo.d/bend.test b/testo.d/bend.test index bf6e81a82..349842a58 100644 --- a/testo.d/bend.test +++ b/testo.d/bend.test @@ -3,3 +3,7 @@ rm -f ${TMPDIR}/bend.* gpsbabel -i gpx -f ${REFERENCE}/route/bend-input.gpx -x bend,distance=25,minangle=5 -o gpx -F ${TMPDIR}/bend.gpx compare ${REFERENCE}/route/bend-expected.gpx ${TMPDIR}/bend.gpx + +# Although not a real useful use case, test with extremly long segments to check great circle usage. +gpsbabel -i kml -f ${REFERENCE}/route/bendgc-input.kml -x transform,rte=trk,del -x bend,distance=1000000,minangle=5 -o gpx -F ${TMPDIR}/bendgc-expected.gpx +compare ${REFERENCE}/route/bendgc-expected.gpx ${TMPDIR}/bendgc-expected.gpx diff --git a/tools/ci_script_osx.sh b/tools/ci_script_osx.sh index 3cb759eec..7222bc86d 100755 --- a/tools/ci_script_osx.sh +++ b/tools/ci_script_osx.sh @@ -41,13 +41,13 @@ case "${GENERATOR[1]}" in Xcode | "Ninja Multi-Config") cmake "${SOURCE_DIR}" -DCMAKE_OSX_ARCHITECTURES=${ARCHS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPLOY_TARGET} "${GENERATOR[@]}" cmake --build . --config Release - ctest -C Release + ctest -C Release --output-on-failure cmake --build . --config Release --target package_app ;; *) cmake "${SOURCE_DIR}" -DCMAKE_OSX_ARCHITECTURES=${ARCHS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPLOY_TARGET} -DCMAKE_BUILD_TYPE=Release "${GENERATOR[@]}" cmake --build . - ctest + ctest --output-on-failure cmake --build . --target package_app cmake --build . --target gpsbabel.html cmake --build . --target gpsbabel.pdf From 4e017862e159f75e43a0d254564b5e9c2c6c0b37 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:21:31 -0600 Subject: [PATCH 111/132] use implicit conversions for lat,lon degs<->rads in grtcirc interface (#1321) * use implict conversions for lat,lon degs<->rads. * use Position* return values. * convert grtcirc i/f to PositionDeg, PositionRad. * fix mac compile, denote converting ctor. * inline PositionDeg/Rad converting ctors. * respect PosotionX encapsulation. * differentiate member names for PositionDeg, PositiionRad. This can catch unintended usages where the type is not what was expected. * clean up unneccesary usage of Waypoint::position. * delete obsolete declaration. * spell * update garmin include * consistenly unpack Positions to consts in grtcirc. * provide default initializers for PositionX. --- arcdist.cc | 27 +++------- arcdist.h | 3 +- bend.cc | 26 +++------ defs.h | 45 ++++++++++++++++ garmin.cc | 1 - gdb.cc | 4 +- grtcirc.cc | 140 ++++++++++++++++++++++++------------------------- grtcirc.h | 37 +++++-------- igc.cc | 3 +- interpolate.cc | 17 ++---- kml.cc | 3 +- position.cc | 6 +-- position.h | 4 -- radius.cc | 4 +- radius.h | 5 -- route.cc | 8 +-- smplrout.cc | 33 +++++------- trackfilter.cc | 43 +++++---------- waypt.cc | 5 +- xcsv.cc | 14 ++--- xcsv.h | 3 +- 21 files changed, 194 insertions(+), 237 deletions(-) diff --git a/arcdist.cc b/arcdist.cc index 5f56b8ca4..d213222d6 100644 --- a/arcdist.cc +++ b/arcdist.cc @@ -44,8 +44,7 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2) { static const Waypoint* arcpt1 = nullptr; - double prjlat; - double prjlon; + PositionDeg prjpos; double frac; if (arcpt2 && arcpt2->latitude != BADVAL && arcpt2->longitude != BADVAL && @@ -62,12 +61,8 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2) if (ed->distance == BADVAL || projectopt || ed->distance >= pos_dist) { double dist; if (ptsopt) { - dist = gcdist(RAD(arcpt2->latitude), - RAD(arcpt2->longitude), - RAD(waypointp->latitude), - RAD(waypointp->longitude)); - prjlat = arcpt2->latitude; - prjlon = arcpt2->longitude; + dist = gcdist(arcpt2->position(), waypointp->position()); + prjpos = arcpt2->position(); frac = 1.0; } else { if (waypointp == nullptr) { @@ -77,13 +72,9 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2) fatal(FatalMsg() << "Internal error: Attempt to project waypoint without predecessor"); } - dist = linedistprj(arcpt1->latitude, - arcpt1->longitude, - arcpt2->latitude, - arcpt2->longitude, - waypointp->latitude, - waypointp->longitude, - &prjlat, &prjlon, &frac); + std::tie(dist, prjpos, frac) = linedistprj(arcpt1->position(), + arcpt2->position(), + waypointp->position()); } /* convert radians to float point statute miles */ @@ -92,8 +83,7 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2) if (ed->distance > dist) { ed->distance = dist; if (projectopt) { - ed->prjlatitude = prjlat; - ed->prjlongitude = prjlon; + ed->prjpos = prjpos; ed->frac = frac; ed->arcpt1 = arcpt1; ed->arcpt2 = arcpt2; @@ -171,8 +161,7 @@ void ArcDistanceFilter::process() wp->wpt_flags.marked_for_deletion = 1; removed++; } else if (projectopt) { - wp->longitude = ed->prjlongitude; - wp->latitude = ed->prjlatitude; + wp->SetPosition(ed->prjpos); if (!arcfileopt && (ed->arcpt2->altitude != unknown_alt) && (ptsopt || (ed->arcpt1->altitude != unknown_alt))) { diff --git a/arcdist.h b/arcdist.h index 2458ffc9e..7e30e4e70 100644 --- a/arcdist.h +++ b/arcdist.h @@ -44,8 +44,7 @@ class ArcDistanceFilter:public Filter struct extra_data { double distance; - double prjlatitude; - double prjlongitude; + PositionDeg prjpos; double frac; const Waypoint* arcpt1; const Waypoint* arcpt2; diff --git a/bend.cc b/bend.cc index 774bea92e..09325673f 100644 --- a/bend.cc +++ b/bend.cc @@ -55,8 +55,8 @@ void BendFilter::init() Waypoint* BendFilter::create_wpt_dest(const Waypoint* wpt_orig, const Waypoint* wpt_orig_adj) const { - double distance = radtometers(gcdist(RAD(wpt_orig->latitude), RAD(wpt_orig->longitude), - RAD(wpt_orig_adj->latitude), RAD(wpt_orig_adj->longitude))); + double distance = radtometers(gcdist(wpt_orig->position(), + wpt_orig_adj->position())); if (distance <= maxDist) { return nullptr; } @@ -64,10 +64,7 @@ Waypoint* BendFilter::create_wpt_dest(const Waypoint* wpt_orig, const Waypoint* double frac = maxDist / distance; auto* wpt_dest = new Waypoint(*wpt_orig); - linepart(wpt_orig->latitude, wpt_orig->longitude, - wpt_orig_adj->latitude, wpt_orig_adj->longitude, - frac, - &wpt_dest->latitude, &wpt_dest->longitude); + wpt_dest->SetPosition(linepart(wpt_orig->position(), wpt_orig_adj->position(), frac)); return wpt_dest; } @@ -76,19 +73,10 @@ int BendFilter::is_small_angle(const Waypoint* wpt_orig, const Waypoint* wpt_orig_prev, const Waypoint* wpt_orig_next) const { - double lat_orig = RAD(wpt_orig->latitude); - double long_orig = RAD(wpt_orig->longitude); - - double lat_orig_prev = RAD(wpt_orig_prev->latitude); - double long_orig_prev = RAD(wpt_orig_prev->longitude); - - double lat_orig_next = RAD(wpt_orig_next->latitude); - double long_orig_next = RAD(wpt_orig_next->longitude); - - double heading_prev = heading_true_degrees(lat_orig, long_orig, - lat_orig_prev, long_orig_prev); - double heading_next = heading_true_degrees(lat_orig, long_orig, - lat_orig_next, long_orig_next); + double heading_prev = heading_true_degrees(wpt_orig->position(), + wpt_orig_prev->position()); + double heading_next = heading_true_degrees(wpt_orig->position(), + wpt_orig_next->position()); double heading_diff = heading_next - heading_prev; diff --git a/defs.h b/defs.h index df3e8c3aa..906bd9a61 100644 --- a/defs.h +++ b/defs.h @@ -19,10 +19,12 @@ #ifndef DEFS_H_INCLUDED_ #define DEFS_H_INCLUDED_ +#include // for nan #include // for NULL, nullptr_t, size_t #include // for int32_t, uint32_t #include // for NULL, fprintf, FILE, stdout #include // for time_t +#include // for inv_pi, pi #include // for optional #include // for move @@ -107,6 +109,14 @@ constexpr double MPH_TO_MPS(double a) { return a * kMPSPerMPH;} /* knots(nautical miles/hour) to meters/second */ constexpr double KNOTS_TO_MPS(double a) {return a * kMPSPerKnot;} +/* Degrees to radians */ +constexpr double kDegreesPerRadian = 180.0 * std::numbers::inv_pi; +constexpr double DEG(double x) { return x * kDegreesPerRadian; } + +/* Radians to degrees */ +constexpr double kRadiansPerDegree = 1.0 / kDegreesPerRadian; +constexpr double RAD(double x) { return x * kRadiansPerDegree; } + constexpr int kDatumOSGB36 = 86; // GPS_Lookup_Datum_Index("OSGB36") constexpr int kDatumWGS84 = 118; // GPS_Lookup_Datum_Index("WGS 84") @@ -246,6 +256,35 @@ struct bounds { double min_alt; /* -unknown_alt => invalid */ }; +struct PositionRad; // forward declare +struct PositionDeg +{ + PositionDeg() = default; + explicit(false) inline PositionDeg(const PositionRad& posr); /* converting ctor */ + PositionDeg(double latd, double lond) : latD(latd), lonD(lond) {} + + double latD{std::nan("")}; + double lonD{std::nan("")}; +}; + +struct PositionRad +{ + PositionRad() = default; + explicit(false) inline PositionRad(const PositionDeg& posd); /* converting ctor */ + PositionRad(double latr, double lonr) : latR(latr), lonR(lonr) {} + + double latR{std::nan("")}; + double lonR{std::nan("")}; +}; + +inline PositionDeg::PositionDeg(const PositionRad& posr) : + latD(posr.latR * kDegreesPerRadian), + lonD(posr.lonR * kDegreesPerRadian) {} + +inline PositionRad::PositionRad(const PositionDeg& posd) : + latR(posd.latD * kRadiansPerDegree), + lonR(posd.lonD * kRadiansPerDegree) {} + /* * This is a waypoint, as stored in the GPSR. It tries to not * cater to any specific model or protocol. Anything that needs to @@ -318,6 +357,12 @@ class Waypoint void SetCreationTime(qint64 t, qint64 ms = 0); Geocache* AllocGCData(); int EmptyGCData() const; + PositionDeg position() const {return PositionDeg(latitude, longitude);} + void SetPosition(const PositionDeg& pos) + { + latitude = pos.latD; + longitude = pos.lonD; + } // mimic std::optional interface, but use our more space // efficient wp_flags. diff --git a/garmin.cc b/garmin.cc index 7c20fc836..13012f5ee 100644 --- a/garmin.cc +++ b/garmin.cc @@ -43,7 +43,6 @@ #include "garmin_fs.h" // for garmin_fs_garmin_after_read, garmin_fs_garmin_before_write #include "garmin_tables.h" // for gt_find_icon_number_from_desc, PCX, gt_find_desc_from_icon_number #include "geocache.h" // for Geocache, Geocache::type_t, Geocache... -#include "grtcirc.h" // for DEG #include "jeeps/gpsapp.h" // for GPS_Set_Baud_Rate, GPS_Init, GPS_Pre... #include "jeeps/gpscom.h" // for GPS_Command_Get_Lap, GPS_Command_Get... #include "jeeps/gpsmem.h" // for GPS_Track_Del, GPS_Way_Del, GPS_Pvt_Del diff --git a/gdb.cc b/gdb.cc index 47f0d072a..ca276ce86 100644 --- a/gdb.cc +++ b/gdb.cc @@ -258,9 +258,7 @@ GdbFormat::gdb_add_route_waypt(route_head* rte, Waypoint* ref, const int wpt_cla /* At this point we have found a waypoint with same name, but probably from another data stream. Check coordinates! */ - double dist = radtometers(gcdist( - RAD(ref->latitude), RAD(ref->longitude), - RAD(tmp->latitude), RAD(tmp->longitude))); + double dist = radtometers(gcdist(ref->position(), tmp->position())); if (fabs(dist) > 100) { fatal(MYNAME ": Route point mismatch!\n" \ diff --git a/grtcirc.cc b/grtcirc.cc index 90c0e0850..b8e4e34cb 100644 --- a/grtcirc.cc +++ b/grtcirc.cc @@ -25,9 +25,10 @@ #include // for errno, EDOM #include // for cos, sin, fabs, atan2, sqrt, asin, atan, isnan #include // for pi -#include // for make_tuple, tuple +#include // for tie, tuple, make_tuple, ignore -#include "defs.h" // for METERS_TO_MILES +#include "defs.h" // for PositionRad, DEG, METERS_TO_MILES, PositionDeg +#include "grtcirc.h" static constexpr double EARTH_RAD = 6378137.0; @@ -46,17 +47,6 @@ static double dotproduct(double x1, double y1, double z1, return (x1 * x2 + y1 * y2 + z1 * z2); } -/* - * Note: this conversion to miles uses the WGS84 value for the radius of - * the earth at the equator. - * (radius in meters)*(100cm/m) -> (radius in cm) - * (radius in cm) / (2.54 cm/in) -> (radius in in) - * (radius in in) / (12 in/ft) -> (radius in ft) - * (radius in ft) / (5280 ft/mi) -> (radius in mi) - * If the compiler is half-decent, it'll do all the math for us at compile - * time, so why not leave the expression human-readable? - */ - double radtomiles(double rads) { constexpr double radmiles = METERS_TO_MILES(EARTH_RAD); @@ -68,10 +58,15 @@ double radtometers(double rads) return (rads * EARTH_RAD); } -double gcdist(double lat1, double lon1, double lat2, double lon2) +double gcdist(PositionRad pos1, PositionRad pos2) { errno = 0; + const double lat1 = pos1.latR; + const double lon1 = pos1.lonR; + const double lat2 = pos2.latR; + const double lon2 = pos2.lonR; + double sdlat = sin((lat1 - lat2) / 2.0); double sdlon = sin((lon1 - lon2) / 2.0); @@ -92,8 +87,13 @@ double gcdist(double lat1, double lon1, double lat2, double lon2) /* This value is the heading you'd leave point 1 at to arrive at point 2. * Inputs and outputs are in radians. */ -static double heading(double lat1, double lon1, double lat2, double lon2) +static double heading(PositionRad pos1, PositionRad pos2) { + const double lat1 = pos1.latR; + const double lon1 = pos1.lonR; + const double lat2 = pos2.latR; + const double lon2 = pos2.lonR; + double v1 = sin(lon2 - lon1) * cos(lat2); double v2 = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon2 - lon1); /* rounding error protection */ @@ -106,10 +106,9 @@ static double heading(double lat1, double lon1, double lat2, double lon2) return atan2(v1, v2); } -/* As above, but outputs is in degrees from 0 - 359. Inputs are still radians. */ -double heading_true_degrees(double lat1, double lon1, double lat2, double lon2) +double heading_true_degrees(PositionRad pos1, PositionRad pos2) { - double h = 360.0 + DEG(heading(lat1, lon1, lat2, lon2)); + double h = 360.0 + DEG(heading(pos1, pos2)); if (h >= 360.0) { h -= 360.0; } @@ -120,11 +119,9 @@ double heading_true_degrees(double lat1, double lon1, double lat2, double lon2) // Note: This is probably not going to vectorize as it uses statics internally, // so it's hard for the optimizer to prove it's a pure function with no side // effects, right? -double linedistprj(double lat1, double lon1, - double lat2, double lon2, - double lat3, double lon3, - double* prjlat, double* prjlon, - double* frac) +std::tuple linedistprj(PositionRad pos1, + PositionRad pos2, + PositionRad pos3) { static double _lat1 = -9999; static double _lat2 = -9999; @@ -144,17 +141,22 @@ double linedistprj(double lat1, double lon1, double dot; - *prjlat = lat1; - *prjlon = lon1; - *frac = 0; + /* prjpos must be of type PositionRad as we assign + * prjpos.lat, prjpos.lon below in radians. + */ + PositionRad prjpos = pos1; - /* degrees to radians */ - lat1 = RAD(lat1); - lon1 = RAD(lon1); - lat2 = RAD(lat2); - lon2 = RAD(lon2); - lat3 = RAD(lat3); - lon3 = RAD(lon3); + double frac = 0; + + /* we use these values below assuming they are in radians, + * => posn must be of type PositionRad. + */ + const double lat1 = pos1.latR; + const double lon1 = pos1.lonR; + const double lat2 = pos2.latR; + const double lon2 = pos2.lonR; + const double lat3 = pos3.latR; + const double lon3 = pos3.lonR; bool newpoints = true; if (lat1 == _lat1 && lat2 == _lat2 && lon1 == _lon1 && lon2 == _lon2) { @@ -183,10 +185,7 @@ double linedistprj(double lat1, double lon1, /* 'a' is the axis; the line that passes through the center of the earth * and is perpendicular to the great circle through point 1 and point 2 * It is computed by taking the cross product of the '1' and '2' vectors.*/ - auto [xt, yt, zt] = crossproduct(x1, y1, z1, x2, y2, z2); - xa = xt; - ya = yt; - za = zt; + std::tie(xa, ya, za) = crossproduct(x1, y1, z1, x2, y2, z2); la = sqrt(xa * xa + ya * ya + za * za); if (la) { @@ -230,15 +229,15 @@ double linedistprj(double lat1, double lon1, * atan2 would be overkill because lp and fabs(dot) are both * known to be positive. */ - *prjlat = DEG(asin(yp)); + prjpos.latR = asin(yp); if (xp == 0 && zp == 0) { - *prjlon = 0; + prjpos.lonR = 0; } else { - *prjlon = DEG(atan2(zp, xp)); + prjpos.lonR = atan2(zp, xp); } - *frac = d1 / (d1 + d2); + frac = d1 / (d1 + d2); - return atan(fabs(dot) / lp); + return {atan(fabs(dot) / lp), prjpos , frac}; } /* otherwise, get the distance from the closest endpoint */ @@ -264,34 +263,32 @@ double linedistprj(double lat1, double lon1, } if (fabs(d1) < fabs(d2)) { - return gcdist(lat1, lon1, lat3, lon3); + return {gcdist(pos1, pos3), prjpos, frac}; } else { - *prjlat = DEG(lat2); - *prjlon = DEG(lon2); - *frac = 1.0; - return gcdist(lat2, lon2, lat3, lon3); + prjpos = pos2; + frac = 1.0; + return {gcdist(pos2, pos3), prjpos, frac}; } } else { /* lp is 0 when 3 is 90 degrees from the great circle */ - return std::numbers::pi / 2; + return {std::numbers::pi / 2, prjpos, frac}; } } else { /* la is 0 when 1 and 2 are either the same point or 180 degrees apart */ dot = dotproduct(x1, y1, z1, x2, y2, z2); if (dot >= 0) { - return gcdist(lat1, lon1, lat3, lon3); + return {gcdist(pos1, pos3), prjpos, frac}; } else { - return 0; + return {0, prjpos, frac}; } } } -double linedist(double lat1, double lon1, - double lat2, double lon2, - double lat3, double lon3) +double linedist(PositionRad pos1, PositionRad pos2, PositionRad pos3) { - double dummy; - return linedistprj(lat1, lon1, lat2, lon2, lat3, lon3, &dummy, &dummy, &dummy); + double dist; + std::tie(dist, std::ignore, std::ignore) = linedistprj(pos1, pos2, pos3); + return dist; } /* @@ -301,20 +298,20 @@ double linedist(double lat1, double lon1, * Ref: http://mathworld.wolfram.com/RotationFormula.html */ -void linepart(double lat1, double lon1, - double lat2, double lon2, - double frac, - double* reslat, double* reslon) +PositionDeg linepart(PositionRad pos1, PositionRad pos2, double frac) { - /* result must be in degrees */ - *reslat = lat1; - *reslon = lon1; - - /* degrees to radians */ - lat1 = RAD(lat1); - lon1 = RAD(lon1); - lat2 = RAD(lat2); - lon2 = RAD(lon2); + /* respos must be of type PositionRad as we assign + * respos.lat, respos.lon below in radians. + */ + PositionRad respos = pos1; + + /* we use these values below assuming they are in radians, + * => posn must be of type PositionRad. + */ + const double lat1 = pos1.latR; + const double lon1 = pos1.lonR; + const double lat2 = pos2.latR; + const double lon2 = pos2.lonR; /* polar to ECEF rectangular */ double x1 = cos(lon1) * cos(lat1); @@ -357,11 +354,12 @@ void linepart(double lat1, double lon1, yr = std::clamp(yr, -1.0, 1.0); zr = std::clamp(zr, -1.0, 1.0); - *reslat = DEG(asin(yr)); + respos.latR = asin(yr); if (xr == 0 && zr == 0) { - *reslon = 0; + respos.lonR = 0; } else { - *reslon = DEG(atan2(zr, xr)); + respos.lonR = atan2(zr, xr); } } + return respos; } diff --git a/grtcirc.h b/grtcirc.h index 981f87228..9d8900dd0 100644 --- a/grtcirc.h +++ b/grtcirc.h @@ -22,35 +22,24 @@ #ifndef GRTCIRC_H #define GRTCIRC_H -#include // for inv_pi +#include // for tuple +#include "defs.h" // for PositionRad, PositionDeg -double gcdist(double lat1, double lon1, double lat2, double lon2); -double heading_true_degrees(double lat1, double lon1, double lat2, double lon2); +/* Note PositionDeg and PositionRad can be implicity converted to + * each other, so you may use either to interface to these functions. + */ + +double gcdist(PositionRad pos1, PositionRad pos2); +double heading_true_degrees(PositionRad pos1, PositionRad pos2); -double linedistprj(double lat1, double lon1, - double lat2, double lon2, - double lat3, double lon3, - double* prjlat, double* prjlon, - double* frac); +std::tuple linedistprj(PositionRad pos1, + PositionRad pos2, + PositionRad pos3); -double linedist(double lat1, double lon1, - double lat2, double lon2, - double lat3, double lon3); +double linedist(PositionRad pos1, PositionRad pos2, PositionRad pos3); double radtometers(double rads); double radtomiles(double rads); -void linepart(double lat1, double lon1, - double lat2, double lon2, - double frac, - double* reslat, double* reslon); - -/* Degrees to radians */ -constexpr double kDegreesPerRadian = 180.0 * std::numbers::inv_pi; -constexpr double DEG(double x) { return x * kDegreesPerRadian; } - -/* Radians to degrees */ -constexpr double kRadiansPerDegree = 1.0 / kDegreesPerRadian; -constexpr double RAD(double x) { return x * kRadiansPerDegree; } - +PositionDeg linepart(PositionRad pos1, PositionRad pos2, double frac); #endif diff --git a/igc.cc b/igc.cc index 23b026470..f93bb793c 100644 --- a/igc.cc +++ b/igc.cc @@ -869,8 +869,7 @@ int IgcFormat::correlate_tracks(const route_head* pres_track, const route_head* // Get a crude indication of groundspeed from the change in lat/lon int deltat_msec = (*wpt_rit)->GetCreationTime().msecsTo(wpt->GetCreationTime()); speed = (deltat_msec == 0) ? 0: - radtometers(gcdist(RAD(wpt->latitude), RAD(wpt->longitude), - RAD((*wpt_rit)->latitude), RAD((*wpt_rit)->longitude))) / + radtometers(gcdist(wpt->position(), (*wpt_rit)->position())) / (0.001 * deltat_msec); if (global_opts.debug_level >= 2) { printf(MYNAME ": speed=%.2fm/s\n", speed); diff --git a/interpolate.cc b/interpolate.cc index f1367c1f2..4a88ac0ba 100644 --- a/interpolate.cc +++ b/interpolate.cc @@ -65,8 +65,7 @@ void InterpolateFilter::process_rte(route_head* rte) } // And add them back, with interpolated points interspersed. - double lat1 = 0; - double lon1 = 0; + PositionDeg pos1; double altitude1 = unknown_alt; gpsbabel::DateTime time1; bool first = true; @@ -92,10 +91,7 @@ void InterpolateFilter::process_rte(route_head* rte) // interpolate even if time is running backwards. npts = std::abs(*timespan) / max_time_step; } else if (opt_dist != nullptr) { - double distspan = radtomiles(gcdist(RAD(lat1), - RAD(lon1), - RAD(wpt->latitude), - RAD(wpt->longitude))); + double distspan = radtomiles(gcdist(pos1, wpt->position())); npts = distspan / max_dist_step; } if (!std::isfinite(npts) || (npts >= INT_MAX)) { @@ -119,11 +115,7 @@ void InterpolateFilter::process_rte(route_head* rte) } else { wpt_new->creation_time = gpsbabel::DateTime(); } - linepart(lat1, lon1, - wpt->latitude, wpt->longitude, - frac, - &wpt_new->latitude, - &wpt_new->longitude); + wpt_new->SetPosition(linepart(pos1, wpt->position(), frac)); if (altspan.has_value()) { wpt_new->altitude = altitude1 + (frac * *altspan); } else { @@ -142,8 +134,7 @@ void InterpolateFilter::process_rte(route_head* rte) track_add_wpt(rte, wpt); } - lat1 = wpt->latitude; - lon1 = wpt->longitude; + pos1 = wpt->position(); altitude1 = wpt->altitude; time1 = wpt->creation_time.toUTC(); // use utc to avoid tz conversions. } diff --git a/kml.cc b/kml.cc index cacf0385c..ae27864b0 100644 --- a/kml.cc +++ b/kml.cc @@ -2070,8 +2070,7 @@ void KmlFormat::wr_position(Waypoint* wpt) } else { Waypoint* newest_posn= posn_trk_head->waypoint_list.back(); - if (radtometers(gcdist(RAD(wpt->latitude), RAD(wpt->longitude), - RAD(newest_posn->latitude), RAD(newest_posn->longitude))) > 50) { + if (radtometers(gcdist(wpt->position(), newest_posn->position())) > 50) { track_add_wpt(posn_trk_head, new Waypoint(*wpt)); } else { /* If we haven't move more than our threshold, pretend diff --git a/position.cc b/position.cc index a7275b84e..759e9e11f 100644 --- a/position.cc +++ b/position.cc @@ -49,10 +49,8 @@ void PositionFilter::position_runqueue(const WaypointList& waypt_list, int qtype for (int j = i + 1 ; j < nelems ; ++j) { if (!qlist.at(j).deleted) { - double dist = gc_distance(qlist.at(j).wpt->latitude, - qlist.at(j).wpt->longitude, - qlist.at(i).wpt->latitude, - qlist.at(i).wpt->longitude); + double dist = radtometers(gcdist(qlist.at(j).wpt->position(), + qlist.at(i).wpt->position())); if (dist <= pos_dist) { if (check_time) { diff --git a/position.h b/position.h index 8c1f8111f..4c2204172 100644 --- a/position.h +++ b/position.h @@ -57,10 +57,6 @@ class PositionFilter:public Filter /* Member Functions */ - static double gc_distance(double lat1, double lon1, double lat2, double lon2) - { - return radtometers(gcdist(RAD(lat1), RAD(lon1), RAD(lat2), RAD(lon2))); - } void position_runqueue(const WaypointList& waypt_list, int qtype); /* Data Members */ diff --git a/radius.cc b/radius.cc index 5552790d2..7e978970b 100644 --- a/radius.cc +++ b/radius.cc @@ -35,8 +35,8 @@ void RadiusFilter::process() { foreach (Waypoint* waypointp, *global_waypoint_list) { - double dist = gc_distance(waypointp->latitude, waypointp->longitude, - home_pos->latitude, home_pos->longitude); + double dist = radtomiles(gcdist(waypointp->position(), + home_pos->position())); if ((dist >= pos_dist) == (exclopt == nullptr)) { waypointp->wpt_flags.marked_for_deletion = 1; diff --git a/radius.h b/radius.h index 8bebd63f9..3e18953c9 100644 --- a/radius.h +++ b/radius.h @@ -51,11 +51,6 @@ class RadiusFilter:public Filter /* Member Functions */ - static double gc_distance(double lat1, double lon1, double lat2, double lon2) - { - return radtomiles(gcdist(RAD(lat1), RAD(lon1), RAD(lat2), RAD(lon2))); - } - /* Data Members */ double pos_dist{}; diff --git a/route.cc b/route.cc index c4c25f56e..34b728a47 100644 --- a/route.cc +++ b/route.cc @@ -278,16 +278,12 @@ computed_trkdata track_recompute(const route_head* trk) /* * gcdist and heading want radians, not degrees. */ - double tlat = RAD(thisw->latitude); - double tlon = RAD(thisw->longitude); - double plat = RAD(prev->latitude); - double plon = RAD(prev->longitude); if (!thisw->course_has_value()) { // Only recompute course if the waypoint // didn't already have a course. - thisw->set_course(heading_true_degrees(plat, plon, tlat, tlon)); + thisw->set_course(heading_true_degrees(prev->position(), thisw->position())); } - double dist = radtometers(gcdist(plat, plon, tlat, tlon)); + double dist = radtometers(gcdist(prev->position(), thisw->position())); tdata.distance_meters += dist; /* diff --git a/smplrout.cc b/smplrout.cc index 6a71295b3..eb5388126 100644 --- a/smplrout.cc +++ b/smplrout.cc @@ -97,18 +97,15 @@ double SimplifyRouteFilter::compute_track_error(const neighborhood& nb) const switch (metric) { case metric_t::crosstrack: track_error = radtomiles(linedist( - wpt1->latitude, wpt1->longitude, - wpt2->latitude, wpt2->longitude, - wpt3->latitude, wpt3->longitude)); + wpt1->position(), + wpt2->position(), + wpt3->position())); break; case metric_t::length: track_error = radtomiles( - gcdist(RAD(wpt1->latitude), RAD(wpt1->longitude), - RAD(wpt3->latitude), RAD(wpt3->longitude)) + - gcdist(RAD(wpt3->latitude), RAD(wpt3->longitude), - RAD(wpt2->latitude), RAD(wpt2->longitude)) - - gcdist(RAD(wpt1->latitude), RAD(wpt1->longitude), - RAD(wpt2->latitude), RAD(wpt2->longitude))); + gcdist(wpt1->position(), wpt3->position()) + + gcdist(wpt3->position(), wpt2->position()) - + gcdist(wpt1->position(), wpt2->position())); break; case metric_t::relative: default: // eliminate false positive warning with g++ 11.3.0: ‘error’ may be used uninitialized in this function [-Wmaybe-uninitialized] @@ -119,19 +116,15 @@ double SimplifyRouteFilter::compute_track_error(const neighborhood& nb) const (wpt1->GetCreationTime() != wpt2->GetCreationTime())) { double frac = static_cast(wpt1->GetCreationTime().msecsTo(wpt3->GetCreationTime())) / static_cast(wpt1->GetCreationTime().msecsTo(wpt2->GetCreationTime())); - double reslat; - double reslon; - linepart(wpt1->latitude, wpt1->longitude, - wpt2->latitude, wpt2->longitude, - frac, &reslat, &reslon); - track_error = radtometers(gcdist( - RAD(wpt3->latitude), RAD(wpt3->longitude), - RAD(reslat), RAD(reslon))); + auto respos = linepart(wpt1->position(), + wpt2->position(), + frac); + track_error = radtometers(gcdist(wpt3->position(), respos)); } else { // else distance to connecting line track_error = radtometers(linedist( - wpt1->latitude, wpt1->longitude, - wpt2->latitude, wpt2->longitude, - wpt3->latitude, wpt3->longitude)); + wpt1->position(), + wpt2->position(), + wpt3->position())); } // error relative to horizontal precision track_error /= (6 * wpt3->hdop); diff --git a/trackfilter.cc b/trackfilter.cc index bcb7b77d0..0d43a42b4 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -531,8 +531,7 @@ void TrackFilter::trackfilter_split() if (distance > 0) { double curdist = radtometers( - gcdist(RAD(prev_wpt->latitude), RAD(prev_wpt->longitude), - RAD(wpt->latitude), RAD(wpt->longitude))); + gcdist(prev_wpt->position(), wpt->position())); if (curdist <= distance) { new_track_flag = false; } else if constexpr(TRACKF_DBG) { @@ -600,10 +599,8 @@ void TrackFilter::trackfilter_move() void TrackFilter::trackfilter_synth() { - double last_course_lat; - double last_course_lon; - double last_speed_lat = std::nan(""); /* Quiet gcc 7.3.0 -Wmaybe-uninitialized */ - double last_speed_lon = std::nan(""); /* Quiet gcc 7.3.0 -Wmaybe-uninitialized */ + PositionDeg last_course_pos; + PositionDeg last_speed_pos; gpsbabel::DateTime last_speed_time; int nsats = 0; @@ -626,18 +623,14 @@ void TrackFilter::trackfilter_synth() wpt->reset_speed(); } first = false; - last_course_lat = wpt->latitude; - last_course_lon = wpt->longitude; - last_speed_lat = wpt->latitude; - last_speed_lon = wpt->longitude; + last_course_pos = wpt->position(); + last_speed_pos = wpt->position(); last_speed_time = wpt->GetCreationTime(); } else { if (opt_course) { - wpt->set_course(heading_true_degrees(RAD(last_course_lat), - RAD(last_course_lon),RAD(wpt->latitude), - RAD(wpt->longitude))); - last_course_lat = wpt->latitude; - last_course_lon = wpt->longitude; + wpt->set_course(heading_true_degrees(last_course_pos, + wpt->position())); + last_course_pos = wpt->position(); } if (opt_speed) { if (last_speed_time.msecsTo(wpt->GetCreationTime()) != 0) { @@ -649,14 +642,11 @@ void TrackFilter::trackfilter_synth() // Note that points with the same time can occur because the input // has truncated times, or because we are truncating times with // toTime_t(). - wpt->set_speed(radtometers(gcdist( - RAD(last_speed_lat), RAD(last_speed_lon), - RAD(wpt->latitude), - RAD(wpt->longitude))) / + wpt->set_speed(radtometers(gcdist(last_speed_pos, wpt->position())) + / (0.001 * std::abs(last_speed_time.msecsTo(wpt->GetCreationTime()))) ); - last_speed_lat = wpt->latitude; - last_speed_lon = wpt->longitude; + last_speed_pos = wpt->position(); last_speed_time = wpt->GetCreationTime(); } else { wpt->reset_speed(); @@ -888,10 +878,7 @@ void TrackFilter::trackfilter_faketime() bool TrackFilter::trackfilter_points_are_same(const Waypoint* wpta, const Waypoint* wptb) { return - radtometers(gcdist(RAD(wpta->latitude), - RAD(wpta->longitude), - RAD(wptb->latitude), - RAD(wptb->longitude))) < kDistanceLimit && + radtometers(gcdist(wpta->position(), wptb->position())) < kDistanceLimit && std::abs(wpta->altitude - wptb->altitude) < 20 && wpta->courses_equal(*wptb) && wpta->speeds_equal(*wptb) && @@ -909,10 +896,8 @@ void TrackFilter::trackfilter_segment_head(const route_head* rte) for (auto it = wptlist.cbegin(); it != wptlist.cend(); ++it) { auto* wpt = *it; if (it != wptlist.cbegin()) { - double cur_dist = radtometers(gcdist(RAD(prev_wpt->latitude), - RAD(prev_wpt->longitude), - RAD(wpt->latitude), - RAD(wpt->longitude))); + double cur_dist = radtometers(gcdist(prev_wpt->position(), + wpt->position())); // Denoise points that are on top of each other, // keeping the first and last of the group. diff --git a/waypt.cc b/waypt.cc index e7c8c1898..b26455511 100644 --- a/waypt.cc +++ b/waypt.cc @@ -200,11 +200,12 @@ waypt_add_url(Waypoint* wpt, const QString& link, const QString& url_link_text, wpt->AddUrlLink(UrlLink(link, url_link_text, url_link_type)); } +// TODO: change inputs to PositionDeg? double gcgeodist(const double lat1, const double lon1, const double lat2, const double lon2) { - return radtometers(gcdist(RAD(lat1), RAD(lon1), RAD(lat2), RAD(lon2))); + return radtometers(gcdist(PositionDeg(lat1, lon1), PositionDeg(lat2, lon2))); } /* @@ -355,7 +356,7 @@ double waypt_course(const Waypoint* A, const Waypoint* B) { if (A && B) { - return heading_true_degrees(RAD(A->latitude), RAD(A->longitude), RAD(B->latitude), RAD(B->longitude)); + return heading_true_degrees(A->position(), B->position()); } else { return 0; } diff --git a/xcsv.cc b/xcsv.cc index c64d9c4d8..afc3cf373 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -963,8 +963,7 @@ void XcsvFormat::xcsv_resetpathlen(const route_head* head) { pathdist = 0; - oldlat = 999; - oldlon = 999; + old_position.reset(); csv_route = csv_track = nullptr; switch (xcsv_style->datatype) { case trkdata: @@ -993,12 +992,13 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) double utmn; char utmzc; - if (oldlon < 900) { - pathdist += radtometers(gcdist(RAD(oldlat),RAD(oldlon), - RAD(wpt->latitude),RAD(wpt->longitude))); + if (old_position) { + pathdist += radtometers(gcdist(old_position.value(), + wpt->position())); } - longitude = oldlon = wpt->longitude; - latitude = oldlat = wpt->latitude; + old_position = wpt->position(); + latitude = wpt->latitude; + longitude = wpt->longitude; QString write_delimiter; if (xcsv_style->field_delimiter == u"\\w") { diff --git a/xcsv.h b/xcsv.h index 838c60c07..b7d4467f8 100644 --- a/xcsv.h +++ b/xcsv.h @@ -366,8 +366,7 @@ class XcsvFormat : public Format XcsvFile* xcsv_file{nullptr}; const XcsvStyle* xcsv_style{nullptr}; double pathdist = 0; - double oldlon = 999; - double oldlat = 999; + std::optional old_position; int waypt_out_count = 0; const route_head* csv_track = nullptr; From 824e01d71ee0f047ed9e6386e4c3185b1866e175 Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Thu, 15 Aug 2024 00:51:56 -0500 Subject: [PATCH 112/132] Modernize Humminbird internals (#1322) * Modernize Humminbirds internals --------- Co-authored-by: Robert Lipe --- .gitignore | 1 + humminbird.cc | 72 +++++++++++++++++++++------------------------------ 2 files changed, 30 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index d0e84069e..eb7338ca2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /*.gcda /*.gcno /*.gcov +/.cmake/ /.vs/ /.vscode/ /GPSBabel diff --git a/humminbird.cc b/humminbird.cc index d4a597b26..3d66cc058 100644 --- a/humminbird.cc +++ b/humminbird.cc @@ -30,7 +30,7 @@ #include // for strncpy, memcpy, memset #include // for inv_pi, pi -#include "defs.h" // for Waypoint, be_read32, be_read16, be_write32, fatal, xfree, be_write16, route_head, xcalloc, track_add_wpt, xstrndup +#include "defs.h" // for Waypoint, be_read32, be_read16, be_write32, fatal, be_write16, route_head, track_add_wpt #include "mkshort.h" // for MakeShort #include "src/core/datetime.h" // for DateTime @@ -229,7 +229,7 @@ HumminbirdBase::humminbird_rd_deinit() const void HumminbirdBase::humminbird_read_wpt(gbfile* fin) { - humminbird_waypt_t w; + humminbird_waypt_t w{0}; if (! gbfread(&w, 1, sizeof(w), fin)) { fatal(MYNAME ": Unexpected end of file!\n"); @@ -247,24 +247,20 @@ HumminbirdBase::humminbird_read_wpt(gbfile* fin) auto* wpt = new Waypoint; - // Could probably find a way to eliminate the alloc/copy. - char* s = xstrndup(w.name, sizeof(w.name)); - wpt->shortname = s; - xfree(s); - + wpt->shortname = QByteArray(w.name, static_cast(qstrnlen(w.name, sizeof(w.name)))); wpt->SetCreationTime(w.time); double guder = gudermannian_i1924(w.north); wpt->latitude = geocentric_to_geodetic_hwr(guder); - wpt->longitude = (double)w.east / EAST_SCALE * 180.0; + wpt->longitude = static_cast(w.east) / EAST_SCALE * 180.0; wpt->altitude = 0.0; /* It's from a fishfinder... */ if (w.depth != 0) { - wpt->set_depth((double)w.depth / 100.0); + wpt->set_depth(static_cast(w.depth) / 100.0); } - int num_icons = sizeof(humminbird_icons) / sizeof(humminbird_icons[0]); + int num_icons = std::size(humminbird_icons); if (w.icon < num_icons) { wpt->icon_descr = humminbird_icons[w.icon]; } @@ -297,7 +293,7 @@ void HumminbirdBase::humminbird_read_route(gbfile* fin) const { - humminbird_rte_t hrte; + humminbird_rte_t hrte{0}; if (! gbfread(&hrte, 1, sizeof(hrte), fin)) { fatal(MYNAME ": Unexpected end of file!\n"); @@ -320,11 +316,7 @@ HumminbirdBase::humminbird_read_route(gbfile* fin) const if (rte == nullptr) { rte = new route_head; route_add_head(rte); - // TODO: find a way to eliminate the copy. - char* s = xstrndup(hrte.name, sizeof(hrte.name)); - rte->rte_name = s; - xfree(s); - /* rte->rte_num = hrte.num + 1; only internal number */ + rte->rte_name = QByteArray(hrte.name, static_cast(qstrnlen(hrte.name, sizeof(hrte.name)))); } route_add_wpt(rte, new Waypoint(*wpt)); } @@ -336,7 +328,7 @@ void HumminbirdBase::humminbird_read_track(gbfile* fin) { - humminbird_trk_header_t th; + humminbird_trk_header_t th{0}; if (! gbfread(&th, 1, sizeof(th), fin)) { fatal(MYNAME ": Unexpected end of file reading header!\n"); @@ -369,7 +361,7 @@ HumminbirdBase::humminbird_read_track(gbfile* fin) /* num_points is actually one too big, because it includes the value in the header. But we want the extra point at the end because the freak-value filter below looks at points[i+1] */ - auto* points = (humminbird_trk_point_t*) xcalloc(th.num_points, sizeof(humminbird_trk_point_t)); + auto* points = new humminbird_trk_point_t[th.num_points](); if (! gbfread(points, sizeof(humminbird_trk_point_t), th.num_points-1, fin)) { fatal(MYNAME ": Unexpected end of file reading points!\n"); } @@ -380,10 +372,7 @@ HumminbirdBase::humminbird_read_track(gbfile* fin) auto* trk = new route_head; track_add_head(trk); - // TODO: find a way to eliminate the copy. - char* s = xstrndup(th.name, sizeof(th.name)); - trk->rte_name = s; - xfree(s); + trk->rte_name = QByteArray(th.name, static_cast(qstrnlen(th.name, sizeof(th.name)))); trk->rte_num = th.trk_num; /* We create one wpt for the info in the header */ @@ -396,7 +385,7 @@ HumminbirdBase::humminbird_read_track(gbfile* fin) /* No depth info in the header. */ track_add_wpt(trk, first_wpt); - for (int i = 0 ; ialtitude = 0.0; if (points[i].depth != 0) { - wpt->set_depth((double)points[i].depth / 100.0); + wpt->set_depth(static_cast(points[i].depth) / 100.0); } if (i == th.num_points-2 && th.time != 0) { @@ -440,14 +429,14 @@ HumminbirdBase::humminbird_read_track(gbfile* fin) } track_add_wpt(trk, wpt); } - xfree(points); + delete[] points; } void HumminbirdBase::humminbird_read_track_old(gbfile* fin) { - humminbird_trk_header_old_t th; + humminbird_trk_header_old_t th{0}; constexpr int file_len = 8048; char namebuf[TRK_NAME_LEN]; @@ -476,7 +465,7 @@ HumminbirdBase::humminbird_read_track_old(gbfile* fin) /* num_points is actually one too big, because it includes the value in the header. But we want the extra point at the end because the freak-value filter below looks at points[i+1] */ - auto* points = (humminbird_trk_point_old_t*)xcalloc(th.num_points, sizeof(humminbird_trk_point_old_t)); + auto* points = new humminbird_trk_point_old_t[th.num_points](); if (! gbfread(points, sizeof(humminbird_trk_point_old_t), th.num_points-1, fin)) { fatal(MYNAME ": Unexpected end of file reading points!\n"); } @@ -492,8 +481,8 @@ HumminbirdBase::humminbird_read_track_old(gbfile* fin) gbfseek(fin, file_len-TRK_NAME_LEN, SEEK_SET); gbfread(&namebuf, 1, TRK_NAME_LEN, fin); - trk->rte_name = xstrndup(namebuf, sizeof(namebuf)); + trk->rte_name = QByteArray(namebuf, static_cast(qstrnlen(namebuf, sizeof(namebuf)))); trk->rte_num = th.trk_num; /* We create one wpt for the info in the header */ @@ -547,16 +536,14 @@ HumminbirdBase::humminbird_read_track_old(gbfile* fin) } track_add_wpt(trk, wpt); } - xfree(points); + delete[] points; } void HumminbirdBase::humminbird_read() { while (! gbfeof(fin_)) { - uint32_t signature = gbfgetuint32(fin_); - - switch (signature) { + switch (uint32_t signature = gbfgetuint32(fin_)) { case WPT_MAGIC: case WPT_MAGIC2: humminbird_read_wpt(fin_); @@ -631,8 +618,8 @@ HumminbirdBase::humminbird_wr_deinit() void HumminbirdFormat::humminbird_write_waypoint(const Waypoint* wpt) { - humminbird_waypt_t hum; - int num_icons = sizeof(humminbird_icons) / sizeof(humminbird_icons[0]); + humminbird_waypt_t hum{0}; + int num_icons = std::size(humminbird_icons); be_write16(&hum.num, waypoint_num++); hum.zero = 0; @@ -688,9 +675,8 @@ HumminbirdHTFormat::humminbird_track_head(const route_head* trk) trk_head = nullptr; last_time = 0; if (!trk->rte_waypt_empty()) { - trk_head = (humminbird_trk_header_t*) xcalloc(1, sizeof(humminbird_trk_header_t)); - trk_points = (humminbird_trk_point_t*) xcalloc(max_points, sizeof(humminbird_trk_point_t)); - + trk_head = new humminbird_trk_header_t(); + trk_points = new humminbird_trk_point_t[max_points](); QString name = trkname_sh->mkshort(trk->rte_name); strncpy(trk_head->name, CSTR(name), sizeof(trk_head->name)-1); be_write16(&trk_head->trk_num, trk->rte_num); @@ -727,8 +713,8 @@ HumminbirdHTFormat::humminbird_track_tail(const route_head* /*unused*/) gbfwrite(trk_points, max_points, sizeof(humminbird_trk_point_t), fout_); gbfputuint16(0, fout_); /* Odd but true. The format doesn't fit an int nr of entries. */ - xfree(trk_head); - xfree(trk_points); + delete trk_head; + delete[] trk_points; trk_head = nullptr; trk_points = nullptr; @@ -768,8 +754,8 @@ HumminbirdHTFormat::humminbird_track_cb(const Waypoint* wpt) } else { /* These points are 16-bit differential. */ int j = i-1; - trk_points[j].deltaeast = east - last_east; - trk_points[j].deltanorth = north - last_north; + trk_points[j].deltaeast = static_cast(east - last_east); + trk_points[j].deltanorth = static_cast(north - last_north); trk_points[j].depth = qRound(wpt->depth_value_or(0) * 100.0); /* BE-ify */ @@ -819,7 +805,7 @@ HumminbirdFormat::humminbird_rte_head(const route_head* rte) { humrte = nullptr; if (!rte->rte_waypt_empty()) { - humrte = (humminbird_rte_t*) xcalloc(1, sizeof(*humrte)); + humrte = new humminbird_rte_t; } } @@ -847,7 +833,7 @@ HumminbirdFormat::humminbird_rte_tail(const route_head* rte) gbfwrite(humrte, sizeof(*humrte), 1, fout_); } - xfree(humrte); + delete humrte; humrte = nullptr; } From e9b2084bc9338fe8b4ad709580cfc84dee283b2b Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 15 Aug 2024 05:50:46 -0600 Subject: [PATCH 113/132] update shapelib to 1.6.1 (#1323) --- shapelib.cmake | 9 +- shapelib/LICENSE-MIT | 3 +- shapelib/README.GPSBabel | 2 +- shapelib/dbf_api.html | 29 +- shapelib/dbfopen.c | 167 ++++++--- shapelib/safileio.c | 8 +- shapelib/shapefil.h | 83 +++-- shapelib/shapefil_private.h | 117 +++++++ shapelib/shp_api.html | 19 +- shapelib/shpopen.c | 676 ++++++++++++++++++------------------ 10 files changed, 651 insertions(+), 462 deletions(-) create mode 100644 shapelib/shapefil_private.h diff --git a/shapelib.cmake b/shapelib.cmake index d52f28e3c..7cd4b7b25 100644 --- a/shapelib.cmake +++ b/shapelib.cmake @@ -15,14 +15,19 @@ else() shapelib/safileio.c shapelib/shpopen.c shapelib/shapefil.h + shapelib/shapefil_private.h ) # note gpsbabel has conditional code include "shapelib/shapefil.h", # so it doesn't actually rely on the include directory being PUBLIC/INTERFACE target_include_directories(shp PUBLIC shape) + include(TestBigEndian) + if(HAVE_BYTE_ORDER_BIG_ENDIAN) + # Define SHP_BIG_ENDIAN if the system is big-endian + target_compile_definitions(shp PRIVATE SHP_BIG_ENDIAN=1) + endif() if(MSVC) target_compile_definitions(shp PRIVATE _CRT_SECURE_NO_WARNINGS) - target_compile_definitions(shp PRIVATE _CRT_NONSTDC_NO_WARNINGS) - target_compile_options(shp PRIVATE /MP -wd4100 -wd4267) + target_compile_options(shp PRIVATE -wd4100) endif() list(APPEND LIBS shp) elseif(GPSBABEL_WITH_SHAPELIB STREQUAL "custom") diff --git a/shapelib/LICENSE-MIT b/shapelib/LICENSE-MIT index 34fb3422c..159e87a02 100644 --- a/shapelib/LICENSE-MIT +++ b/shapelib/LICENSE-MIT @@ -1,6 +1,7 @@ MIT License -Copyright (c) 1999, Frank Warmerdam +Copyright (c) 2011-2024, Even Rouault +Copyright (c) 1999-2013, Frank Warmerdam Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/shapelib/README.GPSBabel b/shapelib/README.GPSBabel index f5bba78a8..03b89e225 100644 --- a/shapelib/README.GPSBabel +++ b/shapelib/README.GPSBabel @@ -1,4 +1,4 @@ -This is a subset of Shapelib v1.6.0 from http://shapelib.maptools.org/ +This is a subset of Shapelib v1.6.1 from http://shapelib.maptools.org/ The source is unmodified. It's subsetted here only to reduce the amount of size in our tree that it takes and to reduce ongoing diff --git a/shapelib/dbf_api.html b/shapelib/dbf_api.html index cdd29a22f..ed0216614 100644 --- a/shapelib/dbf_api.html +++ b/shapelib/dbf_api.html @@ -54,7 +54,7 @@

    DBFCreate()

    DBFGetFieldCount()

    -int DBFGetFieldCount( DBFHandle hDBF );
    +int DBFGetFieldCount( const DBFHandle hDBF );
     
       hDBF:		The access handle for the file to be queried, as returned
                     by DBFOpen(), or DBFCreate().
    @@ -68,7 +68,7 @@ 

    DBFGetFieldCount()

    DBFGetRecordCount()

    -int DBFGetRecordCount( DBFHandle hDBF );
    +int DBFGetRecordCount( const DBFHandle hDBF );
     
       hDBF:		The access handle for the file to be queried, as returned by
     		DBFOpen(), or DBFCreate().
    @@ -83,7 +83,7 @@ 

    DBFGetRecordCount()

    DBFGetFieldIndex()

    -int DBFGetFieldIndex( DBFHandle hDBF, const char *pszFieldName );
    +int DBFGetFieldIndex( const DBFHandle hDBF, const char *pszFieldName );
     
       hDBF:		The access handle for the file to be queried, as returned by
     		DBFOpen(), or DBFCreate().
    @@ -99,7 +99,8 @@ 

    DBFGetFieldIndex()

    DBFGetFieldInfo()

    -DBFFieldType DBFGetFieldInfo( DBFHandle hDBF, int iField, char * pszFieldName,
    +DBFFieldType DBFGetFieldInfo( const  DBFHandle hDBF, int iField,
    +                              char * pszFieldName,
                                   int * pnWidth, int * pnDecimals );
     
       hDBF:		The access handle for the file to be queried, as returned by
    @@ -127,16 +128,16 @@ 

    DBFGetFieldInfo()

    The DBFGetFieldInfo() returns the type of the requested field, which is one of the DBFFieldType enumerated values. As well, the field name, and field width information can optionally be returned. The field type returned - does not correspond one to one with the xBase field types. For instance - the xBase field type for Date will just be returned as being FTInteger.

    + does not correspond one to one with the xBase field types.

         typedef enum {
    -      FTString,			/* fixed length string field 		*/
    -      FTInteger,		/* numeric field with no decimals 	*/
    -      FTDouble,			/* numeric field with decimals 		*/
    -      FTLogical,		/* logical field.                       */
    -      FTInvalid                 /* not a recognised field type 		*/
    +      FTString,			/* fixed length string field        */
    +      FTInteger,		/* numeric field with no decimals   */
    +      FTDouble,			/* numeric field with decimals      */
    +      FTLogical,		/* logical field                    */
    +      FTDate,			/* date field                       */
    +      FTInvalid			/* not a recognised field type      */
         } DBFFieldType;
     
    @@ -251,7 +252,7 @@

    DBFReadStringAttribute()

    DBFIsAttributeNULL()

    -int DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
    +int DBFIsAttributeNULL( const DBFHandle hDBF, int iShape, int iField );
     
       hDBF:		The access handle for the file to be queried, as returned by
     		DBFOpen(), or DBFCreate().
    @@ -382,7 +383,7 @@ 

    DBFClose()

    DBFIsRecordDeleted()

    -int DBFIsRecordDeleted( DBFHandle hDBF, int iShape );
    +int DBFIsRecordDeleted( const DBFHandle hDBF, int iShape );
     
       hDBF:		The access handle for the file to be checked.
       iShape:       The record index to check.
    @@ -410,7 +411,7 @@ 

    DBFMarkRecordDeleted()

    DBFGetNativeFieldType()

    -char DBFGetNativeFieldType( DBFHandle hDBF, int iField );
    +char DBFGetNativeFieldType( const DBFHandle hDBF, int iField );
     
       hDBF:		The access handle for the file.
       iField:       The field index to query.
    diff --git a/shapelib/dbfopen.c b/shapelib/dbfopen.c
    index ee5be97f0..90ed7ea8e 100644
    --- a/shapelib/dbfopen.c
    +++ b/shapelib/dbfopen.c
    @@ -6,12 +6,12 @@
      *
      ******************************************************************************
      * Copyright (c) 1999, Frank Warmerdam
    - * Copyright (c) 2012-2019, Even Rouault 
    + * Copyright (c) 2012-2024, Even Rouault 
      *
      * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
      ******************************************************************************/
     
    -#include "shapefil.h"
    +#include "shapefil_private.h"
     
     #include 
     #include 
    @@ -26,7 +26,7 @@
     
     #if defined(_MSC_VER)
     #define STRCASECMP(a, b) (_stricmp(a, b))
    -#elif defined(WIN32) || defined(_WIN32)
    +#elif defined(_WIN32)
     #define STRCASECMP(a, b) (stricmp(a, b))
     #else
     #include 
    @@ -37,7 +37,7 @@
     #if _MSC_VER < 1900
     #define snprintf _snprintf
     #endif
    -#elif defined(WIN32) || defined(_WIN32)
    +#elif defined(_WIN32)
     #ifndef snprintf
     #define snprintf _snprintf
     #endif
    @@ -68,18 +68,6 @@ CPL_INLINE static void CPL_IGNORE_RET_VAL_INT(CPL_UNUSED int unused)
     #define CPL_IGNORE_RET_VAL_INT(x) x
     #endif
     
    -#ifdef __cplusplus
    -#define STATIC_CAST(type, x) static_cast(x)
    -#define REINTERPRET_CAST(type, x) reinterpret_cast(x)
    -#define CONST_CAST(type, x) const_cast(x)
    -#define SHPLIB_NULLPTR nullptr
    -#else
    -#define STATIC_CAST(type, x) ((type)(x))
    -#define REINTERPRET_CAST(type, x) ((type)(x))
    -#define CONST_CAST(type, x) ((type)(x))
    -#define SHPLIB_NULLPTR NULL
    -#endif
    -
     /************************************************************************/
     /*                           DBFWriteHeader()                           */
     /*                                                                      */
    @@ -310,7 +298,6 @@ void SHPAPI_CALL DBFSetLastModifiedDate(DBFHandle psDBF, int nYYSince1900,
     /************************************************************************/
     
     DBFHandle SHPAPI_CALL DBFOpen(const char *pszFilename, const char *pszAccess)
    -
     {
         SAHooks sHooks;
     
    @@ -494,7 +481,7 @@ DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess,
     
         for (int iField = 0; iField < nFields; iField++)
         {
    -        unsigned char *pabyFInfo = pabyBuf + iField * XBASE_FLDHDR_SZ;
    +        const unsigned char *pabyFInfo = pabyBuf + iField * XBASE_FLDHDR_SZ;
             if (pabyFInfo[0] == HEADER_RECORD_TERMINATOR)
             {
                 psDBF->nFields = iField;
    @@ -1077,7 +1064,6 @@ double SHPAPI_CALL DBFReadDoubleAttribute(DBFHandle psDBF, int iRecord,
     
     const char SHPAPI_CALL1(*)
         DBFReadStringAttribute(DBFHandle psDBF, int iRecord, int iField)
    -
     {
         return STATIC_CAST(const char *,
                            DBFReadAttribute(psDBF, iRecord, iField, 'C'));
    @@ -1091,19 +1077,49 @@ const char SHPAPI_CALL1(*)
     
     const char SHPAPI_CALL1(*)
         DBFReadLogicalAttribute(DBFHandle psDBF, int iRecord, int iField)
    -
     {
         return STATIC_CAST(const char *,
                            DBFReadAttribute(psDBF, iRecord, iField, 'L'));
     }
     
    +/************************************************************************/
    +/*                        DBFReadDateAttribute()                        */
    +/*                                                                      */
    +/*      Read a date attribute.                                          */
    +/************************************************************************/
    +
    +SHPDate SHPAPI_CALL DBFReadDateAttribute(DBFHandle psDBF, int iRecord,
    +                                         int iField)
    +{
    +    const char *pdateValue = STATIC_CAST(
    +        const char *, DBFReadAttribute(psDBF, iRecord, iField, 'D'));
    +
    +    SHPDate date;
    +
    +    if (pdateValue == SHPLIB_NULLPTR)
    +    {
    +        date.year = 0;
    +        date.month = 0;
    +        date.day = 0;
    +    }
    +    else if (3 != sscanf(pdateValue, "%4d%2d%2d", &date.year, &date.month,
    +                         &date.day))
    +    {
    +        date.year = 0;
    +        date.month = 0;
    +        date.day = 0;
    +    }
    +
    +    return date;
    +}
    +
     /************************************************************************/
     /*                         DBFIsValueNULL()                             */
     /*                                                                      */
     /*      Return TRUE if the passed string is NULL.                       */
     /************************************************************************/
     
    -static bool DBFIsValueNULL(char chType, const char *pszValue)
    +static bool DBFIsValueNULL(char chType, const char *pszValue, int size)
     {
         if (pszValue == SHPLIB_NULLPTR)
             return true;
    @@ -1128,13 +1144,22 @@ static bool DBFIsValueNULL(char chType, const char *pszValue)
                 return true;
     
             case 'D':
    -            /* NULL date fields have value "00000000" */
    +        {
    +            const char DIGIT_ZERO = '0';
    +            /* NULL date fields have value "00000000" or "0"*size */
                 /* Some DBF files have fields filled with spaces */
                 /* (trimmed by DBFReadStringAttribute) to indicate null */
                 /* values for dates (#4265). */
                 /* And others have '       0': https://lists.osgeo.org/pipermail/gdal-dev/2023-November/058010.html */
    -            return strncmp(pszValue, "00000000", 8) == 0 ||
    -                   strcmp(pszValue, " ") == 0 || strcmp(pszValue, "0") == 0;
    +            /* And others just empty string: https://github.com/OSGeo/gdal/issues/10405 */
    +            if (pszValue[0] == 0 || strncmp(pszValue, "00000000", 8) == 0 ||
    +                strcmp(pszValue, " ") == 0 || strcmp(pszValue, "0") == 0)
    +                return true;
    +            for (int i = 0; i < size; i++)
    +                if (pszValue[i] != DIGIT_ZERO)
    +                    return false;
    +            return true;
    +        }
     
             case 'L':
                 /* NULL boolean fields have value "?" */
    @@ -1154,14 +1179,16 @@ static bool DBFIsValueNULL(char chType, const char *pszValue)
     /*      Contributed by Jim Matthews.                                    */
     /************************************************************************/
     
    -int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle psDBF, int iRecord, int iField)
    +int SHPAPI_CALL DBFIsAttributeNULL(const DBFHandle psDBF, int iRecord,
    +                                   int iField)
     {
         const char *pszValue = DBFReadStringAttribute(psDBF, iRecord, iField);
     
         if (pszValue == SHPLIB_NULLPTR)
             return TRUE;
     
    -    return DBFIsValueNULL(psDBF->pachFieldType[iField], pszValue);
    +    return DBFIsValueNULL(psDBF->pachFieldType[iField], pszValue,
    +                          psDBF->panFieldSize[iField]);
     }
     
     /************************************************************************/
    @@ -1170,8 +1197,7 @@ int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle psDBF, int iRecord, int iField)
     /*      Return the number of fields in this table.                      */
     /************************************************************************/
     
    -int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF)
    -
    +int SHPAPI_CALL DBFGetFieldCount(const DBFHandle psDBF)
     {
         return (psDBF->nFields);
     }
    @@ -1182,8 +1208,7 @@ int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF)
     /*      Return the number of records in this table.                     */
     /************************************************************************/
     
    -int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF)
    -
    +int SHPAPI_CALL DBFGetRecordCount(const DBFHandle psDBF)
     {
         return (psDBF->nRecords);
     }
    @@ -1196,10 +1221,9 @@ int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF)
     /*      bytes long.                                                     */
     /************************************************************************/
     
    -DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField,
    +DBFFieldType SHPAPI_CALL DBFGetFieldInfo(const DBFHandle psDBF, int iField,
                                              char *pszFieldName, int *pnWidth,
                                              int *pnDecimals)
    -
     {
         if (iField < 0 || iField >= psDBF->nFields)
             return (FTInvalid);
    @@ -1341,8 +1365,14 @@ static bool DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField,
                 if (psDBF->panFieldSize[iField] >= 1 &&
                     (*STATIC_CAST(char *, pValue) == 'F' ||
                      *STATIC_CAST(char *, pValue) == 'T'))
    +            {
                     *(pabyRec + psDBF->panFieldOffset[iField]) =
                         *STATIC_CAST(char *, pValue);
    +            }
    +            else
    +            {
    +                nRetResult = false;
    +            }
                 break;
     
             default:
    @@ -1422,17 +1452,17 @@ int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity,
             /*      Assign all the record fields.                                   */
             /* -------------------------------------------------------------------- */
             int j;
    -        if (STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))) >
    +        if (STATIC_CAST(int, strlen(STATIC_CAST(const char *, pValue))) >
                 psDBF->panFieldSize[iField])
                 j = psDBF->panFieldSize[iField];
             else
             {
                 memset(pabyRec + psDBF->panFieldOffset[iField], ' ',
                        psDBF->panFieldSize[iField]);
    -            j = STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue)));
    +            j = STATIC_CAST(int, strlen(STATIC_CAST(const char *, pValue)));
             }
     
    -        strncpy(
    +        memcpy(
                 REINTERPRET_CAST(char *, pabyRec + psDBF->panFieldOffset[iField]),
                 STATIC_CAST(const char *, pValue), j);
         }
    @@ -1459,7 +1489,7 @@ int SHPAPI_CALL DBFWriteDoubleAttribute(DBFHandle psDBF, int iRecord,
     /************************************************************************/
     /*                      DBFWriteIntegerAttribute()                      */
     /*                                                                      */
    -/*      Write a integer attribute.                                      */
    +/*      Write an integer attribute.                                     */
     /************************************************************************/
     
     int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle psDBF, int iRecord,
    @@ -1479,7 +1509,6 @@ int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle psDBF, int iRecord,
     
     int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle psDBF, int iRecord,
                                             int iField, const char *pszValue)
    -
     {
         return (
             DBFWriteAttribute(psDBF, iRecord, iField,
    @@ -1489,11 +1518,10 @@ int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle psDBF, int iRecord,
     /************************************************************************/
     /*                      DBFWriteNULLAttribute()                         */
     /*                                                                      */
    -/*      Write a string attribute.                                       */
    +/*      Write a NULL attribute.                                         */
     /************************************************************************/
     
     int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle psDBF, int iRecord, int iField)
    -
     {
         return (DBFWriteAttribute(psDBF, iRecord, iField, SHPLIB_NULLPTR));
     }
    @@ -1506,13 +1534,36 @@ int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle psDBF, int iRecord, int iField)
     
     int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle psDBF, int iRecord,
                                              int iField, const char lValue)
    -
     {
         return (
             DBFWriteAttribute(psDBF, iRecord, iField,
                               STATIC_CAST(void *, CONST_CAST(char *, &lValue))));
     }
     
    +/************************************************************************/
    +/*                      DBFWriteDateAttribute()                         */
    +/*                                                                      */
    +/*      Write a date attribute.                                         */
    +/************************************************************************/
    +
    +int SHPAPI_CALL DBFWriteDateAttribute(DBFHandle psDBF, int iRecord, int iField,
    +                                      const SHPDate *lValue)
    +{
    +    if (SHPLIB_NULLPTR == lValue)
    +        return false;
    +    /* check for supported digit range, but do not check for valid date */
    +    if (lValue->year < 0 || lValue->year > 9999)
    +        return false;
    +    if (lValue->month < 0 || lValue->month > 99)
    +        return false;
    +    if (lValue->day < 0 || lValue->day > 99)
    +        return false;
    +    char dateValue[9]; /* "yyyyMMdd\0" */
    +    snprintf(dateValue, sizeof(dateValue), "%04d%02d%02d", lValue->year,
    +             lValue->month, lValue->day);
    +    return (DBFWriteAttributeDirectly(psDBF, iRecord, iField, dateValue));
    +}
    +
     /************************************************************************/
     /*                         DBFWriteTuple()                              */
     /*                                                                      */
    @@ -1572,7 +1623,6 @@ int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity,
     /************************************************************************/
     
     const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity)
    -
     {
         if (hEntity < 0 || hEntity >= psDBF->nRecords)
             return SHPLIB_NULLPTR;
    @@ -1586,12 +1636,15 @@ const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity)
     /************************************************************************/
     /*                          DBFCloneEmpty()                             */
     /*                                                                      */
    -/*      Read one of the attribute fields of a record.                   */
    +/*      Create a new .dbf file with same code page and field            */
    +/*      definitions as the given handle.                                */
     /************************************************************************/
     
    -DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename)
    +DBFHandle SHPAPI_CALL DBFCloneEmpty(const DBFHandle psDBF,
    +                                    const char *pszFilename)
     {
    -    DBFHandle newDBF = DBFCreateEx(pszFilename, psDBF->pszCodePage);
    +    DBFHandle newDBF =
    +        DBFCreateLL(pszFilename, psDBF->pszCodePage, &psDBF->sHooks);
         if (newDBF == SHPLIB_NULLPTR)
             return SHPLIB_NULLPTR;
     
    @@ -1648,8 +1701,7 @@ DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename)
     /*                           'M' (Memo: 10 digits .DBT block ptr)       */
     /************************************************************************/
     
    -char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle psDBF, int iField)
    -
    +char SHPAPI_CALL DBFGetNativeFieldType(const DBFHandle psDBF, int iField)
     {
         if (iField >= 0 && iField < psDBF->nFields)
             return psDBF->pachFieldType[iField];
    @@ -1665,7 +1717,8 @@ char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle psDBF, int iField)
     /*      Contributed by Jim Matthews.                                    */
     /************************************************************************/
     
    -int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName)
    +int SHPAPI_CALL DBFGetFieldIndex(const DBFHandle psDBF,
    +                                 const char *pszFieldName)
     {
         char name[XBASE_FLDNAME_LEN_READ + 1];
     
    @@ -1685,7 +1738,7 @@ int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName)
     /*      it returns FALSE.                                               */
     /************************************************************************/
     
    -int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape)
    +int SHPAPI_CALL DBFIsRecordDeleted(const DBFHandle psDBF, int iShape)
     {
         /* -------------------------------------------------------------------- */
         /*      Verify selection.                                               */
    @@ -1748,7 +1801,7 @@ int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape,
     /*                            DBFGetCodePage                            */
     /************************************************************************/
     
    -const char SHPAPI_CALL1(*) DBFGetCodePage(DBFHandle psDBF)
    +const char SHPAPI_CALL1(*) DBFGetCodePage(const DBFHandle psDBF)
     {
         if (psDBF == SHPLIB_NULLPTR)
             return SHPLIB_NULLPTR;
    @@ -1901,13 +1954,13 @@ int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, const int *panMap)
         /* a simple malloc() would be enough, but calloc() helps clang static
          * analyzer */
         int *panFieldOffsetNew =
    -        STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields));
    +        STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int)));
         int *panFieldSizeNew =
    -        STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields));
    +        STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int)));
         int *panFieldDecimalsNew =
    -        STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields));
    +        STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int)));
         char *pachFieldTypeNew =
    -        STATIC_CAST(char *, calloc(sizeof(char), psDBF->nFields));
    +        STATIC_CAST(char *, calloc(psDBF->nFields, sizeof(char)));
         char *pszHeaderNew = STATIC_CAST(
             char *, malloc(sizeof(char) * XBASE_FLDHDR_SZ * psDBF->nFields));
     
    @@ -2103,7 +2156,6 @@ int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField,
             char *pszOldField =
                 STATIC_CAST(char *, malloc(sizeof(char) * (nOldWidth + 1)));
     
    -        /* cppcheck-suppress uninitdata */
             pszOldField[nOldWidth] = 0;
     
             /* move records to their new positions */
    @@ -2123,7 +2175,8 @@ int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField,
                 }
     
                 memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
    -            const bool bIsNULL = DBFIsValueNULL(chOldType, pszOldField);
    +            const bool bIsNULL =
    +                DBFIsValueNULL(chOldType, pszOldField, nOldWidth);
     
                 if (nWidth != nOldWidth)
                 {
    @@ -2181,7 +2234,6 @@ int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField,
             char *pszOldField =
                 STATIC_CAST(char *, malloc(sizeof(char) * (nOldWidth + 1)));
     
    -        /* cppcheck-suppress uninitdata */
             pszOldField[nOldWidth] = 0;
     
             /* move records to their new positions */
    @@ -2201,7 +2253,8 @@ int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField,
                 }
     
                 memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
    -            const bool bIsNULL = DBFIsValueNULL(chOldType, pszOldField);
    +            const bool bIsNULL =
    +                DBFIsValueNULL(chOldType, pszOldField, nOldWidth);
     
                 if (nOffset + nOldWidth < nOldRecordLength)
                 {
    diff --git a/shapelib/safileio.c b/shapelib/safileio.c
    index b63a3933a..2799f8112 100644
    --- a/shapelib/safileio.c
    +++ b/shapelib/safileio.c
    @@ -6,6 +6,7 @@
      *
      ******************************************************************************
      * Copyright (c) 2007, Frank Warmerdam
    + * Copyright (c) 2016-2024, Even Rouault 
      *
      * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
      ******************************************************************************
    @@ -132,8 +133,10 @@ static wchar_t *Utf8ToWideChar(const char *pszFilename)
     /*                           SAUtf8WFOpen                               */
     /************************************************************************/
     
    -SAFile SAUtf8WFOpen(const char *pszFilename, const char *pszAccess)
    +static SAFile SAUtf8WFOpen(const char *pszFilename, const char *pszAccess,
    +                           void *pvUserData)
     {
    +    (void)pvUserData;
         SAFile file = NULL;
         wchar_t *pwszFileName = Utf8ToWideChar(pszFilename);
         wchar_t *pwszAccess = Utf8ToWideChar(pszAccess);
    @@ -146,8 +149,9 @@ SAFile SAUtf8WFOpen(const char *pszFilename, const char *pszAccess)
         return file;
     }
     
    -int SAUtf8WRemove(const char *pszFilename)
    +static int SAUtf8WRemove(const char *pszFilename, void *pvUserData)
     {
    +    (void)pvUserData;
         wchar_t *pwszFileName = Utf8ToWideChar(pszFilename);
         int rc = -1;
         if (pwszFileName != NULL)
    diff --git a/shapelib/shapefil.h b/shapelib/shapefil.h
    index 2328f15cc..47b2e30fd 100644
    --- a/shapelib/shapefil.h
    +++ b/shapelib/shapefil.h
    @@ -9,7 +9,7 @@
      *
      ******************************************************************************
      * Copyright (c) 1999, Frank Warmerdam
    - * Copyright (c) 2012-2016, Even Rouault 
    + * Copyright (c) 2012-2024, Even Rouault 
      *
      * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
      ******************************************************************************
    @@ -27,22 +27,25 @@ extern "C"
     {
     #endif
     
    -/************************************************************************/
    -/*           Version related macros (added in 1.6.0)                    */
    -/************************************************************************/
    +    /************************************************************************/
    +    /*           Version related macros (added in 1.6.0)                    */
    +    /************************************************************************/
     
     #define SHAPELIB_VERSION_MAJOR 1
     #define SHAPELIB_VERSION_MINOR 6
    -#define SHAPELIB_VERSION_MICRO 0
    +#define SHAPELIB_VERSION_MICRO 1
     
    -#define SHAPELIB_MAKE_VERSION_NUMBER(major, minor, micro) \
    +#define SHAPELIB_MAKE_VERSION_NUMBER(major, minor, micro)                      \
         ((major) * 10000 + (minor) * 100 + (micro))
     
    -#define SHAPELIB_VERSION_NUMBER \
    -    SHAPELIB_MAKE_VERSION_NUMBER(SHAPELIB_VERSION_MAJOR, SHAPELIB_VERSION_MINOR, SHAPELIB_VERSION_MICRO)
    +#define SHAPELIB_VERSION_NUMBER                                                \
    +    SHAPELIB_MAKE_VERSION_NUMBER(SHAPELIB_VERSION_MAJOR,                       \
    +                                 SHAPELIB_VERSION_MINOR,                       \
    +                                 SHAPELIB_VERSION_MICRO)
     
    -#define SHAPELIB_AT_LEAST(major, minor, micro) \
    -    (SHAPELIB_VERSION_NUMBER >= SHAPELIB_MAKE_VERSION_NUMBER(major, minor, micro))
    +#define SHAPELIB_AT_LEAST(major, minor, micro)                                 \
    +    (SHAPELIB_VERSION_NUMBER >=                                                \
    +     SHAPELIB_MAKE_VERSION_NUMBER(major, minor, micro))
     
     /************************************************************************/
     /*                        Configuration options.                        */
    @@ -112,7 +115,7 @@ extern "C"
     /*      On some platforms, additional file IO hooks are defined that    */
     /*      UTF-8 encoded filenames Unicode filenames                       */
     /* -------------------------------------------------------------------- */
    -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
    +#if defined(_WIN32)
     #define SHPAPI_WINDOWS
     #define SHPAPI_UTF8_HOOKS
     #endif
    @@ -190,6 +193,13 @@ extern "C"
     
         typedef SHPInfo *SHPHandle;
     
    +    typedef struct
    +    {
    +        int year;
    +        int month;
    +        int day;
    +    } SHPDate;
    +
     /* -------------------------------------------------------------------- */
     /*      Shape types (nSHPType)                                          */
     /* -------------------------------------------------------------------- */
    @@ -221,7 +231,7 @@ extern "C"
     #define SHPP_RING 5
     
         /* -------------------------------------------------------------------- */
    -    /*      SHPObject - represents on shape (without attributes) read       */
    +    /*      SHPObject - represents one shape (without attributes) read      */
         /*      from the .shp file.                                             */
         /* -------------------------------------------------------------------- */
         struct tagSHPObject
    @@ -282,13 +292,13 @@ extern "C"
         SHPHandle SHPAPI_CALL SHPCreate(const char *pszShapeFile, int nShapeType);
         SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszShapeFile, int nShapeType,
                                           const SAHooks *psHooks);
    -    void SHPAPI_CALL SHPGetInfo(SHPHandle hSHP, int *pnEntities,
    +    void SHPAPI_CALL SHPGetInfo(const SHPHandle hSHP, int *pnEntities,
                                     int *pnShapeType, double *padfMinBound,
                                     double *padfMaxBound);
     
    -    SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle hSHP, int iShape);
    +    SHPObject SHPAPI_CALL1(*) SHPReadObject(const SHPHandle hSHP, int iShape);
         int SHPAPI_CALL SHPWriteObject(SHPHandle hSHP, int iShape,
    -                                   SHPObject *psObject);
    +                                   const SHPObject *psObject);
     
         void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject);
         void SHPAPI_CALL SHPComputeExtents(SHPObject *psObject);
    @@ -301,7 +311,7 @@ extern "C"
             SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX,
                                   const double *padfY, const double *padfZ);
     
    -    int SHPAPI_CALL SHPRewindObject(SHPHandle hSHP, SHPObject *psObject);
    +    int SHPAPI_CALL SHPRewindObject(const SHPHandle hSHP, SHPObject *psObject);
     
         void SHPAPI_CALL SHPClose(SHPHandle hSHP);
         void SHPAPI_CALL SHPWriteHeader(SHPHandle hSHP);
    @@ -355,12 +365,11 @@ extern "C"
         int SHPAPI_CALL SHPWriteTree(SHPTree *hTree, const char *pszFilename);
     
         int SHPAPI_CALL SHPTreeAddShapeId(SHPTree *hTree, SHPObject *psObject);
    -    int SHPAPI_CALL SHPTreeRemoveShapeId(SHPTree *hTree, int nShapeId);
     
         void SHPAPI_CALL SHPTreeTrimExtraNodes(SHPTree *hTree);
     
         int SHPAPI_CALL1(*)
    -        SHPTreeFindLikelyShapes(SHPTree *hTree, double *padfBoundsMin,
    +        SHPTreeFindLikelyShapes(const SHPTree *hTree, double *padfBoundsMin,
                                     double *padfBoundsMax, int *);
         int SHPAPI_CALL SHPCheckBoundsOverlap(const double *, const double *,
                                               const double *, const double *, int);
    @@ -377,8 +386,9 @@ extern "C"
         void SHPAPI_CALL SHPCloseDiskTree(SHPTreeDiskHandle hDiskTree);
     
         int SHPAPI_CALL1(*)
    -        SHPSearchDiskTreeEx(SHPTreeDiskHandle hDiskTree, double *padfBoundsMin,
    -                            double *padfBoundsMax, int *pnShapeCount);
    +        SHPSearchDiskTreeEx(const SHPTreeDiskHandle hDiskTree,
    +                            double *padfBoundsMin, double *padfBoundsMax,
    +                            int *pnShapeCount);
     
         int SHPAPI_CALL SHPWriteTreeLL(SHPTree *hTree, const char *pszFilename,
                                        const SAHooks *psHooks);
    @@ -395,12 +405,14 @@ extern "C"
         void SHPAPI_CALL SBNCloseDiskTree(SBNSearchHandle hSBN);
     
         int SHPAPI_CALL1(*)
    -        SBNSearchDiskTree(SBNSearchHandle hSBN, const double *padfBoundsMin,
    +        SBNSearchDiskTree(const SBNSearchHandle hSBN,
    +                          const double *padfBoundsMin,
                               const double *padfBoundsMax, int *pnShapeCount);
     
         int SHPAPI_CALL1(*)
    -        SBNSearchDiskTreeInteger(SBNSearchHandle hSBN, int bMinX, int bMinY,
    -                                 int bMaxX, int bMaxY, int *pnShapeCount);
    +        SBNSearchDiskTreeInteger(const SBNSearchHandle hSBN, int bMinX,
    +                                 int bMinY, int bMaxX, int bMaxY,
    +                                 int *pnShapeCount);
     
         void SHPAPI_CALL SBNSearchFreeIds(int *panShapeId);
     
    @@ -488,8 +500,8 @@ extern "C"
                                           const char *pszCodePage,
                                           const SAHooks *psHooks);
     
    -    int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF);
    -    int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF);
    +    int SHPAPI_CALL DBFGetFieldCount(const DBFHandle psDBF);
    +    int SHPAPI_CALL DBFGetRecordCount(const DBFHandle psDBF);
         int SHPAPI_CALL DBFAddField(DBFHandle hDBF, const char *pszFieldName,
                                     DBFFieldType eType, int nWidth, int nDecimals);
     
    @@ -505,11 +517,12 @@ extern "C"
                                           const char *pszFieldName, char chType,
                                           int nWidth, int nDecimals);
     
    -    DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField,
    +    DBFFieldType SHPAPI_CALL DBFGetFieldInfo(const DBFHandle psDBF, int iField,
                                                  char *pszFieldName, int *pnWidth,
                                                  int *pnDecimals);
     
    -    int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName);
    +    int SHPAPI_CALL DBFGetFieldIndex(const DBFHandle psDBF,
    +                                     const char *pszFieldName);
     
         int SHPAPI_CALL DBFReadIntegerAttribute(DBFHandle hDBF, int iShape,
                                                 int iField);
    @@ -519,7 +532,10 @@ extern "C"
             DBFReadStringAttribute(DBFHandle hDBF, int iShape, int iField);
         const char SHPAPI_CALL1(*)
             DBFReadLogicalAttribute(DBFHandle hDBF, int iShape, int iField);
    -    int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle hDBF, int iShape, int iField);
    +    SHPDate SHPAPI_CALL DBFReadDateAttribute(DBFHandle hDBF, int iShape,
    +                                             int iField);
    +    int SHPAPI_CALL DBFIsAttributeNULL(const DBFHandle hDBF, int iShape,
    +                                       int iField);
     
         int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle hDBF, int iShape,
                                                  int iField, int nFieldValue);
    @@ -534,24 +550,27 @@ extern "C"
         int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle hDBF, int iShape,
                                                  int iField,
                                                  const char lFieldValue);
    +    int SHPAPI_CALL DBFWriteDateAttribute(DBFHandle hDBF, int iShape,
    +                                          int iField,
    +                                          const SHPDate *dateFieldValue);
         int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity,
                                                   int iField, const void *pValue);
         const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity);
         int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity,
                                       const void *pRawTuple);
     
    -    int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape);
    +    int SHPAPI_CALL DBFIsRecordDeleted(const DBFHandle psDBF, int iShape);
         int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape,
                                              int bIsDeleted);
     
    -    DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF,
    +    DBFHandle SHPAPI_CALL DBFCloneEmpty(const DBFHandle psDBF,
                                             const char *pszFilename);
     
         void SHPAPI_CALL DBFClose(DBFHandle hDBF);
         void SHPAPI_CALL DBFUpdateHeader(DBFHandle hDBF);
    -    char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle hDBF, int iField);
    +    char SHPAPI_CALL DBFGetNativeFieldType(const DBFHandle hDBF, int iField);
     
    -    const char SHPAPI_CALL1(*) DBFGetCodePage(DBFHandle psDBF);
    +    const char SHPAPI_CALL1(*) DBFGetCodePage(const DBFHandle psDBF);
     
         void SHPAPI_CALL DBFSetLastModifiedDate(DBFHandle psDBF, int nYYSince1900,
                                                 int nMM, int nDD);
    diff --git a/shapelib/shapefil_private.h b/shapelib/shapefil_private.h
    new file mode 100644
    index 000000000..fd9ea93eb
    --- /dev/null
    +++ b/shapelib/shapefil_private.h
    @@ -0,0 +1,117 @@
    +#ifndef SHAPEFILE_PRIVATE_H_INCLUDED
    +#define SHAPEFILE_PRIVATE_H_INCLUDED
    +
    +/******************************************************************************
    + *
    + * Project:  Shapelib
    + * Purpose:  Private include file for Shapelib.
    + * Author:   Frank Warmerdam, warmerdam@pobox.com
    + *
    + ******************************************************************************
    + * Copyright (c) 1999, Frank Warmerdam
    + * Copyright (c) 2012-2024, Even Rouault 
    + *
    + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
    + ******************************************************************************
    + *
    + */
    +
    +#ifdef __cplusplus
    +#define STATIC_CAST(type, x) static_cast(x)
    +#define REINTERPRET_CAST(type, x) reinterpret_cast(x)
    +#define CONST_CAST(type, x) const_cast(x)
    +#define SHPLIB_NULLPTR nullptr
    +#else
    +#define STATIC_CAST(type, x) ((type)(x))
    +#define REINTERPRET_CAST(type, x) ((type)(x))
    +#define CONST_CAST(type, x) ((type)(x))
    +#define SHPLIB_NULLPTR NULL
    +#endif
    +
    +#if !defined(SHP_BIG_ENDIAN)
    +#if defined(CPL_MSB)
    +#define SHP_BIG_ENDIAN 1
    +#elif (defined(__GNUC__) && __GNUC__ >= 5) ||                                  \
    +    (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 4 &&          \
    +     __GNUC_MINOR__ >= 6)
    +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
    +#define SHP_BIG_ENDIAN 1
    +#endif
    +#elif defined(__GLIBC__)
    +#if __BYTE_ORDER == __BIG_ENDIAN
    +#define SHP_BIG_ENDIAN 1
    +#endif
    +#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
    +#define SHP_BIG_ENDIAN 1
    +#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
    +#elif defined(__sparc) || defined(__sparc__) || defined(_POWER) ||             \
    +    defined(__powerpc__) || defined(__ppc__) || defined(__hpux) ||             \
    +    defined(_MIPSEB) || defined(_POWER) || defined(__s390__)
    +#define SHP_BIG_ENDIAN 1
    +#endif
    +#endif
    +
    +#include "shapefil.h"
    +#include 
    +#include 
    +
    +/************************************************************************/
    +/*        Little endian <==> big endian byte swap macros.               */
    +/************************************************************************/
    +
    +#if (defined(__GNUC__) && __GNUC__ >= 5) ||                                    \
    +    (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 4 &&          \
    +     __GNUC_MINOR__ >= 8)
    +#define _SHP_SWAP32(x)                                                         \
    +    STATIC_CAST(uint32_t, __builtin_bswap32(STATIC_CAST(uint32_t, x)))
    +#define _SHP_SWAP64(x)                                                         \
    +    STATIC_CAST(uint64_t, __builtin_bswap64(STATIC_CAST(uint64_t, x)))
    +#elif defined(_MSC_VER)
    +#define _SHP_SWAP32(x)                                                         \
    +    STATIC_CAST(uint32_t, _byteswap_ulong(STATIC_CAST(uint32_t, x)))
    +#define _SHP_SWAP64(x)                                                         \
    +    STATIC_CAST(uint64_t, _byteswap_uint64(STATIC_CAST(uint64_t, x)))
    +#else
    +#define _SHP_SWAP32(x)                                                         \
    +    STATIC_CAST(uint32_t,                                                      \
    +                ((STATIC_CAST(uint32_t, x) & 0x000000ffU) << 24) |             \
    +                    ((STATIC_CAST(uint32_t, x) & 0x0000ff00U) << 8) |          \
    +                    ((STATIC_CAST(uint32_t, x) & 0x00ff0000U) >> 8) |          \
    +                    ((STATIC_CAST(uint32_t, x) & 0xff000000U) >> 24))
    +#define _SHP_SWAP64(x)                                                         \
    +    ((STATIC_CAST(uint64_t, _SHP_SWAP32(STATIC_CAST(uint32_t, x))) << 32) |    \
    +     (STATIC_CAST(uint64_t, _SHP_SWAP32(STATIC_CAST(                           \
    +                                uint32_t, STATIC_CAST(uint64_t, x) >> 32)))))
    +
    +#endif
    +
    +/* in-place uint32_t* swap */
    +#define SHP_SWAP32(p)                                                          \
    +    *REINTERPRET_CAST(uint32_t *, p) =                                         \
    +        _SHP_SWAP32(*REINTERPRET_CAST(uint32_t *, p))
    +/* in-place uint64_t* swap */
    +#define SHP_SWAP64(p)                                                          \
    +    *REINTERPRET_CAST(uint64_t *, p) =                                         \
    +        _SHP_SWAP64(*REINTERPRET_CAST(uint64_t *, p))
    +/* in-place double* swap */
    +#define SHP_SWAPDOUBLE(x)                                                      \
    +    do                                                                         \
    +    {                                                                          \
    +        uint64_t _n64;                                                         \
    +        void *_lx = x;                                                         \
    +        memcpy(&_n64, _lx, 8);                                                 \
    +        _n64 = _SHP_SWAP64(_n64);                                              \
    +        memcpy(_lx, &_n64, 8);                                                 \
    +    } while (0)
    +/* copy double* swap*/
    +#define SHP_SWAPDOUBLE_CPY(dst, src)                                           \
    +    do                                                                         \
    +    {                                                                          \
    +        uint64_t _n64;                                                         \
    +        const void *_ls = src;                                                 \
    +        void *_ld = dst;                                                       \
    +        memcpy(&_n64, _ls, 8);                                                 \
    +        _n64 = _SHP_SWAP64(_n64);                                              \
    +        memcpy(_ld, &_n64, 8);                                                 \
    +    } while (0)
    +#endif /* ndef SHAPEFILE_PRIVATE_H_INCLUDED */
    diff --git a/shapelib/shp_api.html b/shapelib/shp_api.html
    index 55900bd6f..f80a25a0e 100644
    --- a/shapelib/shp_api.html
    +++ b/shapelib/shp_api.html
    @@ -82,6 +82,9 @@ 

    SHPObject

    double dfYMax; double dfZMax; double dfMMax; + + int bMeasureIsUsed; + int bFastModeReadObject; } SHPObject;
    @@ -113,7 +116,7 @@

    SHPOpen()

    SHPGetInfo()

    -void SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
    +void SHPGetInfo( const SHPHandle hSHP, int * pnEntities, int * pnShapeType,
                      double * padfMinBound, double * padfMaxBound );
     
       hSHP:			The handle previously returned by SHPOpen()
    @@ -143,7 +146,7 @@ 

    SHPGetInfo()

    SHPReadObject()

    -SHPObject *SHPReadObject( SHPHandle hSHP, int iShape );
    +SHPObject *SHPReadObject( const SHPHandle hSHP, int iShape );
     
       hSHP:			The handle previously returned by SHPOpen()
     			or SHPCreate().
    @@ -210,7 +213,8 @@ 

    SHPCreateSimpleObject()

     SHPObject *
          SHPCreateSimpleObject( int nSHPType, int nVertices,
    -			    double *padfX, double * padfY, double *padfZ, );
    +			    const double *padfX, const double * padfY,
    +			    const double *padfZ );
     
       nSHPType:		The SHPT_ type of the object to be created, such
                             as SHPT_POINT, or SHPT_POLYGON.
    @@ -250,9 +254,10 @@ 

    SHPCreateObject()

     SHPObject *
          SHPCreateObject( int nSHPType, int iShape,
    -                      int nParts, int * panPartStart, int * panPartType,
    -                      int nVertices, double *padfX, double * padfY,
    -                      double *padfZ, double *padfM );
    +                      int nParts, const int * panPartStart,
    +                      const int * panPartType,
    +                      int nVertices, const double *padfX, const double * padfY,
    +                      const double *padfZ, const double *padfM );
     
       nSHPType:		The SHPT_ type of the object to be created, such
                             as SHPT_POINT, or SHPT_POLYGON.
    @@ -321,7 +326,7 @@ 

    SHPComputeExtents()

    SHPWriteObject()

    -int SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject *psObject );
    +int SHPWriteObject( SHPHandle hSHP, int iShape, const SHPObject *psObject );
     
       hSHP:			The handle previously returned by SHPOpen("r+")
     			or SHPCreate().
    diff --git a/shapelib/shpopen.c b/shapelib/shpopen.c
    index 2cf982ddf..014e15770 100644
    --- a/shapelib/shpopen.c
    +++ b/shapelib/shpopen.c
    @@ -6,12 +6,12 @@
      *
      ******************************************************************************
      * Copyright (c) 1999, 2001, Frank Warmerdam
    - * Copyright (c) 2011-2019, Even Rouault 
    + * Copyright (c) 2011-2024, Even Rouault 
      *
      * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
      ******************************************************************************/
     
    -#include "shapefil.h"
    +#include "shapefil_private.h"
     
     #include 
     #include 
    @@ -39,60 +39,17 @@
     #if _MSC_VER < 1900
     #define snprintf _snprintf
     #endif
    -#elif defined(WIN32) || defined(_WIN32)
    +#elif defined(_WIN32)
     #ifndef snprintf
     #define snprintf _snprintf
     #endif
     #endif
     #endif
     
    -#ifndef CPL_UNUSED
    -#if defined(__GNUC__) && __GNUC__ >= 4
    -#define CPL_UNUSED __attribute((__unused__))
    -#else
    -#define CPL_UNUSED
    -#endif
    -#endif
    -
    -#ifndef bBigEndian
    -#if defined(CPL_LSB)
    -#define bBigEndian false
    -#elif defined(CPL_MSB)
    -#define bBigEndian true
    -#else
    -#ifndef static_var_bBigEndian_defined
    -#define static_var_bBigEndian_defined
    -static bool bBigEndian = false;
    -#endif
    -#endif
    -#endif
    -
    -#ifdef __cplusplus
    -#define STATIC_CAST(type, x) static_cast(x)
    -#define SHPLIB_NULLPTR nullptr
    -#else
    -#define STATIC_CAST(type, x) ((type)(x))
    -#define SHPLIB_NULLPTR NULL
    -#endif
    -
    -/************************************************************************/
    -/*                              SwapWord()                              */
    -/*                                                                      */
    -/*      Swap a 2, 4 or 8 byte word.                                     */
    -/************************************************************************/
    -
    -#ifndef SwapWord_defined
    -#define SwapWord_defined
    -static void SwapWord(int length, void *wordP)
    -{
    -    for (int i = 0; i < length / 2; i++)
    -    {
    -        const unsigned char temp = STATIC_CAST(unsigned char *, wordP)[i];
    -        STATIC_CAST(unsigned char *, wordP)
    -        [i] = STATIC_CAST(unsigned char *, wordP)[length - i - 1];
    -        STATIC_CAST(unsigned char *, wordP)[length - i - 1] = temp;
    -    }
    -}
    +/* Allows customization of the message in vendored builds (such as GDAL) */
    +#ifndef SHP_RESTORE_SHX_HINT_MESSAGE
    +#define SHP_RESTORE_SHX_HINT_MESSAGE                                           \
    +    " Use SHPRestoreSHX() to restore or create it."
     #endif
     
     /************************************************************************/
    @@ -120,58 +77,67 @@ void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP)
     
         uint32_t i32 = psSHP->nFileSize / 2; /* file size */
         ByteCopy(&i32, abyHeader + 24, 4);
    -    if (!bBigEndian)
    -        SwapWord(4, abyHeader + 24);
    +#if !defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(abyHeader + 24);
    +#endif
     
         i32 = 1000; /* version */
         ByteCopy(&i32, abyHeader + 28, 4);
    -    if (bBigEndian)
    -        SwapWord(4, abyHeader + 28);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(abyHeader + 28);
    +#endif
     
         i32 = psSHP->nShapeType; /* shape type */
         ByteCopy(&i32, abyHeader + 32, 4);
    -    if (bBigEndian)
    -        SwapWord(4, abyHeader + 32);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(abyHeader + 32);
    +#endif
     
         double dValue = psSHP->adBoundsMin[0]; /* set bounds */
         ByteCopy(&dValue, abyHeader + 36, 8);
    -    if (bBigEndian)
    -        SwapWord(8, abyHeader + 36);
    -
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(abyHeader + 36);
    +#endif
         dValue = psSHP->adBoundsMin[1];
         ByteCopy(&dValue, abyHeader + 44, 8);
    -    if (bBigEndian)
    -        SwapWord(8, abyHeader + 44);
    -
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(abyHeader + 44);
    +#endif
         dValue = psSHP->adBoundsMax[0];
         ByteCopy(&dValue, abyHeader + 52, 8);
    -    if (bBigEndian)
    -        SwapWord(8, abyHeader + 52);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(abyHeader + 52);
    +#endif
     
         dValue = psSHP->adBoundsMax[1];
         ByteCopy(&dValue, abyHeader + 60, 8);
    -    if (bBigEndian)
    -        SwapWord(8, abyHeader + 60);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(abyHeader + 60);
    +#endif
     
         dValue = psSHP->adBoundsMin[2]; /* z */
         ByteCopy(&dValue, abyHeader + 68, 8);
    -    if (bBigEndian)
    -        SwapWord(8, abyHeader + 68);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(abyHeader + 68);
    +#endif
     
         dValue = psSHP->adBoundsMax[2];
         ByteCopy(&dValue, abyHeader + 76, 8);
    -    if (bBigEndian)
    -        SwapWord(8, abyHeader + 76);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(abyHeader + 76);
    +#endif
     
         dValue = psSHP->adBoundsMin[3]; /* m */
         ByteCopy(&dValue, abyHeader + 84, 8);
    -    if (bBigEndian)
    -        SwapWord(8, abyHeader + 84);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(abyHeader + 84);
    +#endif
     
         dValue = psSHP->adBoundsMax[3];
         ByteCopy(&dValue, abyHeader + 92, 8);
    -    if (bBigEndian)
    -        SwapWord(8, abyHeader + 92);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(abyHeader + 92);
    +#endif
     
         /* -------------------------------------------------------------------- */
         /*      Write .shp file header.                                         */
    @@ -193,8 +159,9 @@ void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP)
         /* -------------------------------------------------------------------- */
         i32 = (psSHP->nRecords * 2 * sizeof(uint32_t) + 100) / 2; /* file size */
         ByteCopy(&i32, abyHeader + 24, 4);
    -    if (!bBigEndian)
    -        SwapWord(4, abyHeader + 24);
    +#if !defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(abyHeader + 24);
    +#endif
     
         if (psSHP->sHooks.FSeek(psSHP->fpSHX, 0, 0) != 0 ||
             psSHP->sHooks.FWrite(abyHeader, 100, 1, psSHP->fpSHX) != 1)
    @@ -224,10 +191,10 @@ void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP)
         {
             panSHX[i * 2] = psSHP->panRecOffset[i] / 2;
             panSHX[i * 2 + 1] = psSHP->panRecSize[i] / 2;
    -        if (!bBigEndian)
    -            SwapWord(4, panSHX + i * 2);
    -        if (!bBigEndian)
    -            SwapWord(4, panSHX + i * 2 + 1);
    +#if !defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(panSHX + i * 2);
    +        SHP_SWAP32(panSHX + i * 2 + 1);
    +#endif
         }
     
         if (STATIC_CAST(int, psSHP->sHooks.FWrite(panSHX, sizeof(uint32_t) * 2,
    @@ -309,23 +276,10 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess,
             pszAccess = "rb";
         }
     
    -/* -------------------------------------------------------------------- */
    -/*  Establish the byte order on this machine.           */
    -/* -------------------------------------------------------------------- */
    -#if !defined(bBigEndian)
    -    {
    -        int i = 1;
    -        if (*((unsigned char *)&i) == 1)
    -            bBigEndian = false;
    -        else
    -            bBigEndian = true;
    -    }
    -#endif
    -
         /* -------------------------------------------------------------------- */
         /*  Initialize the info structure.                  */
         /* -------------------------------------------------------------------- */
    -    SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(sizeof(SHPInfo), 1));
    +    SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(1, sizeof(SHPInfo)));
     
         psSHP->bUpdated = FALSE;
         memcpy(&(psSHP->sHooks), psHooks, sizeof(SAHooks));
    @@ -376,14 +330,14 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess,
     
         if (psSHP->fpSHX == SHPLIB_NULLPTR)
         {
    -        const size_t nMessageLen = strlen(pszFullname) * 2 + 256;
    +        const size_t nMessageLen =
    +            64 + strlen(pszFullname) * 2 + strlen(SHP_RESTORE_SHX_HINT_MESSAGE);
             char *pszMessage = STATIC_CAST(char *, malloc(nMessageLen));
             pszFullname[nLenWithoutExtension] = 0;
    -        snprintf(pszMessage, nMessageLen,
    -                 "Unable to open %s.shx or %s.SHX. "
    -                 "Set SHAPE_RESTORE_SHX config option to YES to restore or "
    -                 "create it.",
    -                 pszFullname, pszFullname);
    +        snprintf(
    +            pszMessage, nMessageLen,
    +            "Unable to open %s.shx or %s.SHX." SHP_RESTORE_SHX_HINT_MESSAGE,
    +            pszFullname, pszFullname);
             psHooks->Error(pszMessage);
             free(pszMessage);
     
    @@ -476,43 +430,51 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess,
         /* -------------------------------------------------------------------- */
         double dValue;
     
    -    if (bBigEndian)
    -        SwapWord(8, pabyBuf + 36);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyBuf + 36);
    +#endif
         memcpy(&dValue, pabyBuf + 36, 8);
         psSHP->adBoundsMin[0] = dValue;
     
    -    if (bBigEndian)
    -        SwapWord(8, pabyBuf + 44);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyBuf + 44);
    +#endif
         memcpy(&dValue, pabyBuf + 44, 8);
         psSHP->adBoundsMin[1] = dValue;
     
    -    if (bBigEndian)
    -        SwapWord(8, pabyBuf + 52);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyBuf + 52);
    +#endif
         memcpy(&dValue, pabyBuf + 52, 8);
         psSHP->adBoundsMax[0] = dValue;
     
    -    if (bBigEndian)
    -        SwapWord(8, pabyBuf + 60);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyBuf + 60);
    +#endif
         memcpy(&dValue, pabyBuf + 60, 8);
         psSHP->adBoundsMax[1] = dValue;
     
    -    if (bBigEndian)
    -        SwapWord(8, pabyBuf + 68); /* z */
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyBuf + 68); /* z */
    +#endif
         memcpy(&dValue, pabyBuf + 68, 8);
         psSHP->adBoundsMin[2] = dValue;
     
    -    if (bBigEndian)
    -        SwapWord(8, pabyBuf + 76);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyBuf + 76);
    +#endif
         memcpy(&dValue, pabyBuf + 76, 8);
         psSHP->adBoundsMax[2] = dValue;
     
    -    if (bBigEndian)
    -        SwapWord(8, pabyBuf + 84); /* z */
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyBuf + 84); /* z */
    +#endif
         memcpy(&dValue, pabyBuf + 84, 8);
         psSHP->adBoundsMin[3] = dValue;
     
    -    if (bBigEndian)
    -        SwapWord(8, pabyBuf + 92);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyBuf + 92);
    +#endif
         memcpy(&dValue, pabyBuf + 92, 8);
         psSHP->adBoundsMax[3] = dValue;
     
    @@ -604,13 +566,15 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess,
         {
             unsigned int nOffset;
             memcpy(&nOffset, pabyBuf + i * 8, 4);
    -        if (!bBigEndian)
    -            SwapWord(4, &nOffset);
    +#if !defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(&nOffset);
    +#endif
     
             unsigned int nLength;
             memcpy(&nLength, pabyBuf + i * 8 + 4, 4);
    -        if (!bBigEndian)
    -            SwapWord(4, &nLength);
    +#if !defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(&nLength);
    +#endif
     
             if (nOffset > STATIC_CAST(unsigned int, INT_MAX))
             {
    @@ -691,19 +655,6 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess,
             pszAccess = "rb";
         }
     
    -/* -------------------------------------------------------------------- */
    -/*  Establish the byte order on this machine.                           */
    -/* -------------------------------------------------------------------- */
    -#if !defined(bBigEndian)
    -    {
    -        int i = 1;
    -        if (*((unsigned char *)&i) == 1)
    -            bBigEndian = false;
    -        else
    -            bBigEndian = true;
    -    }
    -#endif
    -
         /* -------------------------------------------------------------------- */
         /*  Open the .shp file.  Note that files pulled from                    */
         /*  a PC to Unix with upper case filenames won't work!                  */
    @@ -808,16 +759,18 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess,
                 char abyReadRecord[8];
                 unsigned int nRecordOffsetBE = nRecordOffset;
     
    -            if (!bBigEndian)
    -                SwapWord(4, &nRecordOffsetBE);
    +#if !defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP32(&nRecordOffsetBE);
    +#endif
                 memcpy(abyReadRecord, &nRecordOffsetBE, 4);
                 memcpy(abyReadRecord + 4, &nRecordLength, 4);
     
    -            if (!bBigEndian)
    -                SwapWord(4, &nRecordLength);
    -
    -            if (bBigEndian)
    -                SwapWord(4, &nSHPType);
    +#if !defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP32(&nRecordLength);
    +#endif
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP32(&nSHPType);
    +#endif
     
                 // Sanity check on record length
                 if (nRecordLength < 1 ||
    @@ -828,7 +781,7 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess,
                              "Error parsing .shp to restore .shx. "
                              "Invalid record length = %u at record starting at "
                              "offset %u",
    -                         nSHPType, nCurrentSHPOffset);
    +                         nRecordLength, nCurrentSHPOffset);
                     psHooks->Error(szErrorMsg);
     
                     nRetCode = FALSE;
    @@ -888,8 +841,10 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess,
         }
     
         nRealSHXContentSize /= 2;  // Bytes counted -> WORDs
    -    if (!bBigEndian)
    -        SwapWord(4, &nRealSHXContentSize);
    +#if !defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(&nRealSHXContentSize);
    +#endif
    +
         psHooks->FSeek(fpSHX, 24, 0);
         psHooks->FWrite(&nRealSHXContentSize, 4, 1, fpSHX);
     
    @@ -975,8 +930,9 @@ void SHPAPI_CALL SHPSetFastModeReadObject(SHPHandle hSHP, int bFastMode)
     /*      Fetch general information about the shape file.                 */
     /************************************************************************/
     
    -void SHPAPI_CALL SHPGetInfo(SHPHandle psSHP, int *pnEntities, int *pnShapeType,
    -                            double *padfMinBound, double *padfMaxBound)
    +void SHPAPI_CALL SHPGetInfo(const SHPHandle psSHP, int *pnEntities,
    +                            int *pnShapeType, double *padfMinBound,
    +                            double *padfMaxBound)
     {
         if (psSHP == SHPLIB_NULLPTR)
             return;
    @@ -1022,19 +978,6 @@ SHPHandle SHPAPI_CALL SHPCreate(const char *pszLayer, int nShapeType)
     SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType,
                                       const SAHooks *psHooks)
     {
    -/* -------------------------------------------------------------------- */
    -/*      Establish the byte order on this system.                        */
    -/* -------------------------------------------------------------------- */
    -#if !defined(bBigEndian)
    -    {
    -        int i = 1;
    -        if (*((unsigned char *)&i) == 1)
    -            bBigEndian = false;
    -        else
    -            bBigEndian = true;
    -    }
    -#endif
    -
         /* -------------------------------------------------------------------- */
         /*      Open the two files so we can write their headers.               */
         /* -------------------------------------------------------------------- */
    @@ -1051,7 +994,7 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType,
             psHooks->Error(szErrorMsg);
     
             free(pszFullname);
    -        return NULL;
    +        return SHPLIB_NULLPTR;
         }
     
         memcpy(pszFullname + nLenWithoutExtension, ".shx", 5);
    @@ -1065,7 +1008,7 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType,
     
             free(pszFullname);
             psHooks->FClose(fpSHP);
    -        return NULL;
    +        return SHPLIB_NULLPTR;
         }
     
         free(pszFullname);
    @@ -1082,18 +1025,21 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType,
     
         uint32_t i32 = 50; /* file size */
         ByteCopy(&i32, abyHeader + 24, 4);
    -    if (!bBigEndian)
    -        SwapWord(4, abyHeader + 24);
    +#if !defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(abyHeader + 24);
    +#endif
     
         i32 = 1000; /* version */
         ByteCopy(&i32, abyHeader + 28, 4);
    -    if (bBigEndian)
    -        SwapWord(4, abyHeader + 28);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(abyHeader + 28);
    +#endif
     
         i32 = nShapeType; /* shape type */
         ByteCopy(&i32, abyHeader + 32, 4);
    -    if (bBigEndian)
    -        SwapWord(4, abyHeader + 32);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(abyHeader + 32);
    +#endif
     
         double dValue = 0.0; /* set bounds */
         ByteCopy(&dValue, abyHeader + 36, 8);
    @@ -1116,7 +1062,7 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType,
             free(pszFullname);
             psHooks->FClose(fpSHP);
             psHooks->FClose(fpSHX);
    -        return NULL;
    +        return SHPLIB_NULLPTR;
         }
     
         /* -------------------------------------------------------------------- */
    @@ -1124,8 +1070,9 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType,
         /* -------------------------------------------------------------------- */
         i32 = 50; /* file size */
         ByteCopy(&i32, abyHeader + 24, 4);
    -    if (!bBigEndian)
    -        SwapWord(4, abyHeader + 24);
    +#if !defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(abyHeader + 24);
    +#endif
     
         if (psHooks->FWrite(abyHeader, 100, 1, fpSHX) != 1)
         {
    @@ -1139,10 +1086,10 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType,
             free(pszFullname);
             psHooks->FClose(fpSHP);
             psHooks->FClose(fpSHX);
    -        return NULL;
    +        return SHPLIB_NULLPTR;
         }
     
    -    SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(sizeof(SHPInfo), 1));
    +    SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(1, sizeof(SHPInfo)));
     
         psSHP->bUpdated = FALSE;
         memcpy(&(psSHP->sHooks), psHooks, sizeof(SAHooks));
    @@ -1187,13 +1134,12 @@ static void _SHPSetBounds(unsigned char *pabyRec, const SHPObject *psShape)
         ByteCopy(&(psShape->dfXMax), pabyRec + 16, 8);
         ByteCopy(&(psShape->dfYMax), pabyRec + 24, 8);
     
    -    if (bBigEndian)
    -    {
    -        SwapWord(8, pabyRec + 0);
    -        SwapWord(8, pabyRec + 8);
    -        SwapWord(8, pabyRec + 16);
    -        SwapWord(8, pabyRec + 24);
    -    }
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP64(pabyRec + 0);
    +    SHP_SWAP64(pabyRec + 8);
    +    SHP_SWAP64(pabyRec + 16);
    +    SHP_SWAP64(pabyRec + 24);
    +#endif
     }
     
     /************************************************************************/
    @@ -1286,7 +1232,7 @@ SHPObject SHPAPI_CALL1(*)
             psObject->nParts = MAX(1, nParts);
     
             psObject->panPartStart =
    -            STATIC_CAST(int *, calloc(sizeof(int), psObject->nParts));
    +            STATIC_CAST(int *, calloc(psObject->nParts, sizeof(int)));
             psObject->panPartType =
                 STATIC_CAST(int *, malloc(sizeof(int) * psObject->nParts));
     
    @@ -1304,8 +1250,7 @@ SHPObject SHPAPI_CALL1(*)
                     psObject->panPartType[i] = SHPP_RING;
             }
     
    -        if (psObject->panPartStart[0] != 0)
    -            psObject->panPartStart[0] = 0;
    +        psObject->panPartStart[0] = 0;
         }
     
         /* -------------------------------------------------------------------- */
    @@ -1316,16 +1261,16 @@ SHPObject SHPAPI_CALL1(*)
             const size_t nSize = sizeof(double) * nVertices;
             psObject->padfX =
                 STATIC_CAST(double *, padfX ? malloc(nSize)
    -                                        : calloc(sizeof(double), nVertices));
    +                                        : calloc(nVertices, sizeof(double)));
             psObject->padfY =
                 STATIC_CAST(double *, padfY ? malloc(nSize)
    -                                        : calloc(sizeof(double), nVertices));
    +                                        : calloc(nVertices, sizeof(double)));
             psObject->padfZ = STATIC_CAST(
                 double *,
    -            padfZ &&bHasZ ? malloc(nSize) : calloc(sizeof(double), nVertices));
    +            padfZ &&bHasZ ? malloc(nSize) : calloc(nVertices, sizeof(double)));
             psObject->padfM = STATIC_CAST(
                 double *,
    -            padfM &&bHasM ? malloc(nSize) : calloc(sizeof(double), nVertices));
    +            padfM &&bHasM ? malloc(nSize) : calloc(nVertices, sizeof(double)));
             if (padfX != SHPLIB_NULLPTR)
                 memcpy(psObject->padfX, padfX, nSize);
             if (padfY != SHPLIB_NULLPTR)
    @@ -1371,7 +1316,7 @@ SHPObject SHPAPI_CALL1(*)
     /************************************************************************/
     
     int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
    -                               SHPObject *psObject)
    +                               const SHPObject *psObject)
     {
         psSHP->bUpdated = TRUE;
     
    @@ -1472,10 +1417,10 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
     
             _SHPSetBounds(pabyRec + 12, psObject);
     
    -        if (bBigEndian)
    -            SwapWord(4, &nPoints);
    -        if (bBigEndian)
    -            SwapWord(4, &nParts);
    +#if defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(&nPoints);
    +        SHP_SWAP32(&nParts);
    +#endif
     
             ByteCopy(&nPoints, pabyRec + 40 + 8, 4);
             ByteCopy(&nParts, pabyRec + 36 + 8, 4);
    @@ -1489,8 +1434,9 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
                      4 * psObject->nParts);
             for (int i = 0; i < psObject->nParts; i++)
             {
    -            if (bBigEndian)
    -                SwapWord(4, pabyRec + 44 + 8 + 4 * i);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP32(pabyRec + 44 + 8 + 4 * i);
    +#endif
                 nRecordSize += 4;
             }
     
    @@ -1503,8 +1449,9 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
                        4 * psObject->nParts);
                 for (int i = 0; i < psObject->nParts; i++)
                 {
    -                if (bBigEndian)
    -                    SwapWord(4, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAP32(pabyRec + nRecordSize);
    +#endif
                     nRecordSize += 4;
                 }
             }
    @@ -1517,11 +1464,10 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
                 ByteCopy(psObject->padfX + i, pabyRec + nRecordSize, 8);
                 ByteCopy(psObject->padfY + i, pabyRec + nRecordSize + 8, 8);
     
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    -
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize + 8);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +            SHP_SWAP64(pabyRec + nRecordSize + 8);
    +#endif
     
                 nRecordSize += 2 * 8;
             }
    @@ -1534,20 +1480,23 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
                 psObject->nSHPType == SHPT_MULTIPATCH)
             {
                 ByteCopy(&(psObject->dfZMin), pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
     
                 ByteCopy(&(psObject->dfZMax), pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
     
                 for (int i = 0; i < psObject->nVertices; i++)
                 {
                     ByteCopy(psObject->padfZ + i, pabyRec + nRecordSize, 8);
    -                if (bBigEndian)
    -                    SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                     nRecordSize += 8;
                 }
             }
    @@ -1565,20 +1514,23 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
                  psObject->nSHPType == SHPT_ARCZ))
             {
                 ByteCopy(&(psObject->dfMMin), pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
     
                 ByteCopy(&(psObject->dfMMax), pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
     
                 for (int i = 0; i < psObject->nVertices; i++)
                 {
                     ByteCopy(psObject->padfM + i, pabyRec + nRecordSize, 8);
    -                if (bBigEndian)
    -                    SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                     nRecordSize += 8;
                 }
             }
    @@ -1595,8 +1547,9 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
     
             _SHPSetBounds(pabyRec + 12, psObject);
     
    -        if (bBigEndian)
    -            SwapWord(4, &nPoints);
    +#if defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(&nPoints);
    +#endif
             ByteCopy(&nPoints, pabyRec + 44, 4);
     
             for (int i = 0; i < psObject->nVertices; i++)
    @@ -1604,10 +1557,10 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
                 ByteCopy(psObject->padfX + i, pabyRec + 48 + i * 16, 8);
                 ByteCopy(psObject->padfY + i, pabyRec + 48 + i * 16 + 8, 8);
     
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + 48 + i * 16);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + 48 + i * 16 + 8);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + 48 + i * 16);
    +            SHP_SWAP64(pabyRec + 48 + i * 16 + 8);
    +#endif
             }
     
             nRecordSize = 48 + 16 * psObject->nVertices;
    @@ -1615,20 +1568,23 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
             if (psObject->nSHPType == SHPT_MULTIPOINTZ)
             {
                 ByteCopy(&(psObject->dfZMin), pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
     
                 ByteCopy(&(psObject->dfZMax), pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
     
                 for (int i = 0; i < psObject->nVertices; i++)
                 {
                     ByteCopy(psObject->padfZ + i, pabyRec + nRecordSize, 8);
    -                if (bBigEndian)
    -                    SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                     nRecordSize += 8;
                 }
             }
    @@ -1638,20 +1594,23 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
                  psObject->nSHPType == SHPT_MULTIPOINTM))
             {
                 ByteCopy(&(psObject->dfMMin), pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
     
                 ByteCopy(&(psObject->dfMMax), pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
     
                 for (int i = 0; i < psObject->nVertices; i++)
                 {
                     ByteCopy(psObject->padfM + i, pabyRec + nRecordSize, 8);
    -                if (bBigEndian)
    -                    SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                     nRecordSize += 8;
                 }
             }
    @@ -1667,18 +1626,19 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
             ByteCopy(psObject->padfX, pabyRec + 12, 8);
             ByteCopy(psObject->padfY, pabyRec + 20, 8);
     
    -        if (bBigEndian)
    -            SwapWord(8, pabyRec + 12);
    -        if (bBigEndian)
    -            SwapWord(8, pabyRec + 20);
    +#if defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP64(pabyRec + 12);
    +        SHP_SWAP64(pabyRec + 20);
    +#endif
     
             nRecordSize = 28;
     
             if (psObject->nSHPType == SHPT_POINTZ)
             {
                 ByteCopy(psObject->padfZ, pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
             }
     
    @@ -1686,8 +1646,9 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
                                              psObject->nSHPType == SHPT_POINTM))
             {
                 ByteCopy(psObject->padfM, pabyRec + nRecordSize, 8);
    -            if (bBigEndian)
    -                SwapWord(8, pabyRec + nRecordSize);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP64(pabyRec + nRecordSize);
    +#endif
                 nRecordSize += 8;
             }
         }
    @@ -1751,18 +1712,21 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId,
         /* -------------------------------------------------------------------- */
         uint32_t i32 =
             (nShapeId < 0) ? psSHP->nRecords + 1 : nShapeId + 1; /* record # */
    -    if (!bBigEndian)
    -        SwapWord(4, &i32);
    +#if !defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(&i32);
    +#endif
         ByteCopy(&i32, pabyRec, 4);
     
         i32 = (nRecordSize - 8) / 2; /* record size */
    -    if (!bBigEndian)
    -        SwapWord(4, &i32);
    +#if !defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(&i32);
    +#endif
         ByteCopy(&i32, pabyRec + 4, 4);
     
         i32 = psObject->nSHPType; /* shape type */
    -    if (bBigEndian)
    -        SwapWord(4, &i32);
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(&i32);
    +#endif
         ByteCopy(&i32, pabyRec + 8, 4);
     
         /* -------------------------------------------------------------------- */
    @@ -1924,7 +1888,7 @@ static unsigned char *SHPReallocObjectBufIfNecessary(SHPHandle psSHP,
     /*      for one shape.                                                  */
     /************************************************************************/
     
    -SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
    +SHPObject SHPAPI_CALL1(*) SHPReadObject(const SHPHandle psSHP, int hEntity)
     {
         /* -------------------------------------------------------------------- */
         /*      Validate the record/entity number.                              */
    @@ -1954,10 +1918,10 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
                 psSHP->sHooks.Error(str);
                 return SHPLIB_NULLPTR;
             }
    -        if (!bBigEndian)
    -            SwapWord(4, &nOffset);
    -        if (!bBigEndian)
    -            SwapWord(4, &nLength);
    +#if !defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(&nOffset);
    +        SHP_SWAP32(&nLength);
    +#endif
     
             if (nOffset > STATIC_CAST(unsigned int, INT_MAX))
             {
    @@ -2089,8 +2053,9 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             /* Do a sanity check */
             int nSHPContentLength;
             memcpy(&nSHPContentLength, psSHP->pabyRec + 4, 4);
    -        if (!bBigEndian)
    -            SwapWord(4, &(nSHPContentLength));
    +#if !defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(&(nSHPContentLength));
    +#endif
             if (nSHPContentLength < 0 || nSHPContentLength > INT_MAX / 2 - 4 ||
                 2 * nSHPContentLength + 8 != nBytesRead)
             {
    @@ -2135,8 +2100,9 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
         int nSHPType;
         memcpy(&nSHPType, psSHP->pabyRec + 8, 4);
     
    -    if (bBigEndian)
    -        SwapWord(4, &(nSHPType));
    +#if defined(SHP_BIG_ENDIAN)
    +    SHP_SWAP32(&(nSHPType));
    +#endif
     
         /* -------------------------------------------------------------------- */
         /*      Allocate and minimally initialize the object.                   */
    @@ -2185,19 +2151,17 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             /* -------------------------------------------------------------------- */
             /*      Get the X/Y bounds.                                             */
             /* -------------------------------------------------------------------- */
    -        memcpy(&(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8);
    -        memcpy(&(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8);
    -        memcpy(&(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8);
    -        memcpy(&(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8);
    -
    -        if (bBigEndian)
    -            SwapWord(8, &(psShape->dfXMin));
    -        if (bBigEndian)
    -            SwapWord(8, &(psShape->dfYMin));
    -        if (bBigEndian)
    -            SwapWord(8, &(psShape->dfXMax));
    -        if (bBigEndian)
    -            SwapWord(8, &(psShape->dfYMax));
    +#if defined(SHP_BIG_ENDIAN)
    +        SHP_SWAPDOUBLE_CPY(&psShape->dfXMin, psSHP->pabyRec + 8 + 4);
    +        SHP_SWAPDOUBLE_CPY(&psShape->dfYMin, psSHP->pabyRec + 8 + 12);
    +        SHP_SWAPDOUBLE_CPY(&psShape->dfXMax, psSHP->pabyRec + 8 + 20);
    +        SHP_SWAPDOUBLE_CPY(&psShape->dfYMax, psSHP->pabyRec + 8 + 28);
    +#else
    +        memcpy(&psShape->dfXMin, psSHP->pabyRec + 8 + 4, 8);
    +        memcpy(&psShape->dfYMin, psSHP->pabyRec + 8 + 12, 8);
    +        memcpy(&psShape->dfXMax, psSHP->pabyRec + 8 + 20, 8);
    +        memcpy(&psShape->dfYMax, psSHP->pabyRec + 8 + 28, 8);
    +#endif
     
             /* -------------------------------------------------------------------- */
             /*      Extract part/point count, and build vertex and part arrays      */
    @@ -2208,10 +2172,10 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             uint32_t nParts;
             memcpy(&nParts, psSHP->pabyRec + 36 + 8, 4);
     
    -        if (bBigEndian)
    -            SwapWord(4, &nPoints);
    -        if (bBigEndian)
    -            SwapWord(4, &nParts);
    +#if defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(&nPoints);
    +        SHP_SWAP32(&nParts);
    +#endif
     
             /* nPoints and nParts are unsigned */
             if (/* nPoints < 0 || nParts < 0 || */
    @@ -2309,8 +2273,9 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             memcpy(psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts);
             for (int i = 0; STATIC_CAST(uint32_t, i) < nParts; i++)
             {
    -            if (bBigEndian)
    -                SwapWord(4, psShape->panPartStart + i);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAP32(psShape->panPartStart + i);
    +#endif
     
                 /* We check that the offset is inside the vertex array */
                 if (psShape->panPartStart[i] < 0 ||
    @@ -2355,8 +2320,9 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
                 memcpy(psShape->panPartType, psSHP->pabyRec + nOffset, 4 * nParts);
                 for (int i = 0; STATIC_CAST(uint32_t, i) < nParts; i++)
                 {
    -                if (bBigEndian)
    -                    SwapWord(4, psShape->panPartType + i);
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAP32(psShape->panPartType + i);
    +#endif
                 }
     
                 nOffset += 4 * nParts;
    @@ -2367,15 +2333,16 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             /* -------------------------------------------------------------------- */
             for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++)
             {
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAPDOUBLE_CPY(psShape->padfX + i,
    +                               psSHP->pabyRec + nOffset + i * 16);
    +            SHP_SWAPDOUBLE_CPY(psShape->padfY + i,
    +                               psSHP->pabyRec + nOffset + i * 16 + 8);
    +#else
                 memcpy(psShape->padfX + i, psSHP->pabyRec + nOffset + i * 16, 8);
    -
                 memcpy(psShape->padfY + i, psSHP->pabyRec + nOffset + i * 16 + 8,
                        8);
    -
    -            if (bBigEndian)
    -                SwapWord(8, psShape->padfX + i);
    -            if (bBigEndian)
    -                SwapWord(8, psShape->padfY + i);
    +#endif
             }
     
             nOffset += 16 * nPoints;
    @@ -2387,20 +2354,24 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
                 psShape->nSHPType == SHPT_ARCZ ||
                 psShape->nSHPType == SHPT_MULTIPATCH)
             {
    -            memcpy(&(psShape->dfZMin), psSHP->pabyRec + nOffset, 8);
    -            memcpy(&(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8);
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAPDOUBLE_CPY(&psShape->dfZMin, psSHP->pabyRec + nOffset);
    +            SHP_SWAPDOUBLE_CPY(&psShape->dfZMax, psSHP->pabyRec + nOffset + 8);
    +#else
    +            memcpy(&psShape->dfZMin, psSHP->pabyRec + nOffset, 8);
    +            memcpy(&psShape->dfZMax, psSHP->pabyRec + nOffset + 8, 8);
     
    -            if (bBigEndian)
    -                SwapWord(8, &(psShape->dfZMin));
    -            if (bBigEndian)
    -                SwapWord(8, &(psShape->dfZMax));
    +#endif
     
                 for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++)
                 {
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAPDOUBLE_CPY(psShape->padfZ + i,
    +                                   psSHP->pabyRec + nOffset + 16 + i * 8);
    +#else
                     memcpy(psShape->padfZ + i,
                            psSHP->pabyRec + nOffset + 16 + i * 8, 8);
    -                if (bBigEndian)
    -                    SwapWord(8, psShape->padfZ + i);
    +#endif
                 }
     
                 nOffset += 16 + 8 * nPoints;
    @@ -2418,20 +2389,23 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             /* -------------------------------------------------------------------- */
             if (nEntitySize >= STATIC_CAST(int, nOffset + 16 + 8 * nPoints))
             {
    -            memcpy(&(psShape->dfMMin), psSHP->pabyRec + nOffset, 8);
    -            memcpy(&(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8);
    -
    -            if (bBigEndian)
    -                SwapWord(8, &(psShape->dfMMin));
    -            if (bBigEndian)
    -                SwapWord(8, &(psShape->dfMMax));
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAPDOUBLE_CPY(&psShape->dfMMin, psSHP->pabyRec + nOffset);
    +            SHP_SWAPDOUBLE_CPY(&psShape->dfMMax, psSHP->pabyRec + nOffset + 8);
    +#else
    +            memcpy(&psShape->dfMMin, psSHP->pabyRec + nOffset, 8);
    +            memcpy(&psShape->dfMMax, psSHP->pabyRec + nOffset + 8, 8);
    +#endif
     
                 for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++)
                 {
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAPDOUBLE_CPY(psShape->padfM + i,
    +                                   psSHP->pabyRec + nOffset + 16 + i * 8);
    +#else
                     memcpy(psShape->padfM + i,
                            psSHP->pabyRec + nOffset + 16 + i * 8, 8);
    -                if (bBigEndian)
    -                    SwapWord(8, psShape->padfM + i);
    +#endif
                 }
                 psShape->bMeasureIsUsed = TRUE;
             }
    @@ -2462,8 +2436,9 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             uint32_t nPoints;
             memcpy(&nPoints, psSHP->pabyRec + 44, 4);
     
    -        if (bBigEndian)
    -            SwapWord(4, &nPoints);
    +#if defined(SHP_BIG_ENDIAN)
    +        SHP_SWAP32(&nPoints);
    +#endif
     
             /* nPoints is unsigned */
             if (/* nPoints < 0 || */ nPoints > 50 * 1000 * 1000)
    @@ -2536,13 +2511,15 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
     
             for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++)
             {
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAPDOUBLE_CPY(psShape->padfX + i,
    +                               psSHP->pabyRec + 48 + 16 * i);
    +            SHP_SWAPDOUBLE_CPY(psShape->padfY + i,
    +                               psSHP->pabyRec + 48 + 16 * i + 8);
    +#else
                 memcpy(psShape->padfX + i, psSHP->pabyRec + 48 + 16 * i, 8);
                 memcpy(psShape->padfY + i, psSHP->pabyRec + 48 + 16 * i + 8, 8);
    -
    -            if (bBigEndian)
    -                SwapWord(8, psShape->padfX + i);
    -            if (bBigEndian)
    -                SwapWord(8, psShape->padfY + i);
    +#endif
             }
     
             int nOffset = 48 + 16 * nPoints;
    @@ -2550,39 +2527,40 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             /* -------------------------------------------------------------------- */
             /*      Get the X/Y bounds.                                             */
             /* -------------------------------------------------------------------- */
    -        memcpy(&(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8);
    -        memcpy(&(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8);
    -        memcpy(&(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8);
    -        memcpy(&(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8);
    -
    -        if (bBigEndian)
    -            SwapWord(8, &(psShape->dfXMin));
    -        if (bBigEndian)
    -            SwapWord(8, &(psShape->dfYMin));
    -        if (bBigEndian)
    -            SwapWord(8, &(psShape->dfXMax));
    -        if (bBigEndian)
    -            SwapWord(8, &(psShape->dfYMax));
    +#if defined(SHP_BIG_ENDIAN)
    +        SHP_SWAPDOUBLE_CPY(&psShape->dfXMin, psSHP->pabyRec + 8 + 4);
    +        SHP_SWAPDOUBLE_CPY(&psShape->dfYMin, psSHP->pabyRec + 8 + 12);
    +        SHP_SWAPDOUBLE_CPY(&psShape->dfXMax, psSHP->pabyRec + 8 + 20);
    +        SHP_SWAPDOUBLE_CPY(&psShape->dfYMax, psSHP->pabyRec + 8 + 28);
    +#else
    +        memcpy(&psShape->dfXMin, psSHP->pabyRec + 8 + 4, 8);
    +        memcpy(&psShape->dfYMin, psSHP->pabyRec + 8 + 12, 8);
    +        memcpy(&psShape->dfXMax, psSHP->pabyRec + 8 + 20, 8);
    +        memcpy(&psShape->dfYMax, psSHP->pabyRec + 8 + 28, 8);
    +#endif
     
             /* -------------------------------------------------------------------- */
             /*      If we have a Z coordinate, collect that now.                    */
             /* -------------------------------------------------------------------- */
             if (psShape->nSHPType == SHPT_MULTIPOINTZ)
             {
    -            memcpy(&(psShape->dfZMin), psSHP->pabyRec + nOffset, 8);
    -            memcpy(&(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8);
    -
    -            if (bBigEndian)
    -                SwapWord(8, &(psShape->dfZMin));
    -            if (bBigEndian)
    -                SwapWord(8, &(psShape->dfZMax));
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAPDOUBLE_CPY(&psShape->dfZMin, psSHP->pabyRec + nOffset);
    +            SHP_SWAPDOUBLE_CPY(&psShape->dfZMax, psSHP->pabyRec + nOffset + 8);
    +#else
    +            memcpy(&psShape->dfZMin, psSHP->pabyRec + nOffset, 8);
    +            memcpy(&psShape->dfZMax, psSHP->pabyRec + nOffset + 8, 8);
    +#endif
     
                 for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++)
                 {
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAPDOUBLE_CPY(psShape->padfZ + i,
    +                                   psSHP->pabyRec + nOffset + 16 + i * 8);
    +#else
                     memcpy(psShape->padfZ + i,
                            psSHP->pabyRec + nOffset + 16 + i * 8, 8);
    -                if (bBigEndian)
    -                    SwapWord(8, psShape->padfZ + i);
    +#endif
                 }
     
                 nOffset += 16 + 8 * nPoints;
    @@ -2598,20 +2576,23 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             /* -------------------------------------------------------------------- */
             if (nEntitySize >= STATIC_CAST(int, nOffset + 16 + 8 * nPoints))
             {
    -            memcpy(&(psShape->dfMMin), psSHP->pabyRec + nOffset, 8);
    -            memcpy(&(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8);
    -
    -            if (bBigEndian)
    -                SwapWord(8, &(psShape->dfMMin));
    -            if (bBigEndian)
    -                SwapWord(8, &(psShape->dfMMax));
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAPDOUBLE_CPY(&psShape->dfMMin, psSHP->pabyRec + nOffset);
    +            SHP_SWAPDOUBLE_CPY(&psShape->dfMMax, psSHP->pabyRec + nOffset + 8);
    +#else
    +            memcpy(&psShape->dfMMin, psSHP->pabyRec + nOffset, 8);
    +            memcpy(&psShape->dfMMax, psSHP->pabyRec + nOffset + 8, 8);
    +#endif
     
                 for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++)
                 {
    +#if defined(SHP_BIG_ENDIAN)
    +                SHP_SWAPDOUBLE_CPY(psShape->padfM + i,
    +                                   psSHP->pabyRec + nOffset + 16 + i * 8);
    +#else
                     memcpy(psShape->padfM + i,
                            psSHP->pabyRec + nOffset + 16 + i * 8, 8);
    -                if (bBigEndian)
    -                    SwapWord(8, psShape->padfM + i);
    +#endif
                 }
                 psShape->bMeasureIsUsed = TRUE;
             }
    @@ -2655,13 +2636,13 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
                 SHPDestroyObject(psShape);
                 return SHPLIB_NULLPTR;
             }
    +#if defined(SHP_BIG_ENDIAN)
    +        SHP_SWAPDOUBLE_CPY(psShape->padfX, psSHP->pabyRec + 12);
    +        SHP_SWAPDOUBLE_CPY(psShape->padfY, psSHP->pabyRec + 20);
    +#else
             memcpy(psShape->padfX, psSHP->pabyRec + 12, 8);
             memcpy(psShape->padfY, psSHP->pabyRec + 20, 8);
    -
    -        if (bBigEndian)
    -            SwapWord(8, psShape->padfX);
    -        if (bBigEndian)
    -            SwapWord(8, psShape->padfY);
    +#endif
     
             int nOffset = 20 + 8;
     
    @@ -2670,10 +2651,11 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             /* -------------------------------------------------------------------- */
             if (psShape->nSHPType == SHPT_POINTZ)
             {
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAPDOUBLE_CPY(psShape->padfZ, psSHP->pabyRec + nOffset);
    +#else
                 memcpy(psShape->padfZ, psSHP->pabyRec + nOffset, 8);
    -
    -            if (bBigEndian)
    -                SwapWord(8, psShape->padfZ);
    +#endif
     
                 nOffset += 8;
             }
    @@ -2686,10 +2668,11 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity)
             /* -------------------------------------------------------------------- */
             if (nEntitySize >= nOffset + 8)
             {
    +#if defined(SHP_BIG_ENDIAN)
    +            SHP_SWAPDOUBLE_CPY(psShape->padfM, psSHP->pabyRec + nOffset);
    +#else
                 memcpy(psShape->padfM, psSHP->pabyRec + nOffset, 8);
    -
    -            if (bBigEndian)
    -                SwapWord(8, psShape->padfM);
    +#endif
                 psShape->bMeasureIsUsed = TRUE;
             }
     
    @@ -2936,8 +2919,9 @@ static int SHPRewindIsInnerRing(const SHPObject *psObject, int iOpRing,
     /*      specification.                                                  */
     /************************************************************************/
     
    -int SHPAPI_CALL SHPRewindObject(CPL_UNUSED SHPHandle hSHP, SHPObject *psObject)
    +int SHPAPI_CALL SHPRewindObject(const SHPHandle hSHP, SHPObject *psObject)
     {
    +    (void)hSHP;
         /* -------------------------------------------------------------------- */
         /*      Do nothing if this is not a polygon object.                     */
         /* -------------------------------------------------------------------- */
    
    From 6e319e82ea514b50a2747de5a34ac5449836d877 Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Thu, 15 Aug 2024 19:45:38 -0600
    Subject: [PATCH 114/132] add fix & test for humminbird route writer. (#1324)
    
    The missing initialization was introduced in 824e01d.
    ---
     humminbird.cc                           |   2 +-
     reference/route/humminbird_gpsbabel.hwr | Bin 0 -> 3504 bytes
     testo.d/humminbird.test                 |  16 ++++++++++++++++
     3 files changed, 17 insertions(+), 1 deletion(-)
     create mode 100644 reference/route/humminbird_gpsbabel.hwr
    
    diff --git a/humminbird.cc b/humminbird.cc
    index 3d66cc058..f829cc796 100644
    --- a/humminbird.cc
    +++ b/humminbird.cc
    @@ -805,7 +805,7 @@ HumminbirdFormat::humminbird_rte_head(const route_head* rte)
     {
       humrte = nullptr;
       if (!rte->rte_waypt_empty()) {
    -    humrte = new humminbird_rte_t;
    +    humrte = new humminbird_rte_t();
       }
     }
     
    diff --git a/reference/route/humminbird_gpsbabel.hwr b/reference/route/humminbird_gpsbabel.hwr
    new file mode 100644
    index 0000000000000000000000000000000000000000..f2f5a2bbad0d11454615f63f0c71eee7f639f86a
    GIT binary patch
    literal 3504
    zcmcJRTWnNC7{@=_Qb6TSvB<4OETuquE<1B}DHnI?c3XP7v)xMpWh0lEs4qYwUS3tK
    zKA?#YUg84@A<=k^`e1xC;-xWB9v}pKGHEm@i4WQ+YO?-k&YbC)^_fZ9rtNRP@BdwA
    zT3To`;mpI=uK5$MH>TVzBqmNWhjaONd0Hd`Kr(}!hZ~J4=N6a?U;+iiOp9h_-`wAr
    z@}33r1amUBoz|qUf!|3~k25#rS$5iDU-cIFVk9PyF_+nP<{PH9G1Y&L!~>U^=cOz=
    z?H2PciTXI0jKwUlm>Cj>mov||<60OoQGT39;Oi{&nC)wkwsT|p3^cDIaqtqDwB_p#
    z%g$NYd5L-4wsWV^(*`@opyzoofuk*{THIwZpMdF>409rHidk&w`J2RpSD6=ZS9?>;
    zk|g790CPbyzMHVKH0jF?;OlcRc3jI0GavnP6?uM|d1*V(%OghT@CJz^A@hUO@Mt+N
    zy(v8_jGcDaSwrGzFBrS-D`Q6Xp}!YBc7{8S&8$lL@?mEpFPU6eoAcFSG1DYUE_dA2
    zcs@HM4ro2AEni?NUEFEvpSxqGzNj(9UL_%BxWoJ?gW67~Vdgca_%QUm&70?Ijm7K+
    zGYiJgJ?jhuJ;7f8JXwQ7l{2h
    zcYWPq+Si7dk#m}Q8O${>ww{fKk@%PfiejssR2^c$v_r{Eji=$qLZgDTL_YXE=wCn0JheyHu`#`^VJ@zMvFD;k
    zGio0O{n!cLb1!Y@aEry{u@iQJvFp{FWcYQ=*A+1Kd~HqY2?X?<;$Fs%z0WY1FaJD=
    zV{P2`Y|YyYvjFwNd>s+oZ`yU+4Ffx@7jt?ZOyKD(s#)G)F{i+MB$+re#q=8nzW7NJ
    z56y7DsaFRKgIcf-5`()r_w8OqMice=n8f%+o(b&ypeq%lYQfi%2(R!=Q+}Xd+mU)|
    z(A=NPXUkn9qhT2DC{!k5oUg&8VP`s*55xRqVz)q@WTIW?KZ;o{VYk@5%3?cpd4FBP
    z?!Ab6hv&+pLj`Opl^=XU>%m@ieubWl+=mu}3Tp=Q#j)or*SVW^_mxGZ5^F|<=NN{#
    z#7XX?Jc~iL=HYIZ2Ri}x^5MURvgNT65r!q9_3Q+Ldv36^j=hm;hp(I5_1q!sO!+yb
    zdC)M3%iW9_oMCQ|v6x+kL0sM;^z%99Wo%}*VdP!F5c@J2yJcsOVPvnm=%1(1W4^`g
    zH4NsIeTu!Y8vBP?%>7`XA8|qRjz2M{?-#PwymeP*4TF1m;5X!FRx!G&D)yXVd7IhLLfBIr@rXbhj!7+0=SuA3B)Ro09SLW>pM&WR6MiLI3=s7(E$^8IG8!
    z4>|G^ekK{To;r#tXgliN!kz>3hh*YrRm@22%lQU+K14r%hdU(*MM1V$RQJ)Ooq@}!
    z`(?cA(#32sUqbGbo&B+$x_sOGj2sr_yG7(G)hzO&n6acCy!nLaDP@b*k@CLmWIPub
    zMiqPX*21nk^dsI{Ua3|tg)uX3e92nKdOd?TNpJwMm1E6C!$42}HPq`d%wVQ068((c
    z*Ljw93SheA`^RERG2?uNxK5BLcQS|B%!FaSL=M%xQyIzUOT!|R!=qw{Fzrj;DI=)q
    zlNFII<-|dm=7>SY=VEue(LW_Q7nN!`pGC~dPBmhpx(~cTqP7RMNL6a%YWVrsE3
    zSyN{nW_can*iJQDLS)69-$GD7oY0@9OwepfT#8m9&cR_J^<%)u@%K)JCJU
    zh(cOIi)lYCrDe37R#1idXglqIMUQ%ED{Y}3+C<&7k-BIDt*6zn)B%eH!j_GW(jfze
    nZ27Hx;`HMW>w8B2u1*zRZ}U+)l!Al~qf$E`q
    Date: Sat, 17 Aug 2024 11:37:13 -0600
    Subject: [PATCH 115/132] simplify osm_tag option processing. (#1325)
    
    I suspect the check of "tagnd" was used in developement before
    opt_tagnd was added.  The only thing the check did was ignore
    opt_tag values that started with tagnd, they weren't used elsewhere.
    ---
     osm.cc | 4 +---
     1 file changed, 1 insertion(+), 3 deletions(-)
    
    diff --git a/osm.cc b/osm.cc
    index f24f0ee49..bb0c62db3 100644
    --- a/osm.cc
    +++ b/osm.cc
    @@ -835,9 +835,7 @@ OsmFormat::osm_rte_disp_trail(const route_head* route)
       osm_write_tag("name", route->rte_name);
       osm_write_tag("note", route->rte_desc);
     
    -  if (opt_tag && (case_ignore_strncmp(opt_tag, "tagnd", 5) != 0)) {
    -    osm_write_opt_tag(opt_tag);
    -  }
    +  osm_write_opt_tag(opt_tag);
     
       fout->writeEndElement(); // way
     }
    
    From 9ba244b2bd78803c8b25b953c7ace8c3a40c36c3 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?=E7=A9=8D=E4=B8=B9=E5=B0=BC=20Dan=20Jacobson?=
     
    Date: Mon, 19 Aug 2024 06:24:12 +0800
    Subject: [PATCH 116/132] Zap repeated examples (#1084)
    
    On https://www.gpsbabel.org/htmldoc-development/fmt_globalsat.html
    we observe these two examples are repeated further down, in context too. So they shouldn't also
    appear higher up.
    
    I am guessing that I have correctly zapped the higher up pair.
    
    Co-authored-by: Robert Lipe
    ---
     xmldoc/formats/globalsat.xml | 10 ----------
     1 file changed, 10 deletions(-)
    
    diff --git a/xmldoc/formats/globalsat.xml b/xmldoc/formats/globalsat.xml
    index b25fb655a..c46243e09 100644
    --- a/xmldoc/formats/globalsat.xml
    +++ b/xmldoc/formats/globalsat.xml
    @@ -9,16 +9,6 @@ USB cable to your computer and the device will show up as a serial device.
     
    -gpsbabel -i globalsat -f /dev/ttyUSB0 -o gpx,garminextensions -F outfile.gpx
    -
    -  Command showing list of tracks on device
    -  gpsbabel -i globalsat,showlist=1 -f /dev/ttyUSB0
    -
    -
    -  Command track can be used to fetch a single track, default is all tracks
    -  gpsbabel -i globalsat,track=number -f /dev/ttyUSB0 -o gpx,garminextensions -F outfile.gpx
    -
    -
     
       The gh625XT USB cable provides a physical USB interface to the host computer, but
       internally it uses a Prolific PL-2303 chip to do this.  So you must have
    
    From 9a74671b96a3374694f0e7a6564555918bb00b2f Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Mon, 19 Aug 2024 16:47:13 -0600
    Subject: [PATCH 117/132] clang-tidy-18 fixes
     performance-unnecessary-copy-initialization (#1328)
    
    ---
     garmin_txt.cc | 2 +-
     gdb.cc        | 4 ++--
     geo.cc        | 2 +-
     geojson.cc    | 2 +-
     gpx.cc        | 2 +-
     kml.cc        | 6 +++---
     unicsv.cc     | 2 +-
     vcf.cc        | 2 +-
     xcsv.cc       | 4 ++--
     9 files changed, 13 insertions(+), 13 deletions(-)
    
    diff --git a/garmin_txt.cc b/garmin_txt.cc
    index 07fd83051..8a8760a63 100644
    --- a/garmin_txt.cc
    +++ b/garmin_txt.cc
    @@ -494,7 +494,7 @@ GarminTxtFormat::write_waypt(const Waypoint* wpt)
       print_string("%s\t", (country != nullptr) ? country : "");
       print_date_and_time(wpt->GetCreationTime().toTime_t(), false);
       if (wpt->HasUrlLink()) {
    -    UrlLink l = wpt->GetUrlLink();
    +    const UrlLink& l = wpt->GetUrlLink();
         print_string("%s\t", l.url_);
       } else {
         print_string("%s\t", "");
    diff --git a/gdb.cc b/gdb.cc
    index ca276ce86..7cd965ed6 100644
    --- a/gdb.cc
    +++ b/gdb.cc
    @@ -1235,7 +1235,7 @@ GdbFormat::write_waypoint(
         FWRITE(zbuf, 4);
         QString ld;
         if (wpt->HasUrlLink()) {
    -      UrlLink l = wpt->GetUrlLink();
    +      const UrlLink& l = wpt->GetUrlLink();
           ld = l.url_;
         }
         QString descr = (wpt_class < gt_waypt_class_map_point) ?
    @@ -1526,7 +1526,7 @@ GdbFormat::write_waypoint_cb(const Waypoint* refpt)
       Waypoint* test = gdb_find_wayptq(waypt_nameposn_out_hash, refpt);
     
       if (refpt->HasUrlLink() && test && test->HasUrlLink() && route_flag == 0) {
    -    UrlLink orig_link = refpt->GetUrlLink();
    +    const UrlLink& orig_link = refpt->GetUrlLink();
         UrlLink test_link = test->GetUrlLink();
         if (orig_link.url_ != test_link.url_) {
           test = nullptr;
    diff --git a/geo.cc b/geo.cc
    index 9baaa5d57..15eab8623 100644
    --- a/geo.cc
    +++ b/geo.cc
    @@ -154,7 +154,7 @@ void GeoFormat::geo_waypt_pr(const Waypoint* waypointp, QXmlStreamWriter& writer
       if (waypointp->HasUrlLink()) {
         writer.writeStartElement(QStringLiteral("link"));
         writer.writeAttribute(QStringLiteral("text "), QStringLiteral("Cache Details"));
    -    UrlLink link = waypointp->GetUrlLink();
    +    const UrlLink& link = waypointp->GetUrlLink();
         writer.writeCharacters(link.url_);
         writer.writeEndElement();
       }
    diff --git a/geojson.cc b/geojson.cc
    index 6c5e60c51..c6dc6eb0a 100644
    --- a/geojson.cc
    +++ b/geojson.cc
    @@ -73,7 +73,7 @@ GeoJsonFormat::geojson_waypt_pr(const Waypoint* waypoint) const
         properties[DESCRIPTION] = waypoint->description;
       }
       if (waypoint->HasUrlLink()) {
    -    UrlLink link = waypoint->GetUrlLink();
    +    const UrlLink& link = waypoint->GetUrlLink();
         if (!link.url_.isEmpty()) {
           properties[URL] = link.url_;
         }
    diff --git a/gpx.cc b/gpx.cc
    index 45430bdb5..96af32faa 100644
    --- a/gpx.cc
    +++ b/gpx.cc
    @@ -1232,7 +1232,7 @@ GpxFormat::write_gpx_url(const UrlList& urls) const
           }
         }
       } else {
    -    UrlLink l = urls.GetUrlLink();
    +    const UrlLink& l = urls.GetUrlLink();
         if (!l.url_.isEmpty()) {
           writer->writeTextElement(QStringLiteral("url"), QString(urlbase) + l.url_);
           writer->writeOptionalTextElement(QStringLiteral("urlname"), l.url_link_text_);
    diff --git a/kml.cc b/kml.cc
    index ae27864b0..7cd37e57f 100644
    --- a/kml.cc
    +++ b/kml.cc
    @@ -1319,7 +1319,7 @@ void KmlFormat::kml_geocache_pr(const Waypoint* waypointp) const
     
       writer->writeStartElement(QStringLiteral("name"));
       if (waypointp->HasUrlLink()) {
    -    UrlLink link = waypointp->GetUrlLink();
    +    const UrlLink& link = waypointp->GetUrlLink();
         writer->writeCDATA(link.url_link_text_);
       }
       writer->writeEndElement(); // Close name tag
    @@ -1347,7 +1347,7 @@ void KmlFormat::kml_geocache_pr(const Waypoint* waypointp) const
       }
     
       if (waypointp->HasUrlLink()) {
    -    UrlLink link = waypointp->GetUrlLink();
    +    const UrlLink& link = waypointp->GetUrlLink();
         kml_write_data_element("gc_name", link.url_link_text_);
       }
     
    @@ -1422,7 +1422,7 @@ void KmlFormat::kml_waypt_pr(const Waypoint* waypointp) const
       // Description
       if (waypointp->HasUrlLink()) {
         writer->writeEmptyElement(QStringLiteral("snippet"));
    -    UrlLink link = waypointp->GetUrlLink();
    +    const UrlLink& link = waypointp->GetUrlLink();
         if (!link.url_link_text_.isEmpty()) {
           QString odesc = link.url_;
           QString olink = link.url_link_text_;
    diff --git a/unicsv.cc b/unicsv.cc
    index 84800e98e..2c4cbbe6d 100644
    --- a/unicsv.cc
    +++ b/unicsv.cc
    @@ -1543,7 +1543,7 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt)
         if (!wpt->HasUrlLink()) {
           unicsv_print_str("");
         } else {
    -      UrlLink l = wpt->GetUrlLink();
    +      const UrlLink& l = wpt->GetUrlLink();
           unicsv_print_str(l.url_);
         }
       }
    diff --git a/vcf.cc b/vcf.cc
    index 4775e753f..ea3368650 100644
    --- a/vcf.cc
    +++ b/vcf.cc
    @@ -97,7 +97,7 @@ VcfFormat::vcf_disp(const Waypoint* wpt)
       gbfprintf(file_out, "ADR:%c%d %06.3f %c%d %06.3f\n", wpt->latitude < 0 ? 'S' : 'N',  abs(latint), 60.0 * (fabs(wpt->latitude) - latint), wpt->longitude < 0 ? 'W' : 'E', abs(lonint), 60.0 * (fabs(wpt->longitude) - lonint));
     
       if (wpt->HasUrlLink()) {
    -    UrlLink link = wpt->GetUrlLink();
    +    const UrlLink& link = wpt->GetUrlLink();
         gbfprintf(file_out, "URL:%s\n", CSTR(link.url_));
       }
     
    diff --git a/xcsv.cc b/xcsv.cc
    index afc3cf373..b1cc09112 100644
    --- a/xcsv.cc
    +++ b/xcsv.cc
    @@ -1118,7 +1118,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
             buff = xcsv_urlbase;
           }
           if (wpt->HasUrlLink()) {
    -        UrlLink l = wpt->GetUrlLink();
    +        const UrlLink& l = wpt->GetUrlLink();
             buff += QString::asprintf(fmp.printfc.constData(), CSTR(l.url_));
           } else {
             buff += QString::asprintf(fmp.printfc.constData(), fmp.val.constData() && *fmp.val.constData() ? fmp.val.constData() : "\"\"");
    @@ -1127,7 +1127,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
         break;
         case XcsvStyle::XT_URL_LINK_TEXT:
           if (wpt->HasUrlLink()) {
    -        UrlLink l = wpt->GetUrlLink();
    +        const UrlLink& l = wpt->GetUrlLink();
             buff = QString::asprintf(fmp.printfc.constData(),
                                      !l.url_link_text_.isEmpty() ? CSTR(l.url_link_text_) : fmp.val.constData());
           }
    
    From 5a08554b7b57802ed6f7870df6bb0ddc43c97e8f Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Mon, 19 Aug 2024 17:33:07 -0600
    Subject: [PATCH 118/132] Humminbirdhash (#1327)
    
    * refactor humminbird handling of wpt numbers.
    
    also:
    convert some macros to constexpr.
    consistenly use strncpy to move strings to humminbird char arrays.`
    
    * fix clang-diagnostic-missing-field-initializers
    ---
     defs.h        |  3 ---
     humminbird.cc | 73 ++++++++++++++++++++++-----------------------------
     humminbird.h  | 15 +++++++++--
     util.cc       | 27 -------------------
     4 files changed, 45 insertions(+), 73 deletions(-)
    
    diff --git a/defs.h b/defs.h
    index 906bd9a61..d50e49429 100644
    --- a/defs.h
    +++ b/defs.h
    @@ -1013,9 +1013,6 @@ enum grid_type {
     #define GRID_INDEX_MIN	grid_lat_lon_ddd
     #define GRID_INDEX_MAX	grid_swiss
     
    -void* gb_int2ptr(int i);
    -int gb_ptr2int(const void* p);
    -
     QTextCodec* get_codec(const QByteArray& cs_name);
     void list_codecs();
     void list_timezones();
    diff --git a/humminbird.cc b/humminbird.cc
    index f829cc796..e6f7505f5 100644
    --- a/humminbird.cc
    +++ b/humminbird.cc
    @@ -21,13 +21,13 @@
     
     #include "humminbird.h"
     
    -#include                  // for QMap
    +#include                 // for QHash
     #include                    // for CaseInsensitive
     #include              // for qRound
     
     #include                 // for atan, tan, log, sinh
    -#include                // for snprintf, SEEK_SET
    -#include               // for strncpy, memcpy, memset
    +#include                // for SEEK_SET
    +#include               // for strncpy
     #include               // for inv_pi, pi
     
     #include "defs.h"               // for Waypoint, be_read32, be_read16, be_write32, fatal, be_write16, route_head, track_add_wpt
    @@ -62,10 +62,6 @@ Still, they're useful in the code as a plain signature.
     #define WPT_MAGIC2		0x02030024L // New for 2013.  No visible diff?!
     #define RTE_MAGIC		0x03030088L
     
    -#define EAST_SCALE		20038297.0 /* this is i1924_equ_axis*pi */
    -#define i1924_equ_axis		6378388.0
    -#define i1924_polar_axis	6356911.946
    -
     #define BAD_CHARS		"\r\n\t"
     
     /* The hwr data format is records-based, and the records are 36 bytes long. */
    @@ -172,8 +168,6 @@ struct HumminbirdBase::group_body_t {
     double
     HumminbirdBase::geodetic_to_geocentric_hwr(const double gd_lat)
     {
    -  constexpr double cos_ae = 0.9966349016452;
    -  constexpr double cos2_ae = cos_ae * cos_ae;
       const double gdr = gd_lat * std::numbers::pi / 180.0;
     
       return atan(cos2_ae * tan(gdr)) * 180.0 * std::numbers::inv_pi;
    @@ -184,8 +178,6 @@ HumminbirdBase::geodetic_to_geocentric_hwr(const double gd_lat)
     double
     HumminbirdBase::geocentric_to_geodetic_hwr(const double gc_lat)
     {
    -  constexpr double cos_ae = 0.9966349016452;
    -  constexpr double cos2_ae = cos_ae * cos_ae;
       const double gcr = gc_lat * std::numbers::pi / 180.0;
     
       return atan(tan(gcr)/cos2_ae) * 180.0 * std::numbers::inv_pi;
    @@ -218,6 +210,8 @@ void
     HumminbirdBase::humminbird_rd_init(const QString& fname)
     {
       fin_ = gbfopen_be(fname, "rb", MYNAME);
    +
    +  wpt_num_to_wpt_hash.clear();
     }
     
     void
    @@ -229,7 +223,7 @@ HumminbirdBase::humminbird_rd_deinit() const
     void
     HumminbirdBase::humminbird_read_wpt(gbfile* fin)
     {
    -  humminbird_waypt_t w{0};
    +  humminbird_waypt_t w{};
     
       if (! gbfread(&w, 1, sizeof(w), fin)) {
         fatal(MYNAME ": Unexpected end of file!\n");
    @@ -275,6 +269,8 @@ HumminbirdBase::humminbird_read_wpt(gbfile* fin)
       case 2: // Waypoint temporary.
       case 3: // Waypoint man-overboard.
         waypt_add(wpt);
    +    /* register the point over his internal Humminbird "Number" */
    +    wpt_num_to_wpt_hash[w.num] = wpt;
         break;
       case 16: // Waypoint group header.
       case 17: // Waypoint group body.
    @@ -283,17 +279,13 @@ HumminbirdBase::humminbird_read_wpt(gbfile* fin)
         delete wpt;
         break;
       }
    -
    -  /* register the point over his internal Humminbird "Number" */
    -  QString buff = QString::number(w.num);
    -  map[buff] = wpt;
     }
     
     void
     HumminbirdBase::humminbird_read_route(gbfile* fin) const
     {
     
    -  humminbird_rte_t hrte{0};
    +  humminbird_rte_t hrte{};
     
       if (! gbfread(&hrte, 1, sizeof(hrte), fin)) {
         fatal(MYNAME ": Unexpected end of file!\n");
    @@ -306,13 +298,10 @@ HumminbirdBase::humminbird_read_route(gbfile* fin) const
         route_head* rte = nullptr;
     
         for (int i = 0; i < hrte.count; i++) {
    -      char buff[10];
           hrte.points[i] = be_read16(&hrte.points[i]);
     
           /* locate the point over his internal Humminbird "Number" */
    -      snprintf(buff, sizeof(buff), "%d", hrte.points[i]);
    -      if ((map.value(buff))) {
    -        const Waypoint* wpt = map.value(buff);
    +      if (const Waypoint* wpt = wpt_num_to_wpt_hash.value(hrte.points[i], nullptr); wpt != nullptr) {
             if (rte == nullptr) {
               rte = new route_head;
               route_add_head(rte);
    @@ -328,7 +317,7 @@ void
     HumminbirdBase::humminbird_read_track(gbfile* fin)
     {
     
    -  humminbird_trk_header_t th{0};
    +  humminbird_trk_header_t th{};
     
       if (! gbfread(&th, 1, sizeof(th), fin)) {
         fatal(MYNAME ": Unexpected end of file reading header!\n");
    @@ -436,7 +425,7 @@ void
     HumminbirdBase::humminbird_read_track_old(gbfile* fin)
     {
     
    -  humminbird_trk_header_old_t th{0};
    +  humminbird_trk_header_old_t th{};
       constexpr int file_len = 8048;
       char namebuf[TRK_NAME_LEN];
     
    @@ -601,6 +590,8 @@ HumminbirdBase::humminbird_wr_init(const QString& fname)
     
       waypoint_num = 0;
       rte_num_ = 0;
    +
    +  wpt_id_to_wpt_num_hash.clear();
     }
     
     void
    @@ -618,7 +609,7 @@ HumminbirdBase::humminbird_wr_deinit()
     void
     HumminbirdFormat::humminbird_write_waypoint(const Waypoint* wpt)
     {
    -  humminbird_waypt_t hum{0};
    +  humminbird_waypt_t hum{};
       int num_icons = std::size(humminbird_icons);
     
       be_write16(&hum.num, waypoint_num++);
    @@ -660,8 +651,7 @@ HumminbirdFormat::humminbird_write_waypoint(const Waypoint* wpt)
       QString name = (global_opts.synthesize_shortnames)
                      ? wptname_sh->mkshort_from_wpt(wpt)
                      : wptname_sh->mkshort(wpt->shortname);
    -  memset(&hum.name, 0, sizeof(hum.name));
    -  memcpy(&hum.name, CSTR(name), name.length());
    +  strncpy(hum.name, CSTR(name), sizeof(hum.name)-1);
     
       gbfputuint32(WPT_MAGIC, fout_);
       gbfwrite(&hum, sizeof(hum), 1, fout_);
    @@ -837,19 +827,29 @@ HumminbirdFormat::humminbird_rte_tail(const route_head* rte)
       humrte = nullptr;
     }
     
    +QString HumminbirdFormat::wpt_to_id(const Waypoint* wpt)
    +{
    +  QString id = QStringLiteral("%1\01%2\01%3").arg(wpt->shortname)
    +                .arg(wpt->latitude, 0, 'f', 9).arg(wpt->longitude, 0, 'f', 9);
    +  return id;
    +}
    +
     void
     HumminbirdFormat::humminbird_write_rtept(const Waypoint* wpt) const
     {
       if (humrte == nullptr) {
         return;
       }
    -  int i = gb_ptr2int(wpt->extra_data);
    -  if (i <= 0) {
    +  QString id = wpt_to_id(wpt);
    +
    +  if (!wpt_id_to_wpt_num_hash.contains(id)) {
    +    // This should not occur, we just scanned all waypoints and routes.
    +    warning("Missing waypoint reference in route, point dropped from route.");
         return;
       }
     
       if (humrte->count < MAX_RTE_POINTS) {
    -    humrte->points[humrte->count] = i - 1;
    +    humrte->points[humrte->count] = wpt_id_to_wpt_num_hash.value(id);
         humrte->count++;
       } else {
         warning(MYNAME ": Sorry, routes are limited to %d points!\n", MAX_RTE_POINTS);
    @@ -860,19 +860,10 @@ HumminbirdFormat::humminbird_write_rtept(const Waypoint* wpt) const
     void
     HumminbirdFormat::humminbird_write_waypoint_wrapper(const Waypoint* wpt)
     {
    -  Waypoint* tmpwpt;
    -
    -  QString key = QStringLiteral("%1\01%2\01%3").arg(wpt->shortname)
    -                .arg(wpt->latitude, 0, 'f', 9).arg(wpt->longitude, 0, 'f', 9);
    -  if (!(tmpwpt = map[key])) {
    -    tmpwpt = const_cast(wpt);
    -    map[key] = const_cast(wpt);
    -    tmpwpt->extra_data = gb_int2ptr(waypoint_num + 1);	/* NOT NULL */
    +  QString id = wpt_to_id(wpt);
    +  if (!wpt_id_to_wpt_num_hash.contains(id)) {
    +    wpt_id_to_wpt_num_hash[id] = waypoint_num;
         humminbird_write_waypoint(wpt);
    -  } else {
    -    void* p = tmpwpt->extra_data;
    -    tmpwpt = const_cast(wpt);
    -    tmpwpt->extra_data = p;
       }
     }
     
    diff --git a/humminbird.h b/humminbird.h
    index 17f0c44c8..ebc34d9da 100644
    --- a/humminbird.h
    +++ b/humminbird.h
    @@ -21,7 +21,7 @@
     #ifndef HUMMINBIRD_H_INCLUDED_
     #define HUMMINBIRD_H_INCLUDED_
     
    -#include       // for QMap
    +#include      // for QHash
     #include    // for QString
     #include    // for QVector
     
    @@ -49,6 +49,15 @@ class HumminbirdBase
     
       /* Constants */
     
    +  // constants related to position conversions.
    +  static constexpr double i1924_equ_axis = 6378388.0;
    +  static constexpr double EAST_SCALE = 20038297.0; /* this is i1924_equ_axis*pi */
    +  // static constexpr double i1924_polar_axis = 6356911.946;
    +  // We use a modified international 1924 ellipse with a different flattening,
    +  // defined by cos_ae = cos(angular eccentricity).
    +  static constexpr double cos_ae = 0.9966349016452;
    +  static constexpr double cos2_ae = cos_ae * cos_ae;
    +
       static constexpr const char* humminbird_icons[] = {
         "Normal",       /*  0 */
         "House",        /*  1 */
    @@ -108,7 +117,8 @@ class HumminbirdBase
       MakeShort* trkname_sh{};
       humminbird_rte_t* humrte{};
       int rte_num_{};
    -  QMap map;
    +  QHash wpt_num_to_wpt_hash;
    +  QHash wpt_id_to_wpt_num_hash;
     
       humminbird_trk_header_t* trk_head{};
       humminbird_trk_point_t* trk_points{};
    @@ -151,6 +161,7 @@ class HumminbirdFormat : public Format, private HumminbirdBase
     
       void humminbird_rte_head(const route_head* rte);
       void humminbird_rte_tail(const route_head* rte);
    +  static QString wpt_to_id(const Waypoint*);
       void humminbird_write_rtept(const Waypoint* wpt) const;
       void humminbird_write_waypoint(const Waypoint* wpt);
       void humminbird_write_waypoint_wrapper(const Waypoint* wpt);
    diff --git a/util.cc b/util.cc
    index 77e724979..d0dcbcd13 100644
    --- a/util.cc
    +++ b/util.cc
    @@ -958,33 +958,6 @@ QString get_filename(const QString& fname)
       return QFileInfo(fname).fileName();
     }
     
    -/*
    - * gb_int2ptr: Needed, when sizeof(*void) != sizeof(int) ! compiler warning !
    - */
    -void* gb_int2ptr(const int i)
    -{
    -  union {
    -    void* p;
    -    int i;
    -  } x = { nullptr };
    -
    -  x.i = i;
    -  return x.p;
    -}
    -
    -/*
    - * gb_ptr2int: Needed, when sizeof(*void) != sizeof(int) ! compiler warning !
    - */
    -int gb_ptr2int(const void* p)
    -{
    -  union {
    -    const void* p;
    -    int i;
    -  } x = { p };
    -
    -  return x.i;
    -}
    -
     QTextCodec* get_codec(const QByteArray& cs_name)
     {
       QTextCodec* codec = QTextCodec::codecForName(cs_name);
    
    From cc2803d5ab3c5307b0cccd901b8d1a8fa479901e Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Fri, 30 Aug 2024 16:31:11 -0600
    Subject: [PATCH 119/132] prevent assertion failures in nmea reader (#1332)
    
    * replace all empty nmea fields with 0.
    
    including adjacent empty fileds, i.e. ",,," -> ",0,0,".
    
    * defend against indexing past end of arrays.
    
    prevents assertion failures in qstring.h operator[].
    
    also consistently default longitude direction.
    ---
     nmea.cc | 32 +++++++++++++++++---------------
     1 file changed, 17 insertions(+), 15 deletions(-)
    
    diff --git a/nmea.cc b/nmea.cc
    index 2a2c90d0d..0e1f35213 100644
    --- a/nmea.cc
    +++ b/nmea.cc
    @@ -386,11 +386,11 @@ NmeaFormat::gpgll_parse(const QString& ibuf)
       double latdeg = 0;
       if (fields.size() > 1) latdeg = fields[1].toDouble();
       QChar latdir = 'N';
    -  if (fields.size() > 2) latdir = fields[2][0];
    +  if ((fields.size() > 2) && (fields[2].size() > 0)) latdir = fields[2][0];
       double lngdeg = 0;
       if (fields.size() > 3) lngdeg = fields[3].toDouble();
       QChar lngdir = 'E';
    -  if (fields.size() > 4) lngdir = fields[4][0];
    +  if ((fields.size() > 4) && (fields[4].size() > 0)) lngdir = fields[4][0];
       QTime hms;
       if (fields.size() > 5) hms = nmea_parse_hms(fields[5]);
       bool valid = false;
    @@ -434,11 +434,11 @@ NmeaFormat::gpgga_parse(const QString& ibuf)
       double latdeg = 0;
       if (fields.size() > 2) latdeg = fields[2].toDouble();
       QChar latdir = 'N';
    -  if (fields.size() > 3) latdir = fields[3][0];
    +  if ((fields.size() > 3) && (fields[3].size() > 0)) latdir = fields[3][0];
       double lngdeg = 0;
       if (fields.size() > 4) lngdeg = fields[4].toDouble();
    -  QChar lngdir = 'W';
    -  if (fields.size() > 5) lngdir = fields[5][0];
    +  QChar lngdir = 'E';
    +  if ((fields.size() > 5) && (fields[5].size() > 0)) lngdir = fields[5][0];
       int fix = fix_unknown;
       if (fields.size() > 6) fix = fields[6].toInt();
       int nsats = 0;
    @@ -448,11 +448,11 @@ NmeaFormat::gpgga_parse(const QString& ibuf)
       double alt = unknown_alt;
       if (fields.size() > 9) alt = fields[9].toDouble();
       QChar altunits ='M';
    -  if (fields.size() > 10) altunits = fields[10][0];
    +  if ((fields.size() > 10) && (fields[10].size() > 0)) altunits = fields[10][0];
       double geoidheight = unknown_alt;
       if (fields.size() > 11) geoidheight = fields[11].toDouble();
       QChar geoidheightunits = 'M';
    -  if (fields.size() > 12) geoidheightunits = fields[12][0];
    +  if ((fields.size() > 12) && (fields[12].size() > 0)) geoidheightunits = fields[12][0];
     
       /*
        * In serial mode, allow the fix with an invalid position through
    @@ -522,15 +522,15 @@ NmeaFormat::gprmc_parse(const QString& ibuf)
       QTime hms;
       if (fields.size() > 1) hms = nmea_parse_hms(fields[1]);
       QChar fix = 'V'; // V == "Invalid"
    -  if (fields.size() > 2) fix = fields[2][0];
    +  if ((fields.size() > 2) && (fields[2].size() > 0)) fix = fields[2][0];
       double latdeg = 0;
       if (fields.size() > 3) latdeg = fields[3].toDouble();
       QChar latdir = 'N';
    -  if (fields.size() > 4) latdir = fields[4][0];
    +  if ((fields.size() > 4) && (fields[4].size() > 0)) latdir = fields[4][0];
       double lngdeg = 0;
       if (fields.size() > 5) lngdeg = fields[5].toDouble();
    -  QChar lngdir = 'W';
    -  if (fields.size() > 6) lngdir = fields[6][0];
    +  QChar lngdir = 'E';
    +  if ((fields.size() > 6) && (fields[6].size() > 0)) lngdir = fields[6][0];
       double speed = 0;
       if (fields.size() > 7) speed = fields[7].toDouble();
       double course = 0;
    @@ -604,11 +604,11 @@ NmeaFormat::gpwpl_parse(const QString& ibuf)
       double latdeg = 0;
       if (fields.size() > 1) latdeg = fields[1].toDouble();
       QChar latdir = 'N';
    -  if (fields.size() > 2) latdir = fields[2][0];
    +  if ((fields.size() > 2) && (fields[2].size() > 0)) latdir = fields[2][0];
       double lngdeg = 0;
       if (fields.size() > 3) lngdeg = fields[3].toDouble();
       QChar lngdir = 'E';
    -  if (fields.size() > 4) lngdir = fields[4][0];
    +  if ((fields.size() > 4) && (fields[4].size() > 0)) lngdir = fields[4][0];
       QString sname;
       if (fields.size() > 5) sname = fields[5];
     
    @@ -662,7 +662,7 @@ NmeaFormat::gpgsa_parse(const QString& ibuf) const
       // 0 = "GPGSA"
       // 1 = Mode. Ignored
       QChar fix;
    -  if (nfields > 2) {
    +  if ((nfields > 2) && (fields[2].size() > 0)) {
         fix = fields[2][0];
       }
     
    @@ -943,7 +943,9 @@ NmeaFormat::nmea_parse_one_line(const QByteArray& ibuf)
          for that field.  Rather than change all the parse routines, we first
          substitute a default value of zero for any missing field.
       */
    -  tbuf.replace(",,", ",0,");
    +  while (tbuf.contains(",,")) {
    +    tbuf.replace(",,", ",0,");
    +  }
     
       if (notalkerid_strmatch(tbuf, "WPL")) {
         gpwpl_parse(tbuf);
    
    From 314d98779ba1c3967bfa95be2c66a69b7a164bb5 Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Fri, 30 Aug 2024 17:11:09 -0600
    Subject: [PATCH 120/132] normalize waypoint position. (#1331)
    
    ---
     defs.h   |  1 +
     waypt.cc | 62 +++++++++++++++++++++++++++++++++++++++-----------------
     2 files changed, 44 insertions(+), 19 deletions(-)
    
    diff --git a/defs.h b/defs.h
    index d50e49429..2380b89e4 100644
    --- a/defs.h
    +++ b/defs.h
    @@ -357,6 +357,7 @@ class Waypoint
       void SetCreationTime(qint64 t, qint64 ms = 0);
       Geocache* AllocGCData();
       int EmptyGCData() const;
    +  void NormalizePosition();
       PositionDeg position() const {return PositionDeg(latitude, longitude);}
       void SetPosition(const PositionDeg& pos)
       {
    diff --git a/waypt.cc b/waypt.cc
    index b26455511..191cdc841 100644
    --- a/waypt.cc
    +++ b/waypt.cc
    @@ -560,31 +560,53 @@ Waypoint::EmptyGCData() const
       return (gc_data == &Waypoint::empty_gc_data);
     }
     
    -void
    -WaypointList::waypt_add(Waypoint* wpt)
    -{
    -  double lat_orig = wpt->latitude;
    -  double lon_orig = wpt->longitude;
    -  append(wpt);
    +void Waypoint::NormalizePosition()
    +{
    +  double lat_orig = this->latitude;
    +  double lon_orig = this->longitude;
    +
    +  if (this->latitude < -90.0 || this->latitude > 90.0) {
    +    bool fliplon = false;
    +    this->latitude = remainder(this->latitude, 360.0); // -180 <= this->latitude <= 180
    +    if (this->latitude < -90.0) {
    +      this->latitude = -180.0 - this->latitude;
    +      fliplon = true;
    +    } else if (this->latitude > 90.0) {
    +      this->latitude = 180.0 - this->latitude;
    +      fliplon = true;
    +    }
     
    -  if (wpt->latitude < -90) {
    -    wpt->latitude += 180;
    -  } else if (wpt->latitude > +90) {
    -    wpt->latitude -= 180;
    +    if (fliplon) {
    +      if (this->longitude < 0.0) {
    +        this->longitude += 180.0;
    +      } else {
    +        this->longitude -= 180.0;
    +      }
    +    }
       }
    -  if (wpt->longitude < -180) {
    -    wpt->longitude += 360;
    -  } else if (wpt->longitude > +180) {
    -    wpt->longitude -= 360;
    +
    +  if (this->longitude < -180.0 || this->longitude >= 180.0) {
    +    this->longitude = remainder(this->longitude, 360.0); // -180 <= this->longitude <= 180
    +    if (this->longitude == 180.0) {
    +      this->longitude = -180.0;
    +    }
       }
     
    -  if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
    -    fatal(FatalMsg() << wpt->session->name
    +  if ((this->latitude < -90) || (this->latitude > 90.0))
    +    fatal(FatalMsg() << this->session->name
               << "Invalid latitude" << lat_orig << "in waypoint"
    -          << wpt->shortname);
    -  if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
    +          << this->shortname);
    +  if ((this->longitude < -180) || (this->longitude > 180.0))
         fatal(FatalMsg() << "Invalid longitude" << lon_orig << "in waypoint"
    -          << wpt->shortname);
    +          << this->shortname);
    +}
    +
    +void
    +WaypointList::waypt_add(Waypoint* wpt)
    +{
    +  append(wpt);
    +
    +  wpt->NormalizePosition();
     
       /*
        * Some input may not have one or more of these types so we
    @@ -621,6 +643,8 @@ WaypointList::add_rte_waypt(int waypt_ct, Waypoint* wpt, bool synth, QStringView
     {
       append(wpt);
     
    +  wpt->NormalizePosition();
    +
       if (synth && wpt->shortname.isEmpty()) {
         wpt->shortname = QStringLiteral("%1%2").arg(namepart).arg(waypt_ct, number_digits, 10, QChar('0'));
         wpt->wpt_flags.shortname_is_synthetic = 1;
    
    From a81a4b130bebff1a901d063f941f0e3de0c0d7bf Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Fri, 30 Aug 2024 17:32:15 -0600
    Subject: [PATCH 121/132] kill a position normilization clone caught by codacy.
     (#1333)
    
    ---
     gdb.cc | 21 +--------------------
     1 file changed, 1 insertion(+), 20 deletions(-)
    
    diff --git a/gdb.cc b/gdb.cc
    index 7cd965ed6..baf0773c8 100644
    --- a/gdb.cc
    +++ b/gdb.cc
    @@ -1152,26 +1152,7 @@ GdbFormat::write_header()
     void
     GdbFormat::gdb_check_waypt(Waypoint* wpt)
     {
    -  double lat_orig = wpt->latitude;
    -  double lon_orig = wpt->longitude;
    -
    -  if (wpt->latitude < -90) {
    -    wpt->latitude += 180;
    -  } else if (wpt->latitude > +90) {
    -    wpt->latitude -= 180;
    -  }
    -  if (wpt->longitude < -180) {
    -    wpt->longitude += 360;
    -  } else if (wpt->longitude > +180) {
    -    wpt->longitude -= 360;
    -  }
    -
    -  if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
    -    fatal("Invalid latitude %f in waypoint %s.\n",
    -          lat_orig, !wpt->shortname.isEmpty() ? qPrintable(wpt->shortname) : "");
    -  if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
    -    fatal("Invalid longitude %f in waypoint %s.\n",
    -          lon_orig, !wpt->shortname.isEmpty() ? qPrintable(wpt->shortname) : "");
    +  wpt->NormalizePosition();
     }
     
     /*-----------------------------------------------------------------------------*/
    
    From a83ddadcf4085f4de5f54b4c9fe8301152a45919 Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Wed, 4 Sep 2024 11:51:18 -0600
    Subject: [PATCH 122/132] optimize [QDate|QTime|QDateTime]::fromString format
     literals. (#1278)
    
    * optimize [QDate|QTime|QDateTime]::fromString format literals.
    
    These accept QStringViews in Qt6 which can be very efficiently
    passed with UTF-16 character literals.
    
    * optimize QDateTime::toString format literals.
    
    This isn't new to Qt6, but we had a few we hadn't taken care of
    yet.
    
    * use QString::replace(QChar, QChar) instead of (QString, QString)
    ---
     exif.cc        |  4 ++--
     garmin_txt.cc  |  2 +-
     gdb.cc         |  4 ++--
     gui/gmapdlg.cc |  4 ++--
     gui/gpx.cc     |  2 +-
     igc.cc         |  4 ++--
     mtk_logger.cc  |  2 +-
     nmea.cc        |  8 ++++----
     subrip.cc      | 10 +++++-----
     trackfilter.cc |  4 ++--
     unicsv.cc      |  6 +++---
     waypt.cc       |  7 +++----
     xcsv.cc        |  2 +-
     13 files changed, 29 insertions(+), 30 deletions(-)
    
    diff --git a/exif.cc b/exif.cc
    index 4982f5989..553a4775b 100644
    --- a/exif.cc
    +++ b/exif.cc
    @@ -267,7 +267,7 @@ ExifFormat::exif_read_timestamp(const ExifTag* tag)
     QDate
     ExifFormat::exif_read_datestamp(const ExifTag* tag)
     {
    -  return QDate::fromString(tag->data.at(0).toByteArray().constData(), "yyyy:MM:dd");
    +  return QDate::fromString(tag->data.at(0).toByteArray().constData(), u"yyyy:MM:dd");
     }
     
     void
    @@ -697,7 +697,7 @@ ExifFormat::exif_get_exif_time(ExifApp* app) const
         // Note the assumption of local time can be problematic if the data
         // is processed in a different time zone than was used in recording
         // the time in the image.
    -    res = QDateTime::fromString(str, "yyyy:MM:dd hh:mm:ss");
    +    res = QDateTime::fromString(str, u"yyyy:MM:dd hh:mm:ss");
     
         // Exif 2.31 added offset tags to record the offset to UTC.
         // If these are present use them, otherwise assume local time.
    diff --git a/garmin_txt.cc b/garmin_txt.cc
    index 8a8760a63..fdd4fdf46 100644
    --- a/garmin_txt.cc
    +++ b/garmin_txt.cc
    @@ -751,7 +751,7 @@ GarminTxtFormat::write()
       };
     
       QString grid_str = gt_get_mps_grid_longname(grid_index, MYNAME);
    -  grid_str = grid_str.replace('*', "°");
    +  grid_str = grid_str.replace('*', u'°');
       *fout << "Grid\t" << grid_str << "\r\n";
     
       datum_str = gt_get_mps_datum_name(datum_index);
    diff --git a/gdb.cc b/gdb.cc
    index baf0773c8..5a2d4e2ad 100644
    --- a/gdb.cc
    +++ b/gdb.cc
    @@ -1133,8 +1133,8 @@ GdbFormat::write_header()
         */
       static const QDateTime gdb_release_dt = QDateTime(QDate(2011, 4, 14), QTime(1, 30, 1), Qt::UTC);
       gdb_write_cstr(QStringLiteral("GPSBabel-%1").arg(gpsbabel_version));
    -  gdb_write_cstr(gdb_release_dt.toString("MMM dd yyyy"));
    -  gdb_write_cstr(gdb_release_dt.toString("HH:mm:ss"));
    +  gdb_write_cstr(gdb_release_dt.toString(u"MMM dd yyyy"));
    +  gdb_write_cstr(gdb_release_dt.toString(u"HH:mm:ss"));
     
       finalize_item(fsave, 'A');
     
    diff --git a/gui/gmapdlg.cc b/gui/gmapdlg.cc
    index d5325d45c..02de27d17 100644
    --- a/gui/gmapdlg.cc
    +++ b/gui/gmapdlg.cc
    @@ -112,9 +112,9 @@ void GMapDialog::appendTrackInfo(QStandardItem* it, const GpxTrack& trk)
       }
       if (startTime.isValid()) {
         it->appendRow(new StandardItem(tr("Start: %1")
    -                                   .arg(startTime.toString("yyyy-MMM-dd HH:mm:ss"))));
    +                                   .arg(startTime.toString(u"yyyy-MMM-dd HH:mm:ss"))));
         it->appendRow(new StandardItem(tr("Stop: %1")
    -                                   .arg(stopTime.toString("yyyy-MMM-dd HH:mm:ss"))));
    +                                   .arg(stopTime.toString(u"yyyy-MMM-dd HH:mm:ss"))));
       }
       it->appendRow(new StandardItem(tr("Points: %1").arg(count)));
     
    diff --git a/gui/gpx.cc b/gui/gpx.cc
    index 93168f2c0..32c99b31f 100644
    --- a/gui/gpx.cc
    +++ b/gui/gpx.cc
    @@ -32,7 +32,7 @@
     
     static QDateTime decodeDateTime(const QString& s)
     {
    -  QDateTime utc = QDateTime::fromString(s, "yyyy-MM-dd'T'HH:mm:ss'Z'");
    +  QDateTime utc = QDateTime::fromString(s, u"yyyy-MM-dd'T'HH:mm:ss'Z'");
       return utc;
     }
     
    diff --git a/igc.cc b/igc.cc
    index f93bb793c..7ef925ee9 100644
    --- a/igc.cc
    +++ b/igc.cc
    @@ -646,7 +646,7 @@ QByteArray IgcFormat::latlon2str(const Waypoint* wpt)
     
     QByteArray IgcFormat::date2str(const gpsbabel::DateTime& dt)
     {
    -  QByteArray str = dt.toUTC().toString("ddMMyy").toUtf8();
    +  QByteArray str = dt.toUTC().toString(u"ddMMyy").toUtf8();
       if (str.size() != 6) {
         fatal(MYNAME ": Bad date format '%s'\n", str.constData());
       }
    @@ -655,7 +655,7 @@ QByteArray IgcFormat::date2str(const gpsbabel::DateTime& dt)
     
     QByteArray IgcFormat::tod2str(const gpsbabel::DateTime& tod)
     {
    -  QByteArray str = tod.toUTC().toString("hhmmss").toUtf8();
    +  QByteArray str = tod.toUTC().toString(u"hhmmss").toUtf8();
       if (str.size() != 6) {
         fatal(MYNAME ": Bad time of day format '%s'\n", str.constData());
       }
    diff --git a/mtk_logger.cc b/mtk_logger.cc
    index ac7483593..ea7fcebbf 100644
    --- a/mtk_logger.cc
    +++ b/mtk_logger.cc
    @@ -842,7 +842,7 @@ int MtkLoggerBase::csv_line(gbfile* csvFile, int idx, unsigned long bmask, data_
         QDateTime dt = QDateTime::fromSecsSinceEpoch(itm->timestamp, Qt::UTC);
         dt = dt.addMSecs(itm->timestamp_ms);
     
    -    QString timestamp = dt.toUTC().toString("yyyy/MM/dd,hh:mm:ss.zzz");
    +    QString timestamp = dt.toUTC().toString(u"yyyy/MM/dd,hh:mm:ss.zzz");
         gbfputs(timestamp, csvFile);
         gbfputc(',', csvFile);
       }
    diff --git a/nmea.cc b/nmea.cc
    index 0e1f35213..f07d78b9f 100644
    --- a/nmea.cc
    +++ b/nmea.cc
    @@ -358,7 +358,7 @@ QTime NmeaFormat::nmea_parse_hms(const QString& str)
       QTime retval; /* invalid time */
       const QStringList parts = str.trimmed().split('.');
       if ((parts.size() == 1) || (parts.size() == 2)) {
    -    retval = QTime::fromString(parts.at(0), "hhmmss");
    +    retval = QTime::fromString(parts.at(0), u"hhmmss");
         if (retval.isValid() && parts.size() == 2) {
           bool ok;
           // prepend "0.".  prepending "." won't work if there are no trailing digits.
    @@ -539,7 +539,7 @@ NmeaFormat::gprmc_parse(const QString& ibuf)
       if (fields.size() > 9) {
         QString datestr(fields[9]);
         datestr.insert(4, "20");
    -    dmy = QDate::fromString(datestr, "ddMMyyyy");
    +    dmy = QDate::fromString(datestr, u"ddMMyyyy");
       }
       if (fix != 'A') {
         /* ignore this fix - it is invalid */
    @@ -635,7 +635,7 @@ NmeaFormat::gpzda_parse(const QString& ibuf)
       if (fields.size() > 4) {
         QTime time = nmea_parse_hms(fields[1]);
         QString datestr = QStringLiteral("%1%2%3").arg(fields[2], fields[3], fields[4]);
    -    QDate date = QDate::fromString(datestr, "ddMMyyyy");
    +    QDate date = QDate::fromString(datestr, u"ddMMyyyy");
     
         // The prev_datetime data member might be used by
         // nmea_fix_timestamps and nmea_set_waypoint_time.
    @@ -997,7 +997,7 @@ NmeaFormat::read()
       }
     
       if (optdate) {
    -    opt_tm = QDate::fromString(optdate, "yyyyMMdd");
    +    opt_tm = QDate::fromString(optdate, u"yyyyMMdd");
         if (!opt_tm.isValid()) {
           fatal(MYNAME ": Invalid date \"%s\"!\n", optdate);
         }
    diff --git a/subrip.cc b/subrip.cc
    index 1fda7ad07..ee6116b58 100644
    --- a/subrip.cc
    +++ b/subrip.cc
    @@ -210,13 +210,13 @@ SubripFormat::wr_init(const QString& fname)
       }
       gps_datetime = QDateTime();
       if ((opt_gpstime != nullptr) && (opt_gpsdate != nullptr)) {
    -    QDate gps_date = QDate::fromString(opt_gpsdate, "yyyyMMdd");
    +    QDate gps_date = QDate::fromString(opt_gpsdate, u"yyyyMMdd");
         if (!gps_date.isValid()) {
           fatal(FatalMsg().nospace() << MYNAME ": option gps_date value (" << opt_gpsdate << ") is invalid.  Expected yyyymmdd.");
         }
    -    QTime gps_time = QTime::fromString(opt_gpstime, "HHmmss");
    +    QTime gps_time = QTime::fromString(opt_gpstime, u"HHmmss");
         if (!gps_time.isValid()) {
    -      gps_time = QTime::fromString(opt_gpstime, "HHmmss.z");
    +      gps_time = QTime::fromString(opt_gpstime, u"HHmmss.z");
           if (!gps_time.isValid()) {
             fatal(FatalMsg().nospace() << MYNAME ": option gps_time value (" << opt_gpstime << ") is invalid.  Expected hhmmss[.sss]");
           }
    @@ -226,9 +226,9 @@ SubripFormat::wr_init(const QString& fname)
     
       video_offset_ms = 0;
       if (opt_videotime != nullptr) {
    -    QTime video_time = QTime::fromString(opt_videotime, "HHmmss");
    +    QTime video_time = QTime::fromString(opt_videotime, u"HHmmss");
         if (!video_time.isValid()) {
    -      video_time = QTime::fromString(opt_videotime, "HHmmss.z");
    +      video_time = QTime::fromString(opt_videotime, u"HHmmss.z");
           if (!video_time.isValid()) {
             fatal(FatalMsg().nospace() << MYNAME ": option video_time value (" << opt_videotime << ") is invalid.  Expected hhmmss[.sss].");
           }
    diff --git a/trackfilter.cc b/trackfilter.cc
    index 0d43a42b4..06f7c8bf3 100644
    --- a/trackfilter.cc
    +++ b/trackfilter.cc
    @@ -675,7 +675,7 @@ QDateTime TrackFilter::trackfilter_range_check(const char* timestr)
       QRegularExpressionMatch match = re.match(fmtstart);
       if (match.hasMatch()) {
         // QTime::fromString zzz expects exactly 3 digits representing milliseconds.
    -    result = QDateTime::fromString(match.captured(0), "yyyyMMddHHmmss.zzz");
    +    result = QDateTime::fromString(match.captured(0), u"yyyyMMddHHmmss.zzz");
         result.setTimeSpec(Qt::UTC);
         if (!result.isValid()) {
           fatal(MYNAME "-range-check: Invalid timestamp \"%s\"!\n", timestr);
    @@ -833,7 +833,7 @@ TrackFilter::faketime_t TrackFilter::trackfilter_faketime_check(const char* time
         QString start = match.captured(2);
         QString fmtstart("00000101000000");
         fmtstart.replace(0, start.size(), start);
    -    result.start = QDateTime::fromString(fmtstart, "yyyyMMddHHmmss");
    +    result.start = QDateTime::fromString(fmtstart, u"yyyyMMddHHmmss");
         result.start.setTimeSpec(Qt::UTC);
         if (!result.start.isValid()) {
           fatal(MYNAME "-faketime-check: Invalid timestamp \"%s\"!\n", qPrintable(start));
    diff --git a/unicsv.cc b/unicsv.cc
    index 2c4cbbe6d..53b00a27e 100644
    --- a/unicsv.cc
    +++ b/unicsv.cc
    @@ -470,7 +470,7 @@ UnicsvFormat::rd_init(const QString& fname)
       fin->open(fname, QIODevice::ReadOnly, MYNAME, opt_codec);
       unicsv_lineno = 0;
       if (opt_fields) {
    -    QString fields = QString(opt_fields).replace("+", ",");
    +    QString fields = QString(opt_fields).replace('+', ',');
         unicsv_fondle_header(fields);
       } else if (buff = fin->readLine(); !buff.isNull()) {
         ++unicsv_lineno;
    @@ -1105,8 +1105,8 @@ UnicsvFormat::unicsv_print_str(const QString& s) const
         // slavish re-implementation of (what I think) the original C code
         // was doing.
         t.replace("\r\n", ",");
    -    t.replace("\r", ",");
    -    t.replace("\n", ",");
    +    t.replace('\r', ',');
    +    t.replace('\n', ',');
       }
       *fout << t.trimmed();
     }
    diff --git a/waypt.cc b/waypt.cc
    index 191cdc841..1d476c3d7 100644
    --- a/waypt.cc
    +++ b/waypt.cc
    @@ -519,12 +519,11 @@ Waypoint::CreationTimeXML() const
     
       QDateTime dt = GetCreationTime().toUTC();
     
    -  const char* format = "yyyy-MM-ddTHH:mm:ssZ";
       if (dt.time().msec()) {
    -    format = "yyyy-MM-ddTHH:mm:ss.zzzZ";
    +    return dt.toString(u"yyyy-MM-ddTHH:mm:ss.zzzZ");
    +  } else {
    +    return dt.toString(u"yyyy-MM-ddTHH:mm:ssZ");
       }
    -
    -  return dt.toString(format);
     }
     
     gpsbabel::DateTime
    diff --git a/xcsv.cc b/xcsv.cc
    index b1cc09112..050f2b231 100644
    --- a/xcsv.cc
    +++ b/xcsv.cc
    @@ -249,7 +249,7 @@ XcsvStyle::xcsv_ofield_add(XcsvStyle* style, const QString& qkey, const QString&
     QDate
     XcsvFormat::yyyymmdd_to_time(const QString& s)
     {
    -  return QDate::fromString(s, "yyyyMMdd");
    +  return QDate::fromString(s, u"yyyyMMdd");
     }
     
     QDateTime
    
    From ae928c145d9e5b1420ba4f250e2b8d984c7b0512 Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Thu, 5 Sep 2024 07:37:45 -0600
    Subject: [PATCH 123/132] fix tidy readability-avoid-const-params-in-decls
    
    ---
     unicsv.h | 2 +-
     xcsv.h   | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/unicsv.h b/unicsv.h
    index a775e4729..4bc77cb6c 100644
    --- a/unicsv.h
    +++ b/unicsv.h
    @@ -169,7 +169,7 @@ class UnicsvFormat : public Format
       static QTime unicsv_parse_time(const char* str, QDate& date);
       static QTime unicsv_parse_time(const QString& str, QDate& date);
       static Geocache::status_t unicsv_parse_status(const QString& str);
    -  QDateTime unicsv_adjust_time(const QDate date, const QTime time, bool is_localtime) const;
    +  QDateTime unicsv_adjust_time(QDate date, QTime time, bool is_localtime) const;
       static bool unicsv_compare_fields(const QString& s, const field_t* f);
       void unicsv_fondle_header(QString header);
       void unicsv_parse_one_line(const QString& ibuf);
    diff --git a/xcsv.h b/xcsv.h
    index b7d4467f8..7d4349259 100644
    --- a/xcsv.h
    +++ b/xcsv.h
    @@ -350,7 +350,7 @@ class XcsvFormat : public Format
       /* Member Functions */
     
       static QDate yyyymmdd_to_time(const QString& s);
    -  QDateTime xcsv_adjust_time(const QDate date, const QTime time, bool is_localtime) const;
    +  QDateTime xcsv_adjust_time(QDate date, QTime time, bool is_localtime) const;
       static void sscanftime(const char* s, const char* format, QDate& date, QTime& time);
       static QString writetime(const char* format, time_t t, bool gmt);
       static QString writetime(const char* format, const gpsbabel::DateTime& t, bool gmt);
    
    From bc0cc519bd2c520e9d025dee8ba6a075f78f99b9 Mon Sep 17 00:00:00 2001
    From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
    Date: Thu, 5 Sep 2024 07:38:41 -0600
    Subject: [PATCH 124/132] fix tidy modernize-raw-string-literal
    
    ---
     html.cc | 4 ++--
     vcf.cc  | 2 +-
     2 files changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/html.cc b/html.cc
    index 0385c2687..e9971ed26 100644
    --- a/html.cc
    +++ b/html.cc
    @@ -228,12 +228,12 @@ HtmlFormat::write()
       // Don't write this line when running test suite.  Actually, we should
       // probably not write this line at all...
       if (!gpsbabel_testmode()) {
    -    *file_out << "  \n";
       }
       *file_out << "  GPSBabel HTML Output\n";
       if (stylesheet) {
    -    *file_out << "  \n";
       } else {
         *file_out << "