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

Function gmtapi_encode_id

src/gmt_api.c:8573–8601  ·  view source on GitHub ↗

! . */

Source from the content-addressed store, hash-verified

8571
8572/*! . */
8573GMT_LOCAL int gmtapi_encode_id (struct GMTAPI_CTRL *API, unsigned int module_input, unsigned int direction, unsigned int family, unsigned int actual_family, unsigned int geometry, unsigned int messenger, int object_ID, char *filename) {
8574 /* Creates a virtual filename with the embedded object information . Space for up to GMT_VF_LEN characters in filename must exist.
8575 * Name template: @GMTAPI@-S-D-F-A-G-M-###### where # is the 6-digit integer object code. Total length is 27 chars (GMTAPI_MEMFILE_LEN)
8576 * S stands for P(rimary) or S(econdary) input or output object (command line is primary, files via options are secondary).
8577 * D stands for Direction and is either I(n) or O(ut).
8578 * F stands for Family and is one of D(ataset), G(rid), I(mage), C(PT), X(PostScript), M(atrix), V(ector), U(cube), -(undefined).
8579 * A stands for Actual Family and is one of D, G, I, C, X, M, V, and U as well.
8580 * Actual family may differ from family if a Dataset is actually passed as a Matrix, for instance.
8581 * G stands for Geometry and is one of (poin)T, L(ine), P(olygon), C(Line|Polygon), A(Point|Line|Polygon), G(rid), V(olume), N(one), X(text), or -(undefined).
8582 * M stands for Messenger and is either Y(es) or N(o).
8583 * Limitation: object_ID must be <= GMTAPI_MAX_ID */
8584
8585 if (API == NULL) return_error (API, GMT_NOT_A_SESSION); /* GMT_Create_Session has not been called */
8586 if (!filename) return_error (API, GMT_MEMORY_ERROR); /* Oops, cannot write to that variable */
8587 if (object_ID <= GMT_NOTSET) return_error (API, GMT_NOT_A_VALID_ID); /* ID is not set yet */
8588 if (object_ID > GMTAPI_MAX_ID) return_error (API, GMT_ID_TOO_LARGE); /* ID is too large to fit in %06d format below */
8589 if (!(direction == GMT_IN || direction == GMT_OUT)) return_error (API, GMT_NOT_A_VALID_DIRECTION);
8590 if (!gmtapi_valid_input_family (family)) return_error (API, GMT_NOT_A_VALID_FAMILY);
8591 if (!gmtapi_valid_actual_family (actual_family)) return_error (API, GMT_NOT_A_VALID_FAMILY);
8592 if (gmtapi_validate_geometry (API, family, geometry)) return_error (API, GMT_BAD_GEOMETRY);
8593 if (!(messenger == 0 || messenger == 1)) return_error (API, GMT_RUNTIME_ERROR);
8594 if (module_input) module_input = 1; /* It may be GMT_VIA_MODULE_INPUT but here we want just 0 or 1 */
8595
8596 gmt_M_memset (filename, GMT_VF_LEN, char); /* Wipe any trace of previous text */
8597 sprintf (filename, "@GMTAPI@-%c-%c-%s-%s-%c-%c-%06d", (module_input) ? 'P' : 'S', (direction == GMT_IN) ? 'I' : 'O', GMT_family_abbrev[family], GMT_family_abbrev[actual_family], gmtapi_debug_geometry_code (geometry), (messenger) ? 'Y' : 'N', object_ID);
8598 GMT_Report (API, GMT_MSG_DEBUG, "VirtualFile name created: %s\n", filename);
8599
8600 return_error (API, GMT_NOERROR); /* No error encountered */
8601}
8602
8603/* Data registration: The main reason for data registration is the following:
8604 * Unlike GMT 4, GMT 5 may be used as modules by another calling program. In

Callers 1

GMT_Open_VirtualFileFunction · 0.85

Calls 5

gmtapi_validate_geometryFunction · 0.85
GMT_ReportFunction · 0.85

Tested by

no test coverage detected