kopia lustrzana https://gitlab.com/tomaszg/geostat
Add geolist tool
rodzic
acc16d1dbf
commit
64613df224
|
@ -63,6 +63,13 @@ Usage: geofriends nick1 nick2
|
|||
Generate HTML stats for user caching intersection from Opencaching data.
|
||||
```
|
||||
|
||||
## geolist
|
||||
Another tools is `geolist`. It generates HTML list of caches from a list of cache codes.
|
||||
|
||||
```
|
||||
Usage: geolist list_of_caches
|
||||
Produce a HTML list of caches given their OC codes.
|
||||
```
|
||||
|
||||
# Installation
|
||||
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
#include "okapi.h"
|
||||
#include "cache.h"
|
||||
#include "debug.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
void show_usage() {
|
||||
std::cout << "Usage: geolist list_of_caches\n";
|
||||
std::cout << "Produce a HTML list of caches given their OC codes.\n\n";
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::string ocpl_url = "https://opencaching.pl/okapi/";
|
||||
std::string ocde_url = "https://www.opencaching.de/okapi/";
|
||||
std::string ocus_url = "http://www.opencaching.us/okapi/";
|
||||
std::string ocnl_url = "http://www.opencaching.nl/okapi/";
|
||||
std::string ocro_url = "http://www.opencaching.ro/okapi/";
|
||||
std::string ocuk_url = "https://opencache.uk/okapi/";
|
||||
|
||||
#include "config_user.h"
|
||||
|
||||
if (argc < 2) show_usage();
|
||||
|
||||
std::string ocpl_user1 = argv[1];
|
||||
std::string ocpl_user2 = argv[2];
|
||||
|
||||
Caches cc;
|
||||
|
||||
std::set<std::string> code_pl, code_de, code_us, code_nl, code_ro, code_uk;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i][0] != 'O') continue;
|
||||
switch (argv[i][1]) {
|
||||
case 'P':
|
||||
code_pl.insert(argv[i]);
|
||||
break;
|
||||
case 'C':
|
||||
code_de.insert(argv[i]);
|
||||
break;
|
||||
case 'U':
|
||||
code_us.insert(argv[i]);
|
||||
break;
|
||||
case 'B':
|
||||
code_nl.insert(argv[i]);
|
||||
break;
|
||||
case 'R':
|
||||
code_ro.insert(argv[i]);
|
||||
break;
|
||||
case 'K':
|
||||
code_uk.insert(argv[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!code_pl.empty()) {
|
||||
Okapi OCpl(ocpl_url, ocpl_key);
|
||||
Caches tmp = OCpl.get_caches(code_pl);
|
||||
std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
}
|
||||
if (!code_de.empty()) {
|
||||
Okapi OCde(ocde_url, ocde_key);
|
||||
Caches tmp = OCde.get_caches(code_de);
|
||||
std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
}
|
||||
if (!code_us.empty()) {
|
||||
Okapi OCus(ocus_url, ocus_key);
|
||||
Caches tmp = OCus.get_caches(code_us);
|
||||
std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
}
|
||||
if (!code_nl.empty()) {
|
||||
Okapi OCnl(ocnl_url, ocnl_key);
|
||||
Caches tmp = OCnl.get_caches(code_nl);
|
||||
std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
}
|
||||
if (!code_ro.empty()) {
|
||||
Okapi OCro(ocro_url, ocro_key);
|
||||
Caches tmp = OCro.get_caches(code_ro);
|
||||
std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
}
|
||||
if (!code_uk.empty()) {
|
||||
Okapi OCuk(ocuk_url, ocuk_key);
|
||||
Caches tmp = OCuk.get_caches(code_uk);
|
||||
std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
}
|
||||
|
||||
header_html();
|
||||
|
||||
std::cout << "<table class=\"list\">\n";
|
||||
std::cout << "<tr><th></th>";
|
||||
std::cout << "<th>Cache</th>";
|
||||
std::cout << "<th>Type</th>";
|
||||
std::cout << "<th>D/T</th>";
|
||||
std::cout << "<th>Date hidden</th>";
|
||||
std::cout << "<th>Region</th>";
|
||||
std::cout << "</tr>\n";
|
||||
|
||||
short int n = 1;
|
||||
for (auto& i : cc) {
|
||||
std::cout << "<tr><th>" << n << "</th> ";
|
||||
std::cout << "<td>" << i.link_name() << "</td>";
|
||||
std::cout << "<td>" << i.type << "</td>";
|
||||
std::cout << "<td>" << i.diff << '/' << i.terr << "</td>";
|
||||
std::cout << "<td>" << i.date_hidden << "</td>";
|
||||
std::cout << "<td>" << i.region << "</td>";
|
||||
std::cout << "</tr>\n";
|
||||
n++;
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
footer_html();
|
||||
}
|
||||
|
|
@ -16,11 +16,13 @@ endif
|
|||
link = ['-lheatmap']
|
||||
src = ['geostat.cpp', 'okapi.cpp', 'cache.cpp', 'debug.cpp', 'heat.cpp', 'ocdb.cpp', 'common.cpp', 'region.cpp']
|
||||
src_fr = ['geofriends.cpp', 'okapi.cpp', 'cache.cpp', 'debug.cpp', 'common.cpp']
|
||||
src_lst = ['geolist.cpp', 'okapi.cpp', 'cache.cpp', 'debug.cpp', 'common.cpp']
|
||||
src_cli = ['geostat_cli.cpp', 'okapi.cpp', 'gpx.cpp', 'cache.cpp', 'debug.cpp', 'heat.cpp', 'ocdb.cpp', 'common.cpp', 'region.cpp']
|
||||
src_db = ['geodb.cpp', 'debug.cpp', 'ocdb.cpp', 'okapi.cpp', 'cache.cpp', 'common.cpp']
|
||||
|
||||
executable('geostat', src, dependencies : [curl_dep, json_dep, magick_dep, sqlite_dep], link_args: link, install: true)
|
||||
executable('geofriends', src_fr, dependencies : [curl_dep, json_dep], install: true)
|
||||
executable('geolist', src_lst, dependencies : [curl_dep, json_dep], install: true)
|
||||
executable('geostat_cli', src_cli, dependencies : [curl_dep, json_dep, magick_dep, sqlite_dep, gpx_dep], link_args: link, install: true)
|
||||
executable('geodb', src_db, dependencies : [sqlite_dep, json_dep, curl_dep], install: true)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue