kopia lustrzana https://gitlab.com/tomaszg/geostat
Add a reasonably working caching timeline
rodzic
d2688336e4
commit
1c2bcf0cdc
44
geo.css
44
geo.css
|
@ -176,6 +176,7 @@ td.dt_zero {
|
|||
padding-top: 0;
|
||||
}
|
||||
|
||||
|
||||
/* horizontal histogram */
|
||||
|
||||
.histogram.cachingtimeline {
|
||||
|
@ -213,6 +214,49 @@ td.dt_zero {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
/* table-based horizontal histogram */
|
||||
|
||||
.calendar_tab th {
|
||||
font-weight: bold;
|
||||
width: 4em;
|
||||
}
|
||||
|
||||
.calendar_tab tr {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
height: 100px;
|
||||
margin: 30px;
|
||||
}
|
||||
|
||||
.calendar_tab tr:first-child {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.calendar_tab td, .calendar_tab th {
|
||||
display: block;
|
||||
flex-grow: 1;
|
||||
flex-basis: 0;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
.calendar_tab td {
|
||||
background: linear-gradient(to right, #7c7 50%, #668);;
|
||||
height: var(--percent);
|
||||
position: relative;
|
||||
border: 1px solid black;
|
||||
vertical-align: bottom;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.calendar_tab td > span {
|
||||
position: absolute;
|
||||
bottom: -1.5em;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
/* collapsible */
|
||||
|
||||
details > summary {
|
||||
|
|
105
geostat.cpp
105
geostat.cpp
|
@ -287,7 +287,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "<html lang=\"en\">\n";
|
||||
std::cout << " <head>\n";
|
||||
std::cout << " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
|
||||
std::cout << " <link rel=\"stylesheet\" type=\"text/css\" href=\"geo.css?ver=10\">\n";
|
||||
std::cout << " <link rel=\"stylesheet\" type=\"text/css\" href=\"geo.css?ver=11\">\n";
|
||||
std::cout << " <title>Geocaching stats</title>\n";
|
||||
std::cout << "</head>\n";
|
||||
std::cout << "<body>\n";
|
||||
|
@ -333,6 +333,12 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
if (!get_not_found) {
|
||||
short count;
|
||||
int n = 0;
|
||||
|
||||
short y_min = std::min_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_hidden_tm.tm_year < b.date_hidden_tm.tm_year; })->date_hidden_tm.tm_year;
|
||||
short y_max = std::max_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_hidden_tm.tm_year < b.date_hidden_tm.tm_year; })->date_hidden_tm.tm_year;
|
||||
|
||||
std::cout << "<div class=\"basic_stats\">\n";
|
||||
std::cout << "Number of caches found: <span class=\"value\">" << cc.size() << "</span><br>\n";
|
||||
|
||||
|
@ -369,6 +375,53 @@ int main(int argc, char** argv) {
|
|||
auto E = *std::max_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lon < b->pos.lon; });
|
||||
auto W = *std::min_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lon < b->pos.lon; });
|
||||
|
||||
std::cout << "<h2>Caching timeline</h2>\n";
|
||||
std::cout << "<table class=\"dt\">\n";
|
||||
std::cout << "<tr><th></th>";
|
||||
for (int j = 1; j <= 12; j++) { // print table month headers
|
||||
std::cout << "<th>" << j << "</th>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
|
||||
for (int i = y_min; i <= y_max; i++) { // i -> years in rows
|
||||
std::cout << "<tr><th>" << i + 1900 << "</th> ";
|
||||
for (int j = 1; j <= 12; j++) { // j -> months in cols
|
||||
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_hidden_tm.tm_year == i && c.date_hidden_tm.tm_mon == j - 1); });
|
||||
if (count == 0)
|
||||
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
|
||||
else
|
||||
std::cout << "<td>" << count << "</td>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
y_min = std::min_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_tm.tm_year < b.date_tm.tm_year; })->date_tm.tm_year;
|
||||
y_max = std::max_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_tm.tm_year < b.date_tm.tm_year; })->date_tm.tm_year;
|
||||
|
||||
std::cout << "<h2>Caches by found day matrix</h2>\n";
|
||||
std::cout << "<table class=\"calendar_tab\">\n";
|
||||
std::cout << "<tr><th></th>";
|
||||
for (int j = 1; j <= 12; j++) { // print table month headers
|
||||
std::cout << "<th>" << j << "</th>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
|
||||
long max = 0; // maximal value for histogram
|
||||
for (int i = y_min; i <= y_max; i++)
|
||||
for (int j = 1; j <= 12; j++)
|
||||
max = std::max(max, std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_tm.tm_year == i && c.date_tm.tm_mon == j - 1); }));
|
||||
|
||||
for (int i = y_min; i <= y_max; i++) { // i -> years in rows
|
||||
std::cout << "<tr><th>" << i + 1900 << "</th> ";
|
||||
for (int j = 1; j <= 12; j++) { // j -> months in cols
|
||||
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_tm.tm_year == i && c.date_tm.tm_mon == j - 1); });
|
||||
std::cout << "<td style=\"--percent: " << count * 100 / max << "%\"><span>" << count << "</span></td>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
std::cout << "<h2>Geographically extreme caches</h2>\n";
|
||||
std::cout << "<table class=\"list\">\n";
|
||||
std::cout << "<tr>\n";
|
||||
|
@ -400,8 +453,6 @@ int main(int argc, char** argv) {
|
|||
show_histogram(cc, &Cache::year, "Years", 1, 0);
|
||||
|
||||
// DT matrix
|
||||
short count;
|
||||
int n = 0;
|
||||
|
||||
std::cout << "<h2>Difficulty / terrain matrix</h2>\n";
|
||||
std::cout << "<table class=\"dt\">\n";
|
||||
|
@ -599,54 +650,6 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
short y_min = std::min_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_hidden_tm.tm_year < b.date_hidden_tm.tm_year; })->date_hidden_tm.tm_year;
|
||||
short y_max = std::max_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_hidden_tm.tm_year < b.date_hidden_tm.tm_year; })->date_hidden_tm.tm_year;
|
||||
|
||||
std::cout << "<h2>Caches by hidden day matrix</h2>\n";
|
||||
std::cout << "<table class=\"dt\">\n";
|
||||
std::cout << "<tr><th></th>";
|
||||
for (int j = 1; j <= 12; j++) { // print table month headers
|
||||
std::cout << "<th>" << j << "</th>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
|
||||
for (int i = y_min; i <= y_max; i++) { // i -> years in rows
|
||||
std::cout << "<tr><th>" << i + 1900 << "</th> ";
|
||||
for (int j = 1; j <= 12; j++) { // j -> months in cols
|
||||
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_hidden_tm.tm_year == i && c.date_hidden_tm.tm_mon == j - 1); });
|
||||
if (count == 0)
|
||||
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
|
||||
else
|
||||
std::cout << "<td>" << count << "</td>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
y_min = std::min_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_tm.tm_year < b.date_tm.tm_year; })->date_tm.tm_year;
|
||||
y_max = std::max_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_tm.tm_year < b.date_tm.tm_year; })->date_tm.tm_year;
|
||||
|
||||
std::cout << "<h2>Caches by found day matrix</h2>\n";
|
||||
std::cout << "<table class=\"dt\">\n";
|
||||
std::cout << "<tr><th></th>";
|
||||
for (int j = 1; j <= 12; j++) { // print table month headers
|
||||
std::cout << "<th>" << j << "</th>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
|
||||
for (int i = y_min; i <= y_max; i++) { // i -> years in rows
|
||||
std::cout << "<tr><th>" << i + 1900 << "</th> ";
|
||||
for (int j = 1; j <= 12; j++) { // j -> months in cols
|
||||
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_tm.tm_year == i && c.date_tm.tm_mon == j - 1); });
|
||||
if (count == 0)
|
||||
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
|
||||
else
|
||||
std::cout << "<td>" << count << "</td>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
} // end of main if
|
||||
|
||||
if (get_not_found) {
|
||||
|
|
Ładowanie…
Reference in New Issue