4
4
constexpr int max_lines_in_block = 10000 ;
5
5
6
6
int dso::Sinex::parse_block_site_antenna (
7
- std::vector<sinex::SiteAntenna> &site_vec) noexcept {
7
+ const std::vector<sinex::SiteId> &site_vec,
8
+ std::vector<sinex::SiteAntenna> &out_vec,
9
+ const dso::datetime<dso::nanoseconds> from,
10
+ const dso::datetime<dso::nanoseconds> to) noexcept {
11
+
12
+ using sinex::details::ltrim_cpy;
13
+
8
14
/* clear the vector */
9
- if (!site_vec .empty ())
10
- site_vec .clear ();
15
+ if (!out_vec .empty ())
16
+ out_vec .clear ();
11
17
12
18
/* go to SITE/ANTENNA block */
13
19
if (goto_block (" SITE/ANTENNA" ))
@@ -32,34 +38,57 @@ int dso::Sinex::parse_block_site_antenna(
32
38
if (!std::strncmp (line, " -SITE/ANTENNA" , 14 ))
33
39
break ;
34
40
if (*line != ' *' ) { /* non-comment line */
35
- site_vec.emplace_back (sinex::SiteAntenna{});
36
- auto vecit = site_vec.end () - 1 ;
37
-
38
- std::memcpy (vecit->site_code (), line + 1 , 4 );
39
- std::memcpy (vecit->point_code (), line + 6 , 2 );
40
- std::memcpy (vecit->soln_id (), line + 9 , 4 );
41
- try {
42
- vecit->m_obscode = dso::sinex::char_to_SinexObservationCode (line[14 ]);
43
- } catch (std::exception &) {
44
- fprintf (
45
- stderr,
46
- " [ERROR] Erronuous SINEX Observation Code \' %c\' (traceback: %s)\n " ,
47
- line[14 ], __func__);
48
- ++error;
49
- }
50
-
51
- error += sinex::parse_sinex_date (line + 16 , m_data_start, vecit->m_start );
52
- error += sinex::parse_sinex_date (line + 29 , m_data_stop, vecit->m_stop );
53
- if (error) {
54
- fprintf (
55
- stderr,
56
- " [ERROR] Failed to parse date from line: \" %s\" (traceback: %s)\n " ,
57
- line, __func__);
58
- }
59
-
60
- std::memcpy (vecit->ant_type (), line + 42 , 20 );
61
- std::memcpy (vecit->ant_serial (), line + 63 , 5 );
62
- }
41
+
42
+ /* first check site name */
43
+ auto it = std::find_if (
44
+ site_vec.cbegin (), site_vec.cend (), [&](const sinex::SiteId &site) {
45
+ return !std::strncmp (site.site_code (), line + 1 , 4 ) &&
46
+ !std::strncmp (site.point_code (), line + 6 , 2 );
47
+ });
48
+
49
+ /* the station is in the list */
50
+ if (it != site_vec.cend ()) {
51
+
52
+ /* second, resolve time interval */
53
+ dso::datetime<dso::nanoseconds> intrv_start, intrv_stop;
54
+ error += sinex::parse_sinex_date (line + 16 , m_data_start, intrv_start);
55
+ error += sinex::parse_sinex_date (line + 29 , m_data_stop, intrv_stop);
56
+ if (error) {
57
+ fprintf (stderr,
58
+ " [ERROR] Failed to parse date from line: \" %s\" (traceback: "
59
+ " %s)\n " ,
60
+ line, __func__);
61
+ }
62
+
63
+ /* if validity interval and antenna interval overlap */
64
+ if (dso::intervals_overlap<
65
+ dso::nanoseconds, dso::datetime_ranges::OverlapComparissonType::
66
+ AllowEdgesOverlap>(
67
+ intrv_start, intrv_stop, from, to)) {
68
+
69
+ out_vec.emplace_back (sinex::SiteAntenna{});
70
+ auto vecit = out_vec.end () - 1 ;
71
+
72
+ ltrim_cpy (vecit->site_code (), line + 1 , 4 );
73
+ ltrim_cpy (vecit->point_code (), line + 6 , 2 );
74
+ ltrim_cpy (vecit->soln_id (), line + 9 , 4 );
75
+ try {
76
+ vecit->m_obscode =
77
+ dso::sinex::char_to_SinexObservationCode (line[14 ]);
78
+ } catch (std::exception &) {
79
+ fprintf (
80
+ stderr,
81
+ " [ERROR] Erronuous SINEX Observation Code \' %c\' (traceback: "
82
+ " %s)\n " ,
83
+ line[14 ], __func__);
84
+ ++error;
85
+ }
86
+
87
+ ltrim_cpy (vecit->ant_type (), line + 42 , 20 );
88
+ ltrim_cpy (vecit->ant_serial (), line + 63 , 5 );
89
+ } /* intervals overlap */
90
+ } /* station in the list */
91
+ } /* non-comment line */
63
92
} /* end parsing block */
64
93
65
94
/* check for infinite loop */
0 commit comments