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

Function msWMSSetTimePattern

mapwms.c:215–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215void msWMSSetTimePattern(const char *timepatternstring, char *timestring)
216{
217 char *time = NULL;
218 char **atimes, **tokens = NULL;
219 int numtimes, ntmp, i = 0;
220 char *tmpstr = NULL;
221
222 if (timepatternstring && timestring)
223 {
224 /* parse the time parameter to extract a distinct time. */
225 /* time value can be dicrete times (eg 2004-09-21), */
226 /* multiple times (2004-09-21, 2004-09-22, ...) */
227 /* and range(s) (2004-09-21/2004-09-25, 2004-09-27/2004-09-29) */
228 if (strstr(timestring, ",") == NULL &&
229 strstr(timestring, "/") == NULL) /* discrete time */
230 {
231 time = msStrdup(timestring);
232 }
233 else
234 {
235 atimes = msStringSplit (timestring, ',', &numtimes);
236 if (numtimes >=1 && atimes)
237 {
238 tokens = msStringSplit(atimes[0], '/', &ntmp);
239 if (ntmp == 2 && tokens) /* range */
240 {
241 time = msStrdup(tokens[0]);
242 }
243 else /* multiple times */
244 {
245 time = msStrdup(atimes[0]);
246 }
247 msFreeCharArray(tokens, ntmp);
248 msFreeCharArray(atimes, numtimes);
249 }
250 }
251 /* get the pattern to use */
252 if (time)
253 {
254 tokens = msStringSplit(timepatternstring, ',', &ntmp);
255 if (tokens && ntmp >= 1)
256 {
257 for (i=0; i<ntmp; i++)
258 {
259 if (tokens[i] && strlen(tokens[i]) > 0)
260 {
261 msStringTrimBlanks(tokens[i]);
262 tmpstr = msStringTrimLeft(tokens[i]);
263 if (msTimeMatchPattern(time, tmpstr) == MS_TRUE)
264 {
265 msSetLimitedPattersToUse(tmpstr);
266 break;
267 }
268 }
269 }
270 msFreeCharArray(tokens, ntmp);
271 }
272 free(time);

Callers 1

msWMSApplyTimeFunction · 0.85

Calls 7

msStrdupFunction · 0.85
msStringSplitFunction · 0.85
msFreeCharArrayFunction · 0.85
msStringTrimBlanksFunction · 0.85
msStringTrimLeftFunction · 0.85
msTimeMatchPatternFunction · 0.85
msSetLimitedPattersToUseFunction · 0.85

Tested by

no test coverage detected