/
thexpmap.h
284 lines (209 loc) · 6.46 KB
/
thexpmap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/**
* @file thexpmap.h
* Export class.
*/
/* Copyright (C) 2000 Stacho Mudrak
*
* $Date: $
* $RCSfile: $
* $Revision: $
*
* --------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* --------------------------------------------------------------------
*/
#ifndef thexpmap_h
#define thexpmap_h
#include "thexport.h"
#include "thsymbolset.h"
#include "thlang.h"
/**
* map export options.
*/
enum {
TT_EXPMAP_OPT_UNKNOWN = 0, ///< Unknown option
TT_EXPMAP_OPT_FORMAT, ///< Output option.
TT_EXPMAP_OPT_PROJECTION, ///< Output projection.
TT_EXPMAP_OPT_LAYOUT, ///< Layout.
TT_EXPMAP_OPT_ENCODING, ///< Output encoding.
TT_EXPMAP_OPT_ENABLE, ///< Output option.
TT_EXPMAP_OPT_DISABLE, ///< Output option.
};
/**
* Options parsing table.
*/
static const thstok thtt_expmap_opt[] = {
{"-disable", TT_EXPMAP_OPT_DISABLE},
{"-enable", TT_EXPMAP_OPT_ENABLE},
{"-enc", TT_EXPMAP_OPT_ENCODING},
{"-encoding", TT_EXPMAP_OPT_ENCODING},
{"-fmt", TT_EXPMAP_OPT_FORMAT},
{"-format", TT_EXPMAP_OPT_FORMAT},
{"-layout", TT_EXPMAP_OPT_LAYOUT},
{"-proj", TT_EXPMAP_OPT_PROJECTION},
{"-projection", TT_EXPMAP_OPT_PROJECTION},
{NULL, TT_EXPMAP_OPT_UNKNOWN}
};
/**
* Model export item options.
*/
enum {
TT_EXPMAP_ITEM_UNKNOWN = 0,
TT_EXPMAP_ITEM_ENTRANCES = 32,
TT_EXPMAP_ITEM_ALL = 255,
};
/**
* Options parsing table.
*/
static const thstok thtt_expmap_items[] = {
{"all", TT_EXPMAP_ITEM_ALL},
{"entrances", TT_EXPMAP_ITEM_ENTRANCES},
{NULL, TT_EXPMAP_ITEM_UNKNOWN}
};
/**
* map export formats.
*/
enum {
TT_EXPMAP_FMT_UNKNOWN = 0, ///< Unknown option
TT_EXPMAP_FMT_SVG,
TT_EXPMAP_FMT_XHTML,
TT_EXPMAP_FMT_PDF,
TT_EXPMAP_FMT_XVI,
TT_EXPMAP_FMT_TH2,
TT_EXPMAP_FMT_3D,
TT_EXPMAP_FMT_SHP,
TT_EXPMAP_FMT_KML,
TT_EXPMAP_FMT_DXF,
TT_EXPMAP_FMT_BBOX,
};
/**
* Format parsing table.
*/
static const thstok thtt_expmap_fmt[] = {
{"bbox", TT_EXPMAP_FMT_BBOX},
{"dxf", TT_EXPMAP_FMT_DXF},
{"esri", TT_EXPMAP_FMT_SHP},
{"kml", TT_EXPMAP_FMT_KML},
{"pdf", TT_EXPMAP_FMT_PDF},
{"shapefile", TT_EXPMAP_FMT_SHP},
{"shapefiles", TT_EXPMAP_FMT_SHP},
{"shp", TT_EXPMAP_FMT_SHP},
{"survex", TT_EXPMAP_FMT_3D},
{"svg", TT_EXPMAP_FMT_SVG},
{"th2", TT_EXPMAP_FMT_TH2},
{"xhtml", TT_EXPMAP_FMT_XHTML},
{"xvi", TT_EXPMAP_FMT_XVI},
{NULL, TT_EXPMAP_FMT_UNKNOWN}
};
/**
* Scrap mp export struct.
*/
class thexpmapmpxs {
public:
FILE * file; ///< output file
class thdb2dprj * proj;
double ms, mx, my, sr, cr, rr; ///< Scale and centering.
thsymbolset * symset = nullptr;
thlayout * layout = nullptr;
const char * attr_last_id, * attr_last_survey, * attr_last_scrap;
bool attr_last_scrap_centerline;
double m_shift_x, m_shift_y;
thexpmapmpxs() : file(NULL), proj(NULL), ms(1.0), mx(0.0), my(0.0), sr(0.0), cr(1.0), rr(0.0),
attr_last_id(""), attr_last_survey(""), attr_last_scrap(""), attr_last_scrap_centerline(false),
m_shift_x(0.0), m_shift_y(0.0) {}
};
#define thxmmxst(out, sx, sy) \
(((sx) - (out)->mx) * (out)->cr + \
((sy) - (out)->my) * (out)->sr) * out->ms, \
(((sy) - (out)->my) * (out)->cr - \
((sx) - (out)->mx) * (out)->sr) * out->ms
enum {
TT_XMPS_NONE = 0,
TT_XMPS_COUNT = 5,
TT_XMPS_F = 1,
TT_XMPS_COUNT_F = 0,
TT_XMPS_B = 2,
TT_XMPS_COUNT_B = 1,
TT_XMPS_E = 4,
TT_XMPS_COUNT_E = 2,
TT_XMPS_X = 8,
TT_XMPS_COUNT_X = 3,
};
struct thexpmap_xmps {
int flags;
long F,B,E,X;
thexpmap_xmps() : flags(TT_XMPS_NONE), F(-1), B(-1), E(-1), X(-1) {}
};
/**
* Main export class.
*/
class thexpmap : public thexport {
public:
friend class thexporter;
int format, ///< Output format.
encoding; ///< Output encoding.
const char * projstr, ///< Projection string.
* layoutstr; ///< Layout string.
class thdb2dprj * projptr; ///< Projection pointer.
thsymbolset symset;
thbuffer layoutopts; ///< Layout options buffer.
unsigned items; ///< Item types to be exported (As of 29/11/2016 affects only KML entrances)
void export_xvi(class thdb2dprj * prj);
void export_th2(class thdb2dprj * prj);
void export_pdf(class thdb2dxm * maps, class thdb2dprj * prj);
thexpmap_xmps export_mp(thexpmapmpxs * out, class thscrap * scrap, unsigned & startnum, bool outline_mode);
void export_pdf_set_colors(class thdb2dxm * maps, class thdb2dprj * prj);
void export_pdf_set_colors_new(class thdb2dxm * maps, class thdb2dprj * prj);
void export_scrap_backgroud_mesh(class thscrap * cs, class thexpmapmpxs * out, struct scraprecord * r);
void export_uni(class thdb2dxm * maps, class thdb2dprj * prj);
void export_uni_scrap(FILE * out, class thscrap * scrap);
void export_shp(class thdb2dxm * maps, class thdb2dprj * prj);
void export_kml(class thdb2dxm * maps, class thdb2dprj * prj);
void export_bbox(class thdb2dxm * maps, class thdb2dprj * prj);
void export_dxf(class thdb2dxm * maps, class thdb2dprj * prj);
public:
thexpmap(); ///< Default constructor.
virtual ~thexpmap(); ///< Default destructor.
/**
* Parse map export options.
*/
void parse_options(int & argx, int nargs, char ** args) override;
/**
* Parse layout options.
*/
void parse_layout_option(int & argx, int nargs, char ** args);
/**
* Dump object into file.
*/
void dump_body(FILE * xf) override;
/**
* Dump object into file.
*/
void dump_header(FILE * xf) override;
/**
* Make export.
*/
void process_db(class thdatabase * dbp) override;
/**
* Parse export projection.
*/
void parse_projection(class thdatabase * dbp);
};
/**
* Quick map export scale.
*/
extern double thexpmap_quick_map_export_scale;
void thexpmap_log_log_file(const char * logfpath, const char * on_title, const char * off_title, bool mpbug = false);
#endif