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

Function msSOSAddMemberNodeObservation

mapogcsos.c:1013–1089  ·  view source on GitHub ↗

/ msSOSAddMemberNodeObservation */ / Add a member node used for getObservation request using */ Observation as the result format. */ /

Source from the content-addressed store, hash-verified

1011/* Observation as the result format. */
1012/************************************************************************/
1013xmlNodePtr msSOSAddMemberNodeObservation(xmlNsPtr psNsGml, xmlNsPtr psNsSos, xmlNsPtr psNsOm, xmlNsPtr psNsSwe, xmlNsPtr psNsXLink, xmlNodePtr psParent, mapObj *map, layerObj *lp, const char *pszProcedure)
1014{
1015 char *pszTmp = NULL;
1016 xmlNodePtr psNode=NULL, psObsNode=NULL, psMemberNode=NULL;
1017 layerObj *lpfirst;
1018 const char *value = NULL;
1019
1020 /*always featch the first layer that has the same offering id and observered propery.
1021 This allows to only define all the attributes and components on the first layer if the user
1022 wants to present several mapserver layers as the same offering.*/
1023 lpfirst = msSOSGetFirstLayerForOffering(map,
1024 msOWSLookupMetadata(&(lp->metadata), "S",
1025 "offering_id"),
1026 msOWSLookupMetadata(&(lp->metadata), "S",
1027 "observedproperty_id"));
1028 if (psParent)
1029 {
1030 psMemberNode = xmlNewChild(psParent, NULL, BAD_CAST "member", NULL);
1031 psObsNode = xmlNewChild(psMemberNode, NULL, BAD_CAST "Observation", NULL);
1032
1033 /*time*/
1034 /* ??TODO : sampling time is a manadatory element but uses a non mandatory metadata sos_offering_timeextent */
1035 value = msOWSLookupMetadata(&(lp->metadata), "S", "offering_timeextent");
1036 if (value)
1037 {
1038 char **tokens;
1039 int n;
1040 char *pszEndTime = NULL;
1041 tokens = msStringSplit(value, '/', &n);
1042 if (tokens==NULL || (n != 1 && n!=2)) {
1043 msSetError(MS_SOSERR, "Wrong number of arguments for sos_offering_timeextent.",
1044 "msSOSGetObservation()");
1045 msSOSException(map, "sos_offering_timeextent", "InvalidParameterValue");
1046 return NULL;
1047 }
1048
1049 if (n == 2) /* end time is empty. It is going to be set as "now*/
1050 pszEndTime = tokens[1];
1051
1052 psNode = xmlAddChild(psObsNode, msSOSAddTimeNode(psNsOm, psNsGml, tokens[0], pszEndTime));
1053 msFreeCharArray(tokens, n);
1054
1055 }
1056
1057 /* procedure */
1058 if (pszProcedure) /*this should always be true since procedure is a manadtory element*/
1059 {
1060 if (! msOWSLookupMetadata(&(lp->metadata), "S", "procedure_item") && msOWSLookupMetadata(&(lp->metadata), "S", "procedure"))
1061 xmlAddSibling(psNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"sos_procedure_item\" missing for sos:procedure. If you have more than 1 procedures, sos:procedure will output them incorrectly."));
1062
1063 pszTmp = msStringConcatenate(pszTmp, "urn:ogc:def:procedure:");
1064 pszTmp = msStringConcatenate(pszTmp, (char *)pszProcedure);
1065 psNode = xmlNewChild(psObsNode, NULL, BAD_CAST "procedure", NULL);
1066 /* xmlNewNsProp(psNode, xmlNewNs(NULL, BAD_CAST "http://www.w3.org/1999/xlink", BAD_CAST "xlink"), BAD_CAST "href", BAD_CAST pszTmp); */
1067 xmlNewNsProp(psNode, psNsXLink, BAD_CAST "href", BAD_CAST pszTmp);
1068 msFree(pszTmp);
1069 pszTmp = NULL;
1070 }

Callers 1

msSOSGetObservationFunction · 0.85

Calls 14

msOWSLookupMetadataFunction · 0.85
msStringSplitFunction · 0.85
msSetErrorFunction · 0.85
msSOSExceptionFunction · 0.85
msSOSAddTimeNodeFunction · 0.85
msFreeCharArrayFunction · 0.85
msStringConcatenateFunction · 0.85
msFreeFunction · 0.85
msLayerOpenFunction · 0.85
msLayerGetItemsFunction · 0.85
msSOSAddPropertyNodeFunction · 0.85

Tested by

no test coverage detected