mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
HTML: export DC samples to JSON format.
-Export Dive computer samples to JSON format, for dive profile plotting. -Add maxdepth and duration to attributes of the JSON dive object. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4a69dea972
commit
c7bc364ca1
1 changed files with 16 additions and 0 deletions
16
save-html.c
16
save-html.c
|
@ -1,5 +1,20 @@
|
||||||
#include "save-html.h"
|
#include "save-html.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
|
void put_HTML_samples(struct membuffer *b, struct dive *dive)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
put_format(b, "\"maxdepth\":%d,", dive->dc.maxdepth.mm);
|
||||||
|
put_format(b, "\"duration\":%d,", dive->dc.duration.seconds);
|
||||||
|
put_string(b, "\"samples\":\[");
|
||||||
|
struct sample *s = dive->dc.sample;
|
||||||
|
for (i = 0; i < dive->dc.samples; i++) {
|
||||||
|
put_format(b, "[%d,%d],", s->time.seconds, s->depth.mm);
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
put_string(b, "],");
|
||||||
|
}
|
||||||
|
|
||||||
void put_HTML_date(struct membuffer *b, struct dive *dive, const char *pre, const char *post)
|
void put_HTML_date(struct membuffer *b, struct dive *dive, const char *pre, const char *post)
|
||||||
{
|
{
|
||||||
|
@ -103,6 +118,7 @@ void write_one_dive(struct membuffer *b, struct dive *dive, int *dive_no)
|
||||||
write_attribute(b, "suit", dive->suit);
|
write_attribute(b, "suit", dive->suit);
|
||||||
put_HTML_tags(b, dive, "\"tags\":", ",");
|
put_HTML_tags(b, dive, "\"tags\":", ",");
|
||||||
put_HTML_notes(b, dive, "\"notes\":\"", "\",");
|
put_HTML_notes(b, dive, "\"notes\":\"", "\",");
|
||||||
|
put_HTML_samples(b, dive);
|
||||||
put_string(b, "},\n");
|
put_string(b, "},\n");
|
||||||
(*dive_no)++;
|
(*dive_no)++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue