From 32a040ece0020354cd890abb3654e30c630b5511 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 16 Jul 2018 14:07:45 +1200 Subject: [PATCH] Support "clamp to ground" for KML export The default altitude mode for KML is "clampToGround", which renders data on the surface of the terrain. This is useful with KML viewers which render the terrain as opaque so underground data isn't visible. Rendering cave passages on the surface isn't great, but is better than not being able to see them at all. This option may also be helpful if you want to see where to look on the surface for new entrances. --- lib/bg.po | 10 ++++++++++ lib/ca.po | 10 ++++++++++ lib/de.po | 10 ++++++++++ lib/de_CH.po | 10 ++++++++++ lib/el.po | 10 ++++++++++ lib/en_US.po | 10 ++++++++++ lib/es.po | 10 ++++++++++ lib/fr.po | 10 ++++++++++ lib/hu.po | 10 ++++++++++ lib/id.po | 10 ++++++++++ lib/it.po | 10 ++++++++++ lib/pl.po | 10 ++++++++++ lib/pt.po | 10 ++++++++++ lib/pt_BR.po | 10 ++++++++++ lib/ro.po | 10 ++++++++++ lib/ru.po | 10 ++++++++++ lib/sk.po | 10 ++++++++++ lib/survex.pot | 10 ++++++++++ lib/zh_CN.po | 10 ++++++++++ src/export.cc | 8 +++++--- src/export.h | 1 + src/kml.cc | 30 ++++++++++++++++++++++++------ src/kml.h | 3 ++- src/printing.cc | 8 +++++++- src/survexport.cc | 35 ++++++++++++++++++++--------------- 25 files changed, 249 insertions(+), 26 deletions(-) diff --git a/lib/bg.po b/lib/bg.po index c3216a3c..3c511d67 100644 --- a/lib/bg.po +++ b/lib/bg.po @@ -2017,6 +2017,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/ca.po b/lib/ca.po index c6f7bfa8..2e7403be 100644 --- a/lib/ca.po +++ b/lib/ca.po @@ -2016,6 +2016,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/de.po b/lib/de.po index f6729141..b5e40300 100644 --- a/lib/de.po +++ b/lib/de.po @@ -2015,6 +2015,16 @@ msgstr "Vollständige Koordinaten" msgid "full coordinates" msgstr "Vollständige Koordinaten" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/de_CH.po b/lib/de_CH.po index 11b47d9d..24b75300 100644 --- a/lib/de_CH.po +++ b/lib/de_CH.po @@ -2015,6 +2015,16 @@ msgstr "Vollständige Koordinaten" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/el.po b/lib/el.po index aae7a707..1e820275 100644 --- a/lib/el.po +++ b/lib/el.po @@ -2013,6 +2013,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/en_US.po b/lib/en_US.po index d513e585..d0cf1a78 100644 --- a/lib/en_US.po +++ b/lib/en_US.po @@ -2012,6 +2012,16 @@ msgstr "Full coordinates" msgid "full coordinates" msgstr "full coordinates" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "Clamp to ground" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "clamp to ground" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/es.po b/lib/es.po index 3bbb198c..49413c82 100644 --- a/lib/es.po +++ b/lib/es.po @@ -2012,6 +2012,16 @@ msgstr "Coordenadas completas" msgid "full coordinates" msgstr "coordenadas completas" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "Pegar al suelo" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "pegar al suelo" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/fr.po b/lib/fr.po index 914f265b..515b1c74 100644 --- a/lib/fr.po +++ b/lib/fr.po @@ -2012,6 +2012,16 @@ msgstr "Coordonnées complètes" msgid "full coordinates" msgstr "coordonnées complètes" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/hu.po b/lib/hu.po index c39dc604..f64a0264 100644 --- a/lib/hu.po +++ b/lib/hu.po @@ -2023,6 +2023,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/id.po b/lib/id.po index 93fbde94..76097cbe 100644 --- a/lib/id.po +++ b/lib/id.po @@ -2012,6 +2012,16 @@ msgstr "Koordinat penuh" msgid "full coordinates" msgstr "koordinat penuh" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/it.po b/lib/it.po index d7293254..44984b83 100644 --- a/lib/it.po +++ b/lib/it.po @@ -2015,6 +2015,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/pl.po b/lib/pl.po index daf77c00..c40517ec 100644 --- a/lib/pl.po +++ b/lib/pl.po @@ -2012,6 +2012,16 @@ msgstr "Pełne współrzędne" msgid "full coordinates" msgstr "pełne współrzędne" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/pt.po b/lib/pt.po index 3ab65ca3..8f57be7d 100644 --- a/lib/pt.po +++ b/lib/pt.po @@ -2018,6 +2018,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/pt_BR.po b/lib/pt_BR.po index 772180cf..8a4fc9fd 100644 --- a/lib/pt_BR.po +++ b/lib/pt_BR.po @@ -2018,6 +2018,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/ro.po b/lib/ro.po index 6779ca75..ee382200 100644 --- a/lib/ro.po +++ b/lib/ro.po @@ -2016,6 +2016,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/ru.po b/lib/ru.po index ee43d549..d912f0ed 100644 --- a/lib/ru.po +++ b/lib/ru.po @@ -2013,6 +2013,16 @@ msgstr "Полные координаты" msgid "full coordinates" msgstr "полные координаты" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/sk.po b/lib/sk.po index 0afe92e9..c235811c 100644 --- a/lib/sk.po +++ b/lib/sk.po @@ -2015,6 +2015,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/survex.pot b/lib/survex.pot index 0b40c546..42ffa51a 100644 --- a/lib/survex.pot +++ b/lib/survex.pot @@ -2014,6 +2014,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/lib/zh_CN.po b/lib/zh_CN.po index ebd9b80f..dbc6518b 100644 --- a/lib/zh_CN.po +++ b/lib/zh_CN.po @@ -2015,6 +2015,16 @@ msgstr "" msgid "full coordinates" msgstr "" +#: ../src/printing.cc:548 +#: n:477 +msgid "Clamp to ground" +msgstr "" + +#: ../src/survexport.cc:134 +#: n:478 +msgid "clamp to ground" +msgstr "" + #. TRANSLATORS: Used in the print dialog: #: ../src/printing.cc:473 #: n:263 diff --git a/src/export.cc b/src/export.cc index 9a673f04..d15df1de 100644 --- a/src/export.cc +++ b/src/export.cc @@ -88,7 +88,7 @@ const format_info export_format_info[] = { LEGS|SPLAYS|CENTRED|EXPORT_3D, LEGS }, { ".kml", /*KML files*/444, - LABELS|LEGS|SPLAYS|PASG|XSECT|WALLS|ENTS|FIXES|EXPORTS|PROJ|EXPORT_3D, + LABELS|LEGS|SPLAYS|PASG|XSECT|WALLS|ENTS|FIXES|EXPORTS|PROJ|EXPORT_3D|CLAMP_TO_GROUND, LABELS|LEGS }, /* TRANSLATORS: "Compass" and "Carto" are the names of software packages, * so should not be translated: @@ -1357,11 +1357,13 @@ Export(const wxString &fnm_out, const wxString &title, case FMT_JSON: filt = new JSON; break; - case FMT_KML: - filt = new KML(model.GetCSProj().c_str()); + case FMT_KML: { + bool clamp_to_ground = (show_mask & CLAMP_TO_GROUND); + filt = new KML(model.GetCSProj().c_str(), clamp_to_ground); show_mask |= FULL_COORDS; need_bounds = false; break; + } case FMT_PLT: filt = new PLT; show_mask |= FULL_COORDS; diff --git a/src/export.h b/src/export.h index f65179a9..170e840d 100644 --- a/src/export.h +++ b/src/export.h @@ -74,6 +74,7 @@ extern const format_info export_format_info[]; #define SCALE 0x00020000 #define FULL_COORDS 0x00040000 #define SPLAYS 0x00080000 +#define CLAMP_TO_GROUND 0x00100000 #define DEFAULT_GRID_SPACING 100 // metres #define DEFAULT_TEXT_HEIGHT 0.6 diff --git a/src/kml.cc b/src/kml.cc index d41e6910..e2030f84 100644 --- a/src/kml.cc +++ b/src/kml.cc @@ -62,7 +62,8 @@ html_escape(FILE *fh, const char *s) } } -KML::KML(const char * input_datum) +KML::KML(const char * input_datum, bool clamp_to_ground_) + : clamp_to_ground(clamp_to_ground_) { if (!(pj_input = pj_init_plus(input_datum))) { wxString m = wmsg(/*Failed to initialise input coordinate system “%s”*/287); @@ -137,7 +138,11 @@ KML::line(const img_point *p1, const img_point *p, unsigned /*flags*/, bool fPen } else { fputs("\n", fh); } - fputs("absolute\n", fh); + if (clamp_to_ground) { + fputs("\n", fh); + } else { + fputs("absolute\n", fh); + } double X = p1->x, Y = p1->y, Z = p1->z; pj_transform(pj_input, pj_output, 1, 1, &X, &Y, &Z); X = deg(X); @@ -173,7 +178,11 @@ KML::xsect(const img_point *p, double angle, double d1, double d2) x2 = deg(x2); y2 = deg(y2); - fputs("absolute", fh); + if (clamp_to_ground) { + fputs("", fh); + } else { + fputs("absolute", fh); + } fprintf(fh, "%.8f,%.8f,%.2f %.8f,%.8f,%.2f", x1, y1, z1, x2, y2, z2); fputs("\n", fh); } @@ -192,7 +201,11 @@ KML::wall(const img_point *p, double angle, double d) y = deg(y); if (!in_wall) { - fputs("absolute", fh); + if (clamp_to_ground) { + fputs("", fh); + } else { + fputs("absolute", fh); + } in_wall = true; } fprintf(fh, "%.8f,%.8f,%.2f\n", x, y, z); @@ -222,8 +235,13 @@ KML::passage(const img_point *p, double angle, double d1, double d2) y2 = deg(y2); if (psg.empty()) { - fprintf(fh, "absolute" - "\n"); + if (clamp_to_ground) { + fputs("" + "\n", fh); + } else { + fputs("absolute" + "\n", fh); + } } // NB - order of vertices should be anti-clockwise in a KML file, so go // along the right wall now, and put the left wall points on a stack to diff --git a/src/kml.h b/src/kml.h index 9d0292a6..931f3d01 100644 --- a/src/kml.h +++ b/src/kml.h @@ -30,9 +30,10 @@ class KML : public ExportFilter { projPJ pj_input = NULL, pj_output = NULL; bool in_linestring = false; bool in_wall = false; + bool clamp_to_ground; std::vector psg; public: - explicit KML(const char * input_datum); + KML(const char * input_datum, bool clamp_to_ground_); ~KML(); const int * passes() const; void header(const char *, const char *, time_t, diff --git a/src/printing.cc b/src/printing.cc index 29296fa5..9b5568f5 100644 --- a/src/printing.cc +++ b/src/printing.cc @@ -115,7 +115,8 @@ enum { svx_TEXT_HEIGHT, svx_MARKER_SIZE, svx_CENTRED, - svx_FULLCOORDS + svx_FULLCOORDS, + svx_CLAMP_TO_GROUND }; class BitValidator : public wxValidator { @@ -514,6 +515,10 @@ svxPrintDlg::svxPrintDlg(MainFrm* mainfrm_, const wxString & filename, wxDefaultPosition, wxDefaultSize, 0, BitValidator(&m_layout.show_mask, FULL_COORDS)), 0, wxALIGN_LEFT|wxALL, 2); + v2->Add(new wxCheckBox(this, svx_CLAMP_TO_GROUND, wmsg(/*Clamp to ground*/477), + wxDefaultPosition, wxDefaultSize, 0, + BitValidator(&m_layout.show_mask, CLAMP_TO_GROUND)), + 0, wxALIGN_LEFT|wxALL, 2); } if (printing) { /* TRANSLATORS: used in the print dialog - controls drawing lines @@ -765,6 +770,7 @@ svxPrintDlg::SomethingChanged(int control_id) { { svx_EXPORTS, EXPORTS }, { svx_CENTRED, CENTRED }, { svx_FULLCOORDS, FULL_COORDS }, + { svx_CLAMP_TO_GROUND, CLAMP_TO_GROUND }, }; static unsigned n_controls = sizeof(controls) / sizeof(controls[0]); for (unsigned i = 0; i != n_controls; ++i) { diff --git a/src/survexport.cc b/src/survexport.cc index a58cdc8c..f71824a3 100644 --- a/src/survexport.cc +++ b/src/survexport.cc @@ -62,7 +62,7 @@ main(int argc, char **argv) OPT_SCALE = 0x100, OPT_BEARING, OPT_TILT, OPT_PLAN, OPT_ELEV, OPT_LEGS, OPT_SURF, OPT_SPLAYS, OPT_CROSSES, OPT_LABELS, OPT_ENTS, OPT_FIXES, OPT_EXPORTS, OPT_XSECT, OPT_WALLS, OPT_PASG, - OPT_CENTRED, OPT_FULL_COORDS, OPT_DEFAULTS + OPT_CENTRED, OPT_FULL_COORDS, OPT_CLAMP_TO_GROUND, OPT_DEFAULTS }; static const struct option long_opts[] = { /* const char *name; int has_arg (0 no_argument, 1 required, 2 options_*); int *flag; int val */ @@ -85,6 +85,7 @@ main(int argc, char **argv) {"passages", no_argument, 0, OPT_PASG}, {"origin-in-centre", no_argument, 0, OPT_CENTRED}, {"full-coordinates", no_argument, 0, OPT_FULL_COORDS}, + {"clamp-to-ground", no_argument, 0, OPT_CLAMP_TO_GROUND}, {"defaults", no_argument, 0, OPT_DEFAULTS}, {"grid", optional_argument, 0, 'g'}, {"text-height", required_argument, 0, 't'}, @@ -131,24 +132,25 @@ main(int argc, char **argv) {HLP_ENCODELONG(16), /*passages*/471, 0}, {HLP_ENCODELONG(17), /*origin in centre*/472, 0}, {HLP_ENCODELONG(18), /*full coordinates*/473, 0}, - {HLP_ENCODELONG(19), /*include items exported by default*/155, 0}, - {HLP_ENCODELONG(20), /*generate grid (default %sm)*/148, STRING(DEFAULT_GRID_SPACING)}, - {HLP_ENCODELONG(21), /*station labels text height (default %s)*/149, STRING(DEFAULT_TEXT_HEIGHT)}, - {HLP_ENCODELONG(22), /*station marker size (default %s)*/152, STRING(DEFAULT_MARKER_SIZE)}, - {HLP_ENCODELONG(23), /*produce DXF output*/156, 0}, - {HLP_ENCODELONG(24), /*produce EPS output*/454, 0}, - {HLP_ENCODELONG(25), /*produce GPX output*/455, 0}, - {HLP_ENCODELONG(26), /*produce HPGL output*/456, 0}, - {HLP_ENCODELONG(27), /*produce JSON output*/457, 0}, - {HLP_ENCODELONG(28), /*produce KML output*/458, 0}, + {HLP_ENCODELONG(19), /*clamp to ground*/478, 0}, + {HLP_ENCODELONG(20), /*include items exported by default*/155, 0}, + {HLP_ENCODELONG(21), /*generate grid (default %sm)*/148, STRING(DEFAULT_GRID_SPACING)}, + {HLP_ENCODELONG(22), /*station labels text height (default %s)*/149, STRING(DEFAULT_TEXT_HEIGHT)}, + {HLP_ENCODELONG(23), /*station marker size (default %s)*/152, STRING(DEFAULT_MARKER_SIZE)}, + {HLP_ENCODELONG(24), /*produce DXF output*/156, 0}, + {HLP_ENCODELONG(25), /*produce EPS output*/454, 0}, + {HLP_ENCODELONG(26), /*produce GPX output*/455, 0}, + {HLP_ENCODELONG(27), /*produce HPGL output*/456, 0}, + {HLP_ENCODELONG(29), /*produce JSON output*/457, 0}, + {HLP_ENCODELONG(29), /*produce KML output*/458, 0}, /* TRANSLATORS: "Compass" and "Carto" are the names of software packages, * so should not be translated. */ - {HLP_ENCODELONG(29), /*produce Compass PLT output for Carto*/159, 0}, + {HLP_ENCODELONG(30), /*produce Compass PLT output for Carto*/159, 0}, /* TRANSLATORS: "Skencil" is the name of a software package, so should not be * translated. */ - {HLP_ENCODELONG(30), /*produce Skencil output*/158, 0}, - {HLP_ENCODELONG(31), /*produce Survex POS output*/459, 0}, - {HLP_ENCODELONG(32), /*produce SVG output*/160, 0}, + {HLP_ENCODELONG(31), /*produce Skencil output*/158, 0}, + {HLP_ENCODELONG(32), /*produce Survex POS output*/459, 0}, + {HLP_ENCODELONG(33), /*produce SVG output*/160, 0}, {0, 0, 0} }; @@ -204,6 +206,9 @@ main(int argc, char **argv) case OPT_FULL_COORDS: bit = FULL_COORDS; break; + case OPT_CLAMP_TO_GROUND: + bit = CLAMP_TO_GROUND; + break; case OPT_DEFAULTS: always_include_defaults = true; break; -- 2.11.4.GIT