diff --git a/include/turtle.h b/include/turtle.h index 4ce256b..30cbfb4 100644 --- a/include/turtle.h +++ b/include/turtle.h @@ -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 * diff --git a/src/turtle/stack.c b/src/turtle/stack.c index 3f74974..f0511e6 100644 --- a/src/turtle/stack.c +++ b/src/turtle/stack.c @@ -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; + } +}