MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / gmtsupport_time_array

Function gmtsupport_time_array

src/gmt_support.c:15690–15716  ·  view source on GitHub ↗

! . */

Source from the content-addressed store, hash-verified

15688
15689/*! . */
15690GMT_LOCAL uint64_t gmtsupport_time_array (struct GMT_CTRL *GMT, double min, double max, double inc, char unit, bool interval, double **array) {
15691 /* When T->active is true we must return interval start/stop even if outside min/max range */
15692 uint64_t n = 0;
15693 size_t n_alloc = GMT_SMALL_CHUNK;
15694 struct GMT_MOMENT_INTERVAL I;
15695 double *val = NULL;
15696
15697 val = gmt_M_memory (GMT, NULL, n_alloc, double);
15698 gmt_M_memset (&I, 1, struct GMT_MOMENT_INTERVAL);
15699 I.unit = unit;
15700 I.step = urint (inc);
15701 gmtlib_moment_interval (GMT, &I, min, true); /* First time we pass true for initialization */
15702 while (I.dt[0] <= max) { /* As long as we are not gone way past the end time */
15703 if (I.dt[0] >= min || interval) val[n++] = I.dt[0]; /* Was inside region */
15704 gmtlib_moment_interval (GMT, &I, 0.0, false); /* Advance to next interval */
15705 if (n == n_alloc) { /* Allocate more space */
15706 n_alloc <<= 1;
15707 val = gmt_M_memory (GMT, val, n_alloc, double);
15708 }
15709 }
15710 if (interval) val[n++] = I.dt[0]; /* Must get end of interval too */
15711 val = gmt_M_memory (GMT, val, n, double);
15712
15713 *array = val;
15714
15715 return (n);
15716}
15717
15718/*! . */
15719unsigned int gmtlib_time_array (struct GMT_CTRL *GMT, double min, double max, struct GMT_PLOT_AXIS_ITEM *T, double **array) {

Callers 2

gmtlib_time_arrayFunction · 0.85
gmt_create_arrayFunction · 0.85

Calls 1

gmtlib_moment_intervalFunction · 0.85

Tested by

no test coverage detected