source: git/src/json.cc

walls-data-hanging-as-warning
Last change on this file was 4c83f84, checked in by Olly Betts <olly@…>, 11 days ago

Don't check HAVE_CONFIG_H in most cases

This check is only useful for img.c, which is intended to be usable
outside of Survex (and had fallbacks for functions which may not be
available which will get used if built in a non-autotools project).
For all the other source files it's just useless boilerplate.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/* json.cc
2 * Export from Aven as JSON.
3 */
4/* Copyright (C) 2015,2016,2022 Olly Betts
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19 */
20
21#include <config.h>
22
23#include "json.h"
24
25#include "export.h"
26
27#include <stdio.h>
28
29using namespace std;
30
31const int *
32JSON::passes() const
33{
34    static const int default_passes[] = { LEGS|SURF, 0 };
35    return default_passes;
36}
37
38void
39JSON::header(const char * title, const char *, time_t datestamp_numeric,
40             double min_x, double min_y, double min_z,
41             double max_x, double max_y, double max_z)
42{
43    (void)title;
44    (void)datestamp_numeric;
45#if 0
46    if (title) {
47        fputs("title: \"", fh);
48        json_escape(fh, title);
49        fputs("\",\n", fh);
50    }
51    if (datestamp_numeric != time_t(-1)) {
52        fprintf("date: %ld,\n", (long)datestamp_numeric);
53    }
54#endif
55    fprintf(fh, "{\"bounds\":[%.2f,%.2f,%.2f,%.2f,%.2f,%.2f],\n\"traverses\":[\n",
56            min_x, min_z, min_y, max_x, max_z, max_y);
57}
58
59void
60JSON::line(const img_point *p1, const img_point *p, unsigned /*flags*/, bool fPendingMove)
61{
62    if (fPendingMove) {
63        if (in_segment) {
64            fputs("],\n[", fh);
65        } else {
66            fputs("[", fh);
67            in_segment = true;
68        }
69        fprintf(fh, "[%.2f,%.2f,%.2f]", p1->x, p1->z, p1->y);
70    }
71    fprintf(fh, ",[%.2f,%.2f,%.2f]", p->x, p->z, p->y);
72}
73
74void
75JSON::label(const img_point *p, const wxString&, bool /*fSurface*/, int type)
76{
77    (void)p;
78    (void)type;
79}
80
81void
82JSON::footer()
83{
84    if (in_segment)
85        fputs("]\n", fh);
86    fputs("]}\n", fh);
87}
Note: See TracBrowser for help on using the repository browser.