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

Function gmtapi_validate_geometry

src/gmt_api.c:2896–2912  ·  view source on GitHub ↗

! Sanity check that geometry and family are compatible; note they may not be set (GMT_NOTSET) hence the use of signed ints */

Source from the content-addressed store, hash-verified

2894
2895/*! Sanity check that geometry and family are compatible; note they may not be set (GMT_NOTSET) hence the use of signed ints */
2896GMT_LOCAL bool gmtapi_validate_geometry (struct GMTAPI_CTRL *API, int family, int geometry) {
2897 bool problem = false;
2898 gmt_M_unused(API);
2899 if (geometry == GMT_NOTSET || family == GMT_NOTSET) return false; /* No errors if nothing to check yet */
2900 switch (family) {
2901 case GMT_IS_DATASET: if (!(geometry == GMT_IS_NONE || geometry == GMT_IS_TEXT || (geometry & GMT_IS_PLP))) problem = true; break; /* Datasets can hold many things... */
2902 case GMT_IS_GRID: if (geometry != GMT_IS_SURFACE) problem = true; break; /* Only surface is valid */
2903 case GMT_IS_IMAGE: if (geometry != GMT_IS_SURFACE) problem = true; break; /* Only surface is valid */
2904 case GMT_IS_PALETTE: if (geometry != GMT_IS_NONE) problem = true; break; /* Only text is valid */
2905 case GMT_IS_POSTSCRIPT: if (geometry != GMT_IS_NONE) problem = true; break; /* Only text is valid */
2906 case GMT_IS_CUBE: if (geometry != GMT_IS_VOLUME) problem = true; break; /* Only volume is valid */
2907 case GMT_IS_VECTOR: if ((geometry & GMT_IS_PLP) == 0) problem = true; break; /* Must be one of those three */
2908 case GMT_IS_MATRIX: if (geometry == GMT_IS_NONE) problem = true; break; /* Matrix can hold surfaces or DATASETs */
2909 case GMT_IS_COORD: if (geometry != GMT_IS_NONE) problem = true; break; /* Only text is valid */
2910 }
2911 return (problem);
2912}
2913
2914/*! . */
2915GMT_LOCAL int gmtapi_decode_id (const char *filename) {

Callers 3

gmtapi_encode_idFunction · 0.85
GMT_Register_IOFunction · 0.85
GMT_Init_IOFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected