Skip to content

Commit

Permalink
Stack info function
Browse files Browse the repository at this point in the history
  • Loading branch information
niess committed Sep 19, 2024
1 parent aa5366b commit 5eb1806
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/turtle.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,21 @@ TURTLE_API enum turtle_return turtle_stack_gradient(
struct turtle_stack * stack, double latitude, double longitude,
double * glat, double * glon, int * inside);

/**
* Get some basic information relative to the stack.
*
* @param stack The stack object
* @param shape The stack shape along [longitude, latitude], or `NULL`.
* @param latitude The stack latitude range, or `NULL`.
* @param longitude The stack longitude range, or `NULL`.
*
* __Warnings__ The shape, latitude and longitude arguments must be size 2-or
* more arrays, if not `NULL`.
*
*/
TURTLE_API void turtle_stack_info(const struct turtle_stack * stack,
int * shape, double * latitude, double * longitude);

/**
* Create a new client to a stack of global topography data
*
Expand Down
20 changes: 20 additions & 0 deletions src/turtle/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,23 @@ enum turtle_return turtle_stack_load_(struct turtle_stack * stack,
if (inside != NULL) *inside = 1;
return TURTLE_RETURN_SUCCESS;
}

/* Return some stack info. */
void turtle_stack_info(const struct turtle_stack * stack, int * shape,
double * latitude, double * longitude)
{
if (shape != NULL) {
shape[0] = stack->longitude_n;
shape[1] = stack->latitude_n;
}

if (latitude != NULL) {
latitude[0] = stack->latitude_0;
latitude[1] = stack->latitude_0 + stack->latitude_delta;
}

if (longitude != NULL) {
longitude[0] = stack->longitude_0;
longitude[1] = stack->longitude_0 + stack->longitude_delta;
}
}

0 comments on commit 5eb1806

Please # to comment.