MCPcopy Index your code
hub / github.com/MapServer/MapServer / msGMLGetConstants

Function msGMLGetConstants

mapgml.c:911–965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

909}
910
911gmlConstantListObj *msGMLGetConstants(layerObj *layer, const char *metadata_namespaces)
912{
913 int i;
914 const char *value=NULL;
915 char tag[64];
916
917 char **names=NULL;
918 int numnames=0;
919
920 gmlConstantListObj *constantList=NULL;
921 gmlConstantObj *constant=NULL;
922
923 /* allocate the collection */
924 constantList = (gmlConstantListObj *) malloc(sizeof(gmlConstantListObj));
925 MS_CHECK_ALLOC(constantList, sizeof(gmlConstantListObj), NULL);
926 constantList->constants = NULL;
927 constantList->numconstants = 0;
928
929 /* list of constants (TODO: make this automatic by parsing metadata) */
930 if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "constants")) != NULL) {
931 names = msStringSplit(value, ',', &numnames);
932
933 /* allocation an array of gmlConstantObj's */
934 constantList->numconstants = numnames;
935 constantList->constants = (gmlConstantObj *) malloc(sizeof(gmlConstantObj)*constantList->numconstants);
936 if (constantList->constants == NULL)
937 {
938 msSetError(MS_MEMERR, "Out of memory allocating %u bytes.\n", "msGMLGetConstants()",
939 sizeof(gmlConstantObj)*constantList->numconstants);
940 free(constantList);
941 return NULL;
942 }
943
944
945 for(i=0; i<constantList->numconstants; i++) {
946 constant = &(constantList->constants[i]);
947
948 constant->name = msStrdup(names[i]); /* initialize a few things */
949 constant->value = NULL;
950 constant->type = NULL;
951
952 snprintf(tag, 64, "%s_value", constant->name);
953 if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL)
954 constant->value = msStrdup(value);
955
956 snprintf(tag, 64, "%s_type", constant->name);
957 if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL)
958 constant->type = msStrdup(value);
959 }
960
961 msFreeCharArray(names, numnames);
962 }
963
964 return constantList;
965}
966
967void msGMLFreeConstants(gmlConstantListObj *constantList)
968{

Callers 3

msGMLWriteQueryFunction · 0.85
msGMLWriteWFSQueryFunction · 0.85
msWFSDescribeFeatureTypeFunction · 0.85

Calls 5

msOWSLookupMetadataFunction · 0.85
msStringSplitFunction · 0.85
msSetErrorFunction · 0.85
msStrdupFunction · 0.85
msFreeCharArrayFunction · 0.85

Tested by

no test coverage detected