Skip to content

Commit 05b7407

Browse files
author
chad-iris
committed
Update Source Identifier handling to the adopted specification
1 parent 6becee5 commit 05b7407

34 files changed

+75
-63
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2021.234: 3.0.9
2+
- Update Source Identifier handling to the adopted specification of:
3+
FDSN:NET_STA_LOC_BAND_SOURCE_POSITION
4+
15
2020.156: 3.0.8
26
- Add error/warning log registry for accumulation of messages.
37
- Log and diagnostic printing callbacks now require 'const char *'.

example/lm_sids.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ main (int argc, char **argv)
6262
char *sid;
6363
int idx;
6464

65-
sid = "XFDSN:NET_STA_LOC_C_H_N";
65+
sid = "FDSN:NET_STA_LOC_C_H_N";
6666

6767
if (map_sid (sid))
6868
{

genutils.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This file is part of the miniSEED Library.
55
*
6-
* Copyright (c) 2020 Chad Trabant, IRIS Data Management Center
6+
* Copyright (c) 2021 Chad Trabant, IRIS Data Management Center
77
*
88
* Licensed under the Apache License, Version 2.0 (the "License");
99
* you may not use this file except in compliance with the License.
@@ -113,18 +113,25 @@ static const int monthdays_leap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30,
113113

114114

115115
/**********************************************************************/ /**
116-
* @brief Parse network, station, location and channel from a source ID URI
116+
* @brief Parse network, station, location and channel from an FDSN Source ID
117+
*
118+
* FDSN Source Identifiers are defined at:
119+
* https://docs.fdsn.org/projects/source-identifiers/
117120
*
118121
* Parse a source identifier into separate components, expecting:
119-
* \c "XFDSN:NET_STA_LOC_CHAN", where \c CHAN="BAND_SOURCE_POSITION"
122+
* \c "FDSN:NET_STA_LOC_CHAN", where \c CHAN="BAND_SOURCE_POSITION"
120123
*
121124
* The CHAN value will be converted to a SEED channel code if
122125
* possible. Meaning, if the BAND, SOURCE, and POSITION are single
123126
* characters, the underscore delimiters will not be included in the
124127
* returned channel.
125128
*
126129
* Identifiers may contain additional namespace identifiers, e.g.:
127-
* \c "XFDSN:AGENCY:NET_STA_LOC_CHAN"
130+
* \c "FDSN:AGENCY:NET_STA_LOC_CHAN"
131+
*
132+
* Such additional namespaces are not part of the Source ID standard
133+
* as of this writing and support is included for specialized usage or
134+
* future identifier changes.
128135
*
129136
* Memory for each component must already be allocated. If a specific
130137
* component is not desired set the appropriate argument to NULL.
@@ -154,21 +161,20 @@ ms_sid2nslc (char *sid, char *net, char *sta, char *loc, char *chan)
154161
return -1;
155162
}
156163

157-
/* Handle the XFDSN: and FDSN: namespace identifiers */
158-
if (!strncmp (sid, "XFDSN:", 6) ||
159-
!strncmp (sid, "FDSN:", 5))
164+
/* Handle the FDSN: namespace identifier */
165+
if (!strncmp (sid, "FDSN:", 5))
160166
{
161167
/* Advance sid pointer to last ':', skipping all namespace identifiers */
162168
sid = strrchr (sid, ':') + 1;
163169

164-
/* Verify 3 or 5 delimiters */
170+
/* Verify 5 delimiters */
165171
id = sid;
166172
while ((id = strchr (id, '_')))
167173
{
168174
id++;
169175
sepcnt++;
170176
}
171-
if (sepcnt != 3 && sepcnt != 5)
177+
if (sepcnt != 5)
172178
{
173179
ms_log (2, "Incorrect number of identifier delimiters (%d): %s\n", sepcnt, sid);
174180
return -1;
@@ -205,7 +211,7 @@ ms_sid2nslc (char *sid, char *net, char *sta, char *loc, char *chan)
205211

206212
top = next;
207213
}
208-
/* Location (potentially empty) */
214+
/* Location, potentially empty */
209215
if ((ptr = strchr (top, '_')))
210216
{
211217
next = ptr + 1;
@@ -240,11 +246,14 @@ ms_sid2nslc (char *sid, char *net, char *sta, char *loc, char *chan)
240246
} /* End of ms_sid2nslc() */
241247

242248
/**********************************************************************/ /**
243-
* @brief Convert network, station, location and channel to a source ID URI
249+
* @brief Convert network, station, location and channel to an FDSN Source ID
250+
*
251+
* FDSN Source Identifiers are defined at:
252+
* https://docs.fdsn.org/projects/source-identifiers/
244253
*
245254
* Create a source identifier from individual network,
246255
* station, location and channel codes with the form:
247-
* \c XFDSN:NET_STA_LOC_CHAN, where \c CHAN="BAND_SOURCE_POSITION"
256+
* \c FDSN:NET_STA_LOC_CHAN, where \c CHAN="BAND_SOURCE_POSITION"
248257
*
249258
* Memory for the source identifier must already be allocated. If a
250259
* specific component is NULL it will be empty in the resulting
@@ -288,13 +297,12 @@ ms_nslc2sid (char *sid, int sidlen, uint16_t flags,
288297
return -1;
289298
}
290299

291-
*sptr++ = 'X';
292300
*sptr++ = 'F';
293301
*sptr++ = 'D';
294302
*sptr++ = 'S';
295303
*sptr++ = 'N';
296304
*sptr++ = ':';
297-
needed = 6;
305+
needed = 5;
298306

299307
if (net)
300308
{

libmseed.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* See the License for the specific language governing permissions and
1818
* limitations under the License.
1919
*
20-
* Copyright (C) 2020:
20+
* Copyright (C) 2021:
2121
* @author Chad Trabant, IRIS Data Management Center
2222
***************************************************************************/
2323

@@ -28,8 +28,8 @@
2828
extern "C" {
2929
#endif
3030

31-
#define LIBMSEED_VERSION "3.0.8" //!< Library version
32-
#define LIBMSEED_RELEASE "2020.156" //!< Library release date
31+
#define LIBMSEED_VERSION "3.0.1" //!< Library version
32+
#define LIBMSEED_RELEASE "2021.234" //!< Library release date
3333

3434
/** @defgroup io-functions File and URL I/O */
3535
/** @defgroup miniseed-record Record Handling */

test/parse-sids.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
LD_LIBRARY_PATH=.. \
33
DYLD_LIBRARY_PATH=.. \
4-
./lm_sids XFDSN:XX_TEST__L_H_Z XFDSN:NETWORK_STATION_LOCATION_BAND_SOURCE_POSITION
4+
./lm_sids FDSN:XX_TEST__L_H_Z FDSN:NETWORK_STATION_LOCATION_BAND_SOURCE_POSITION

test/parse-sids.test.ref

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
Original SID: 'XFDSN:NET_STA_LOC_C_H_N'
1+
Original SID: 'FDSN:NET_STA_LOC_C_H_N'
22
network: 'NET', station: 'STA', location: 'LOC', channel: 'CHN'
3-
SID: 'XFDSN:NET_STA_LOC_C_H_N'
4-
Original SID: 'XFDSN:XX_TEST__L_H_Z'
3+
SID: 'FDSN:NET_STA_LOC_C_H_N'
4+
Original SID: 'FDSN:XX_TEST__L_H_Z'
55
network: 'XX', station: 'TEST', location: '', channel: 'LHZ'
6-
SID: 'XFDSN:XX_TEST__L_H_Z'
7-
Original SID: 'XFDSN:NETWORK_STATION_LOCATION_BAND_SOURCE_POSITION'
6+
SID: 'FDSN:XX_TEST__L_H_Z'
7+
Original SID: 'FDSN:NETWORK_STATION_LOCATION_BAND_SOURCE_POSITION'
88
network: 'NETWORK', station: 'STATION', location: 'LOCATION', channel: 'BAND_SOURCE_POSITION'
9-
SID: 'XFDSN:NETWORK_STATION_LOCATION_BAND_SOURCE_POSITION'
9+
SID: 'FDSN:NETWORK_STATION_LOCATION_BAND_SOURCE_POSITION'

test/read-CDSN-encoded.test.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
XFDSN:XX_TEST__B_H_E, 3, 4096, 2016 samples, 20 Hz, 1986,360,01:11:45.430000
1+
FDSN:XX_TEST__B_H_E, 3, 4096, 2016 samples, 20 Hz, 1986,360,01:11:45.430000
22
-96 -87 -100 -128 -123 -83
33
-52 -54 -77 -108 -130 -120
44
-92 -93 -106 -108 -96 -57

test/read-DWWSSN-encoded.test.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
XFDSN:XX_TEST__L_H_E, 4, 4096, 2016 samples, 1 Hz, 1980,360,00:00:00.320000
1+
FDSN:XX_TEST__L_H_E, 4, 4096, 2016 samples, 1 Hz, 1980,360,00:00:00.320000
22
6 5 1 -9 -18 -19
33
-7 10 27 34 34 35
44
40 45 49 44 35 31

test/read-Float32-encoded.test.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
XFDSN:XX_TEST__V_H_E, 2, 4096, 1008 samples, 0.1 Hz, 1986,360,02:12:05.864800
1+
FDSN:XX_TEST__V_H_E, 2, 4096, 1008 samples, 0.1 Hz, 1986,360,02:12:05.864800
22
-1.0625 -1.078125 -1.078125 -1.078125 -1.078125 -1.078125
33
-1.0859375 -1.0859375 -1.0859375 -1.0859375 -1.09375 -1.09375
44
-1.09375 -1.09375 -1.0859375 -1.0859375 -1.0703125 -1.0625

test/read-Float64-encoded.test.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
XFDSN:XX_TEST__V_H_E, 2, 4096, 504 samples, 0.1 Hz, 1986,360,02:12:05.864800
1+
FDSN:XX_TEST__V_H_E, 2, 4096, 504 samples, 0.1 Hz, 1986,360,02:12:05.864800
22
-1.0625 -1.078125 -1.078125 -1.078125 -1.078125 -1.078125
33
-1.0859375 -1.0859375 -1.0859375 -1.0859375 -1.09375 -1.09375
44
-1.09375 -1.09375 -1.0859375 -1.0859375 -1.0703125 -1.0625

0 commit comments

Comments
 (0)