2 * Export from Aven as Survex .pos.
4 /* Copyright (C) 2001,2002,2011,2013,2014,2015 Olly Betts
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.
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.
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
27 #include "export.h" // For LABELS, etc
34 #include "namecompare.h"
42 vector
<pos_label
*>::const_iterator i
;
43 for (i
= todo
.begin(); i
!= todo
.end(); ++i
) {
52 static const int default_passes
[] = { LABELS
|ENTS
|FIXES
|EXPORTS
, 0 };
53 return default_passes
;
56 void POS::header(const char *, const char *, time_t,
57 double, double, double, double, double, double)
59 fputsnl(msg(/*( Easting, Northing, Altitude )*/195), fh
);
63 POS::label(const img_point
*p
, const char *s
, bool /*fSurface*/, int /*type*/)
65 size_t len
= strlen(s
);
66 pos_label
* l
= (pos_label
*)new char[offsetof(pos_label
, name
) + len
+ 1];
70 memcpy(l
->name
, s
, len
+ 1);
74 class pos_label_ptr_cmp
{
78 explicit pos_label_ptr_cmp(char separator_
) : separator(separator_
) { }
80 bool operator()(const POS::pos_label
* a
, const POS::pos_label
* b
) {
81 return name_cmp(a
->name
, b
->name
, separator
) < 0;
88 sort(todo
.begin(), todo
.end(), pos_label_ptr_cmp(separator
));
89 vector
<pos_label
*>::const_iterator i
;
90 for (i
= todo
.begin(); i
!= todo
.end(); ++i
) {
91 fprintf(fh
, "(%8.2f, %8.2f, %8.2f ) %s\n",
92 (*i
)->x
, (*i
)->y
, (*i
)->z
, (*i
)->name
);