Skip to content
This repository
Newer
Older
100644 1715 lines (1456 sloc) 63.039 kb
6d276a00 » warmerdam
2004-10-21 Added standardized headers. Added MS_CVSID().
1 /******************************************************************************
2 *
3 * Project: MapServer
4 * Purpose: MapServer CGI mainline.
5 * Author: Steve Lime and the MapServer team.
6 *
7 ******************************************************************************
ec3dabc5 » dmorissette
2005-06-14 Updated copyright date to 2005
8 * Copyright (c) 1996-2005 Regents of the University of Minnesota.
6d276a00 » warmerdam
2004-10-21 Added standardized headers. Added MS_CVSID().
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies of this Software or works derived from this Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ******************************************************************************
28 *
29 * $Log$
7c6a9ffd » warmerdam
2007-02-13 msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
30 * Revision 1.155 2007/02/13 04:44:54 frank
31 * msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
32 * returns MS_FAILURE and there is still an error on the stack, report it.
33 * This ensure that errors that can't be issued as exceptions still get
34 * reported (such as reports that the service isn't compiled in) (bug 2025)
35 *
cabf2b8a » sdlime
2006-12-26 Change validation metadata name from foo_pattern to a more descriptiv…
36 * Revision 1.154 2006/12/26 21:07:58 sdlime
37 * Change validation metadata name from foo_pattern to a more descriptive foo_validation_pattern.
38 *
a41113d5 » sdlime
2006-12-26 Added support for checking runtime substitution values against a patt…
39 * Revision 1.153 2006/12/26 20:56:38 sdlime
40 * Added support for checking runtime substitution values against a pattern (e.g. regex). (bug 1918)
41 *
c6f51d0b » sdlime
2006-08-29 Fixed buffer overflow with POSTs and huge numbers of name/value pairs…
42 * Revision 1.152 2006/08/29 01:56:53 sdlime
43 * Fixed buffer overflow with POSTs and huge numbers of name/value pairs. Reduced MAX_PARAMS (now MS_MAX_CGI_PARAMS) from 10,000 to 100.
44 *
6c9248dc » warmerdam
2006-07-05 avoid mapservobj leak in some error cases
45 * Revision 1.151 2006/07/05 05:50:14 frank
46 * avoid mapservobj leak in some error cases
47 *
19105d6b » sdlime
2005-12-14 Patched mapserv.c to use legendformat and browseformat (both default …
48 * Revision 1.150 2005/12/14 19:55:07 sdlime
49 * Patched mapserv.c to use legendformat and browseformat (both default to text/html). (bug 1518)
50 *
403f572a » Assefa Yewondwossen
2005-10-13 Added variable substitution capability for layer's tileindex (Bug 1497).
51 * Revision 1.149 2005/10/13 18:28:52 assefa
52 * Added variable substitution capability for layer's tileindex (Bug 1497).
53 *
b6a08ea6 » warmerdam
2005-07-25 Removed unnecessary strdup() calls for QUERY_STRING commandline arg.
54 * Revision 1.148 2005/07/25 14:24:04 frank
55 * Removed unnecessary strdup() calls for QUERY_STRING commandline arg.
56 *
ec3dabc5 » dmorissette
2005-06-14 Updated copyright date to 2005
57 * Revision 1.147 2005/06/14 16:03:34 dan
58 * Updated copyright date to 2005
59 *
6dff9ccf » dmorissette
2005-03-28 Make sure we always use PID in temp image filenames generated by
60 * Revision 1.146 2005/03/28 02:38:55 dan
61 * Make sure we always use PID in temp image filenames generated by
62 * msProcessTemplate() (bug 1299)
63 *
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
64 * Revision 1.145 2005/02/18 03:06:47 dan
65 * Turned all C++ (//) comments into C comments (bug 1238)
66 *
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
67 * Revision 1.144 2005/02/09 21:51:17 frank
68 * added msForceTmpFileBase and -tmpbase mapserv switch
69 *
e5f634d3 » sdlime
2005-01-28 Applied patch to make function prototypes ANSI C compliant. Thanks to…
70 * Revision 1.143 2005/01/28 06:16:54 sdlime
71 * Applied patch to make function prototypes ANSI C compliant. Thanks to Petter Reinholdtsen. This fixes but 1181.
72 *
fd8d7a2e » warmerdam
2004-12-09 clear error list before processing new request in fastcgi mode
73 * Revision 1.142 2004/12/09 21:20:19 frank
74 * clear error list before processing new request in fastcgi mode
75 *
40e7c879 » sdlime
2004-11-11 Fixed enhancement request 1004, plus a bit more. ERROR and EMPTY prop…
76 * Revision 1.141 2004/11/11 19:55:24 sdlime
77 * Fixed enhancement request 1004, plus a bit more. ERROR and EMPTY properties are now treated as URL templates so for example you could pass the map xy value for a bombed query (perhaps to another service). Also added [errmsg] and [errmsg_esc] tags to the templating code so that the current error stack can be output. Various error messages are delimited by semi-colons.
78 *
134f59d2 » Assefa Yewondwossen
2004-11-09 Used to send html output with emebed flash file when format was set t…
79 * Revision 1.140 2004/11/09 21:34:31 assefa
80 * Used to send html output with emebed flash file when format was set to flash.
81 * Now send directly swf.
82 *
23ecd5d5 » warmerdam
2004-11-09 avoid lots of casting warnings
83 * Revision 1.139 2004/11/09 16:24:19 frank
84 * avoid lots of casting warnings
85 *
68d86aae » warmerdam
2004-11-04 Removed unused variable.
86 * Revision 1.138 2004/11/04 21:47:36 frank
87 * Removed unused variable.
88 *
aa5517dd » warmerdam
2004-11-03 Free mapServObj properly in mapserv.c in OWS dispatch case to fix minor
89 * Revision 1.137 2004/11/03 17:07:13 frank
90 * Free mapServObj properly in mapserv.c in OWS dispatch case to fix minor
91 * memory leaks.
92 *
a5ebd339 » Assefa Yewondwossen
2004-11-02 Add a 2nd optional argument to msLoadMapContext function (Bug 1023).
93 * Revision 1.136 2004/11/02 21:01:00 assefa
94 * Add a 2nd optional argument to msLoadMapContext function (Bug 1023).
95 *
eba56f96 » Assefa Yewondwossen
2004-11-01 Work on Bug 1023 : only layers coming from a mapcontext use the
96 * Revision 1.135 2004/11/01 23:24:57 assefa
97 * Work on Bug 1023 : only layers coming from a mapcontext use the
98 * wms_name to set status on/off.
99 *
1d057192 » warmerdam
2004-10-29 Added a bit of debugging for new requests in fastcgi mode, with the
100 * Revision 1.134 2004/10/29 22:32:36 frank
101 * Added a bit of debugging for new requests in fastcgi mode, with the
102 * process id.
103 *
317843f4 » warmerdam
2004-10-28 added win32/fastcgi support using atexit()
104 * Revision 1.133 2004/10/28 20:12:31 frank
105 * added win32/fastcgi support using atexit()
106 *
fbc84bcc » warmerdam
2004-10-28 Implemented signal catching on unix (non-win32) platforms. The signal
107 * Revision 1.132 2004/10/28 19:12:51 frank
108 * Implemented signal catching on unix (non-win32) platforms. The signal
109 * catcher calls msCleanup() which most importantly will close database
110 * connections open in the pool. This is most useful for the fastcgi case, but
111 * it could be good in a pure cgi case too where a long running cgi is
112 * killed for some reason.
113 *
3b5d5e52 » dmorissette
2004-10-28 Fixed WMS GetLegendGraphic which was returning an exception (GD error)
114 * Revision 1.131 2004/10/28 18:16:17 dan
115 * Fixed WMS GetLegendGraphic which was returning an exception (GD error)
116 * when requested layer was out of scale (bug 1006)
117 *
6d276a00 » warmerdam
2004-10-21 Added standardized headers. Added MS_CVSID().
118 * Revision 1.130 2004/10/21 04:30:54 frank
119 * Added standardized headers. Added MS_CVSID().
120 *
121 */
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
122
123 #ifdef USE_FASTCGI
124 #define NO_FCGI_DEFINES
125 #include "fcgi_stdio.h"
126 #endif
127
abe3c7ac » sdlime
2000-04-11 Initial revision
128 #include "mapserv.h"
129
fbc84bcc » warmerdam
2004-10-28 Implemented signal catching on unix (non-win32) platforms. The signal
130 #ifndef WIN32
131 #include <signal.h>
132 #endif
133
6d276a00 » warmerdam
2004-10-21 Added standardized headers. Added MS_CVSID().
134 MS_CVSID("$Id$")
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
135
136
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
137 mapservObj* msObj;
abe3c7ac » sdlime
2000-04-11 Initial revision
138
139 int writeLog(int show_error)
140 {
141 FILE *stream;
142 int i;
143 time_t t;
a332c37c » Julien-Samuel Lacroix
2002-09-17 Remove all chdir() function and replace them with the new msBuildPath…
144 char szPath[MS_MAXPATHLEN];
abe3c7ac » sdlime
2000-04-11 Initial revision
145
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
146 if(!msObj->Map) return(0);
147 if(!msObj->Map->web.log) return(0);
abe3c7ac » sdlime
2000-04-11 Initial revision
148
c5efdbf6 » sdlime
2002-09-20 Swapped map_path for mappath for consistency.
149 if((stream = fopen(msBuildPath(szPath, msObj->Map->mappath,
a332c37c » Julien-Samuel Lacroix
2002-09-17 Remove all chdir() function and replace them with the new msBuildPath…
150 msObj->Map->web.log),"a")) == NULL) {
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
151 msSetError(MS_IOERR, msObj->Map->web.log, "writeLog()");
abe3c7ac » sdlime
2000-04-11 Initial revision
152 return(-1);
153 }
154
155 t = time(NULL);
156 fprintf(stream,"%s,",chop(ctime(&t)));
157 fprintf(stream,"%d,",(int)getpid());
158
159 if(getenv("REMOTE_ADDR") != NULL)
160 fprintf(stream,"%s,",getenv("REMOTE_ADDR"));
161 else
162 fprintf(stream,"NULL,");
163
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
164 fprintf(stream,"%s,",msObj->Map->name);
165 fprintf(stream,"%d,",msObj->Mode);
abe3c7ac » sdlime
2000-04-11 Initial revision
166
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
167 fprintf(stream,"%f %f %f %f,", msObj->Map->extent.minx, msObj->Map->extent.miny, msObj->Map->extent.maxx, msObj->Map->extent.maxy);
abe3c7ac » sdlime
2000-04-11 Initial revision
168
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
169 fprintf(stream,"%f %f,", msObj->MapPnt.x, msObj->MapPnt.y);
abe3c7ac » sdlime
2000-04-11 Initial revision
170
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
171 for(i=0;i<msObj->NumLayers;i++)
172 fprintf(stream, "%s ", msObj->Layers[i]);
abe3c7ac » sdlime
2000-04-11 Initial revision
173 fprintf(stream,",");
174
175 if(show_error == MS_TRUE)
176 msWriteError(stream);
177 else
178 fprintf(stream, "normal execution");
179
180 fprintf(stream,"\n");
181
182 fclose(stream);
183 return(0);
184 }
185
e5f634d3 » sdlime
2005-01-28 Applied patch to make function prototypes ANSI C compliant. Thanks to…
186 void writeError(void)
abe3c7ac » sdlime
2000-04-11 Initial revision
187 {
47eaecfe » warmerdam
2002-01-09 avoid use of ms_error global
188 errorObj *ms_error = msGetErrorObj();
abe3c7ac » sdlime
2000-04-11 Initial revision
189
190 writeLog(MS_TRUE);
191
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
192 if(!msObj->Map) {
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
193 msIO_printf("Content-type: text/html%c%c",10,10);
194 msIO_printf("<HTML>\n");
195 msIO_printf("<HEAD><TITLE>MapServer Message</TITLE></HEAD>\n");
196 msIO_printf("<!-- %s -->\n", msGetVersion());
197 msIO_printf("<BODY BGCOLOR=\"#FFFFFF\">\n");
abe3c7ac » sdlime
2000-04-11 Initial revision
198 msWriteError(stdout);
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
199 msIO_printf("</BODY></HTML>");
6c9248dc » warmerdam
2006-07-05 avoid mapservobj leak in some error cases
200 msFreeMapServObj(msObj);
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
201 msCleanup();
abe3c7ac » sdlime
2000-04-11 Initial revision
202 exit(0);
203 }
204
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
205 if((ms_error->code == MS_NOTFOUND) && (msObj->Map->web.empty)) {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
206 /* msRedirect(msObj->Map->web.empty); */
40e7c879 » sdlime
2004-11-11 Fixed enhancement request 1004, plus a bit more. ERROR and EMPTY prop…
207 if(msReturnURL(msObj, msObj->Map->web.empty, BROWSE) != MS_SUCCESS) {
208 msIO_printf("Content-type: text/html%c%c",10,10);
209 msIO_printf("<HTML>\n");
210 msIO_printf("<HEAD><TITLE>MapServer Message</TITLE></HEAD>\n");
211 msIO_printf("<!-- %s -->\n", msGetVersion());
212 msIO_printf("<BODY BGCOLOR=\"#FFFFFF\">\n");
213 msWriteError(stdout);
214 msIO_printf("</BODY></HTML>");
215 }
abe3c7ac » sdlime
2000-04-11 Initial revision
216 } else {
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
217 if(msObj->Map->web.error) {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
218 /* msRedirect(msObj->Map->web.error); */
40e7c879 » sdlime
2004-11-11 Fixed enhancement request 1004, plus a bit more. ERROR and EMPTY prop…
219 if(msReturnURL(msObj, msObj->Map->web.error, BROWSE) != MS_SUCCESS) {
220 msIO_printf("Content-type: text/html%c%c",10,10);
221 msIO_printf("<HTML>\n");
222 msIO_printf("<HEAD><TITLE>MapServer Message</TITLE></HEAD>\n");
223 msIO_printf("<!-- %s -->\n", msGetVersion());
224 msIO_printf("<BODY BGCOLOR=\"#FFFFFF\">\n");
225 msWriteError(stdout);
226 msIO_printf("</BODY></HTML>");
227 }
abe3c7ac » sdlime
2000-04-11 Initial revision
228 } else {
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
229 msIO_printf("Content-type: text/html%c%c",10,10);
230 msIO_printf("<HTML>\n");
231 msIO_printf("<HEAD><TITLE>MapServer Message</TITLE></HEAD>\n");
232 msIO_printf("<!-- %s -->\n", msGetVersion());
233 msIO_printf("<BODY BGCOLOR=\"#FFFFFF\">\n");
abe3c7ac » sdlime
2000-04-11 Initial revision
234 msWriteError(stdout);
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
235 msIO_printf("</BODY></HTML>");
abe3c7ac » sdlime
2000-04-11 Initial revision
236 }
237 }
238
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
239 /* Clean-up (the following are not stored as part of the msObj) */
3caaeceb » sdlime
2003-08-23 Fixed bug 414: clean up in mapserv.c and mapserv.h.
240 if(QueryItem) free(QueryItem);
241 if(QueryString) free(QueryString);
242 if(QueryLayer) free(QueryLayer);
243 if(SelectLayer) free(SelectLayer);
244 if(QueryFile) free(QueryFile);
abe3c7ac » sdlime
2000-04-11 Initial revision
245
7d440dba » sdlime
2002-04-05 Class MINSCALE/MAXSCALE enabled.
246 msFreeMapServObj(msObj);
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
247 msCleanup();
abe3c7ac » sdlime
2000-04-11 Initial revision
248
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
249 exit(0); /* bail */
abe3c7ac » sdlime
2000-04-11 Initial revision
250 }
251
58949bff » sdlime
2001-02-07 Added support to mapserv.c to allow a default map file to be define u…
252 /*
253 ** Converts a string (e.g. form parameter) to a double, first checking the format against
254 ** a regular expression. Dumps an error immediately if the format test fails.
255 */
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
256 static double getNumeric(char *s)
abe3c7ac » sdlime
2000-04-11 Initial revision
257 {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
258 char *err;
4183deed » sdlime
2004-06-02 Removed spurrious DOS linefeeds from mapserv.c and mapserv_fcgi.c.
259 double rv;
260
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
261 rv = strtod(s, &err);
262 if (*err) {
263 msSetError(MS_TYPEERR, NULL, "getNumeric()");
abe3c7ac » sdlime
2000-04-11 Initial revision
264 writeError();
265 }
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
266 return rv;
abe3c7ac » sdlime
2000-04-11 Initial revision
267 }
268
58949bff » sdlime
2001-02-07 Added support to mapserv.c to allow a default map file to be define u…
269 /*
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
270 ** Extract Map File name from params and load it.
271 ** Returns map object or NULL on error.
58949bff » sdlime
2001-02-07 Added support to mapserv.c to allow a default map file to be define u…
272 */
e5f634d3 » sdlime
2005-01-28 Applied patch to make function prototypes ANSI C compliant. Thanks to…
273 mapObj *loadMap(void)
abe3c7ac » sdlime
2000-04-11 Initial revision
274 {
0c3989f7 » Assefa Yewondwossen
2003-01-07 Correct Compilation error.
275 int i,j,k;
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
276 mapObj *map = NULL;
a41113d5 » sdlime
2006-12-26 Added support for checking runtime substitution values against a patt…
277 char *tmpstr, *key, *value=NULL;
00a3d3ea » Assefa Yewondwossen
2004-10-15 Add support for OGC mapcontext through mapserver cgi : Bug 946.
278
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
279 for(i=0;i<msObj->request->NumParams;i++) /* find the mapfile parameter first */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
280 if(strcasecmp(msObj->request->ParamNames[i], "map") == 0) break;
abe3c7ac » sdlime
2000-04-11 Initial revision
281
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
282 if(i == msObj->request->NumParams) {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
283 if(getenv("MS_MAPFILE")) /* has a default file has not been set */
90cc4642 » dmorissette
2002-04-22 Added optional new_map_path arg to msLoadMap()
284 map = msLoadMap(getenv("MS_MAPFILE"), NULL);
58949bff » sdlime
2001-02-07 Added support to mapserv.c to allow a default map file to be define u…
285 else {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
286 msSetError(MS_WEBERR, "CGI variable \"map\" is not set.", "loadMap()"); /* no default, outta here */
58949bff » sdlime
2001-02-07 Added support to mapserv.c to allow a default map file to be define u…
287 writeError();
288 }
d1494765 » sdlime
2001-11-08 Added support for using environment variables as aliases for mapfiles.
289 } else {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
290 if(getenv(msObj->request->ParamValues[i])) /* an environment references the actual file to use */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
291 map = msLoadMap(getenv(msObj->request->ParamValues[i]), NULL);
d1494765 » sdlime
2001-11-08 Added support for using environment variables as aliases for mapfiles.
292 else
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
293 map = msLoadMap(msObj->request->ParamValues[i], NULL);
d1494765 » sdlime
2001-11-08 Added support for using environment variables as aliases for mapfiles.
294 }
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
295
296 if(!map) writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
297
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
298 /* check for any %variable% substitutions here, also do any map_ changes, we do this here so WMS/WFS */
299 /* services can take advantage of these "vendor specific" extensions */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
300 for(i=0;i<msObj->request->NumParams;i++) {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
301 if(strncasecmp(msObj->request->ParamNames[i],"map_",4) == 0) { /* check to see if there are any additions to the mapfile */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
302 if(msLoadMapString(map, msObj->request->ParamNames[i], msObj->request->ParamValues[i]) == -1) writeError();
a41113d5 » sdlime
2006-12-26 Added support for checking runtime substitution values against a patt…
303 continue;
34099bd6 » sdlime
2003-06-15 Moved code to alter the mapfile via a URL to loadMap in mapserv.c so …
304 }
305
a41113d5 » sdlime
2006-12-26 Added support for checking runtime substitution values against a patt…
306 /* subtitution string */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
307 tmpstr = (char *)malloc(sizeof(char)*strlen(msObj->request->ParamNames[i]) + 3);
308 sprintf(tmpstr,"%%%s%%", msObj->request->ParamNames[i]);
a41113d5 » sdlime
2006-12-26 Added support for checking runtime substitution values against a patt…
309
310 /* validation pattern metadata key */
cabf2b8a » sdlime
2006-12-26 Change validation metadata name from foo_pattern to a more descriptiv…
311 key = (char *)malloc(sizeof(char)*strlen(msObj->request->ParamNames[i]) + 20);
312 sprintf(key,"%s_validation_pattern", msObj->request->ParamNames[i]);
a41113d5 » sdlime
2006-12-26 Added support for checking runtime substitution values against a patt…
313
09dbaa05 » dmorissette
2003-01-13 Fixed seg. fault in %variable% code in loadMap(), msObj->Map was acce…
314 for(j=0; j<map->numlayers; j++) {
a41113d5 » sdlime
2006-12-26 Added support for checking runtime substitution values against a patt…
315 value = msLookupHashTable(&(map->layers[j].metadata), key);
316 if(value) { /* validate parameter value */
317 if(msEvalRegex(value, msObj->request->ParamValues[i]) == MS_FALSE) {
318 msSetError(MS_WEBERR, "Parameter '%s' value fails to validate.", "loadMap()", msObj->request->ParamNames[i]);
319 writeError();
320 }
321 }
322
323 if(map->layers[j].data && (strstr(map->layers[j].data, tmpstr) != NULL))
324 map->layers[j].data = gsub(map->layers[j].data, tmpstr, msObj->request->ParamValues[i]);
325 if(map->layers[j].tileindex && (strstr(map->layers[j].tileindex, tmpstr) != NULL))
326 map->layers[j].tileindex = gsub(map->layers[j].tileindex, tmpstr, msObj->request->ParamValues[i]);
327 if(map->layers[j].connection && (strstr(map->layers[j].connection, tmpstr) != NULL))
328 map->layers[j].connection = gsub(map->layers[j].connection, tmpstr, msObj->request->ParamValues[i]);
329 if(map->layers[j].filter.string && (strstr(map->layers[j].filter.string, tmpstr) != NULL))
330 map->layers[j].filter.string = gsub(map->layers[j].filter.string, tmpstr, msObj->request->ParamValues[i]);
331 for(k=0; k<map->layers[j].numclasses; k++) {
332 if(map->layers[j].class[k].expression.string && (strstr(map->layers[j].class[k].expression.string, tmpstr) != NULL))
333 map->layers[j].class[k].expression.string = gsub(map->layers[j].class[k].expression.string, tmpstr, msObj->request->ParamValues[i]);
334 }
2fcc1385 » sdlime
2003-01-07 Added DATA to the list of map file elements checked for %variable% su…
335 }
336
337 free(tmpstr);
a41113d5 » sdlime
2006-12-26 Added support for checking runtime substitution values against a patt…
338 free(key);
2fcc1385 » sdlime
2003-01-07 Added DATA to the list of map file elements checked for %variable% su…
339 }
340
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
341 /* check to see if a ogc map context is passed as argument. if there */
342 /* is one load it */
00a3d3ea » Assefa Yewondwossen
2004-10-15 Add support for OGC mapcontext through mapserver cgi : Bug 946.
343
344 for(i=0;i<msObj->request->NumParams;i++)
345 {
346 if(strcasecmp(msObj->request->ParamNames[i],"context") == 0)
347 {
348 if (msObj->request->ParamValues[i] &&
349 strlen(msObj->request->ParamValues[i]) > 0)
350 {
351 if (strncasecmp(msObj->request->ParamValues[i],"http",4) == 0)
352 {
353 if (msGetConfigOption(map, "CGI_CONTEXT_URL"))
a5ebd339 » Assefa Yewondwossen
2004-11-02 Add a 2nd optional argument to msLoadMapContext function (Bug 1023).
354 msLoadMapContextURL(map, msObj->request->ParamValues[i], MS_FALSE);
00a3d3ea » Assefa Yewondwossen
2004-10-15 Add support for OGC mapcontext through mapserver cgi : Bug 946.
355 }
356 else
a5ebd339 » Assefa Yewondwossen
2004-11-02 Add a 2nd optional argument to msLoadMapContext function (Bug 1023).
357 msLoadMapContext(map, msObj->request->ParamValues[i], MS_FALSE);
00a3d3ea » Assefa Yewondwossen
2004-10-15 Add support for OGC mapcontext through mapserver cgi : Bug 946.
358 }
359 }
360 }
361
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
362 return map;
363 }
364
365 /*
366 ** Process CGI parameters.
367 */
e5f634d3 » sdlime
2005-01-28 Applied patch to make function prototypes ANSI C compliant. Thanks to…
368 void loadForm(void)
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
369 {
0c3989f7 » Assefa Yewondwossen
2003-01-07 Correct Compilation error.
370 int i,j,n;
3caaeceb » sdlime
2003-08-23 Fixed bug 414: clean up in mapserv.c and mapserv.h.
371 char **tokens=NULL;
dc2f9159 » Assefa Yewondwossen
2002-05-23 Add support for the Rosa applet parameters.
372 int rosa_type=0;
abe3c7ac » sdlime
2000-04-11 Initial revision
373
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
374 for(i=0;i<msObj->request->NumParams;i++) { /* now process the rest of the form variables */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
375 if(strlen(msObj->request->ParamValues[i]) == 0)
abe3c7ac » sdlime
2000-04-11 Initial revision
376 continue;
377
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
378 if(strcasecmp(msObj->request->ParamNames[i],"queryfile") == 0) {
379 QueryFile = strdup(msObj->request->ParamValues[i]);
abe3c7ac » sdlime
2000-04-11 Initial revision
380 continue;
381 }
382
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
383 if(strcasecmp(msObj->request->ParamNames[i],"savequery") == 0) {
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
384 msObj->SaveQuery = MS_TRUE;
abe3c7ac » sdlime
2000-04-11 Initial revision
385 continue;
386 }
387
623e1c6f » sdlime
2002-11-21 Implemented the security measures necessary to limit access to files …
388 /* Insecure as implemented, need to save someplace non accessible by everyone in the universe
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
389 if(strcasecmp(msObj->request->ParamNames[i],"savemap") == 0) {
623e1c6f » sdlime
2002-11-21 Implemented the security measures necessary to limit access to files …
390 msObj->SaveMap = MS_TRUE;
391 continue;
392 }
393 */
abe3c7ac » sdlime
2000-04-11 Initial revision
394
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
395 if(strcasecmp(msObj->request->ParamNames[i],"zoom") == 0) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
396 msObj->Zoom = getNumeric(msObj->request->ParamValues[i]);
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
397 if((msObj->Zoom > MAXZOOM) || (msObj->Zoom < MINZOOM)) {
abe3c7ac » sdlime
2000-04-11 Initial revision
398 msSetError(MS_WEBERR, "Zoom value out of range.", "loadForm()");
399 writeError();
400 }
401 continue;
402 }
403
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
404 if(strcasecmp(msObj->request->ParamNames[i],"zoomdir") == 0) {
23ecd5d5 » warmerdam
2004-11-09 avoid lots of casting warnings
405 msObj->ZoomDirection = (int)getNumeric(msObj->request->ParamValues[i]);
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
406 if((msObj->ZoomDirection != -1) && (msObj->ZoomDirection != 1) && (msObj->ZoomDirection != 0)) {
abe3c7ac » sdlime
2000-04-11 Initial revision
407 msSetError(MS_WEBERR, "Zoom direction must be 1, 0 or -1.", "loadForm()");
408 writeError();
409 }
410 continue;
411 }
412
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
413 if(strcasecmp(msObj->request->ParamNames[i],"zoomsize") == 0) { /* absolute zoom magnitude */
23ecd5d5 » warmerdam
2004-11-09 avoid lots of casting warnings
414 ZoomSize = (int) getNumeric(msObj->request->ParamValues[i]);
abe3c7ac » sdlime
2000-04-11 Initial revision
415 if((ZoomSize > MAXZOOM) || (ZoomSize < 1)) {
416 msSetError(MS_WEBERR, "Invalid zoom size.", "loadForm()");
417 writeError();
418 }
419 continue;
420 }
421
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
422 if(strcasecmp(msObj->request->ParamNames[i],"imgext") == 0) { /* extent of an existing image in a web application */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
423 tokens = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
424
425 if(!tokens) {
426 msSetError(MS_MEMERR, NULL, "loadForm()");
427 writeError();
428 }
429
430 if(n != 4) {
431 msSetError(MS_WEBERR, "Not enough arguments for imgext.", "loadForm()");
432 writeError();
433 }
434
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
435 msObj->ImgExt.minx = getNumeric(tokens[0]);
436 msObj->ImgExt.miny = getNumeric(tokens[1]);
437 msObj->ImgExt.maxx = getNumeric(tokens[2]);
438 msObj->ImgExt.maxy = getNumeric(tokens[3]);
abe3c7ac » sdlime
2000-04-11 Initial revision
439
440 msFreeCharArray(tokens, 4);
441 continue;
442 }
443
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
444 if(strcasecmp(msObj->request->ParamNames[i],"searchmap") == 0) {
abe3c7ac » sdlime
2000-04-11 Initial revision
445 SearchMap = MS_TRUE;
446 continue;
447 }
448
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
449 if(strcasecmp(msObj->request->ParamNames[i],"id") == 0) {
450 strncpy(msObj->Id, msObj->request->ParamValues[i], IDSIZE);
3e913150 » sdlime
2000-09-15 Many small edits, most of GD-1.8 upgrade. Organized chaos at this poi…
451 continue;
452 }
453
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
454 if(strcasecmp(msObj->request->ParamNames[i],"mapext") == 0) { /* extent of the new map or query */
abe3c7ac » sdlime
2000-04-11 Initial revision
455
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
456 if(strncasecmp(msObj->request->ParamValues[i],"shape",5) == 0)
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
457 msObj->UseShapes = MS_TRUE;
abe3c7ac » sdlime
2000-04-11 Initial revision
458 else {
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
459 tokens = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
460
461 if(!tokens) {
462 msSetError(MS_MEMERR, NULL, "loadForm()");
463 writeError();
464 }
465
466 if(n != 4) {
467 msSetError(MS_WEBERR, "Not enough arguments for mapext.", "loadForm()");
468 writeError();
469 }
470
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
471 msObj->Map->extent.minx = getNumeric(tokens[0]);
472 msObj->Map->extent.miny = getNumeric(tokens[1]);
473 msObj->Map->extent.maxx = getNumeric(tokens[2]);
474 msObj->Map->extent.maxy = getNumeric(tokens[3]);
abe3c7ac » sdlime
2000-04-11 Initial revision
475
476 msFreeCharArray(tokens, 4);
477
478 #ifdef USE_PROJ
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
479 /* make sure both coordinates are in range! */
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
480 if(msObj->Map->projection.proj && !pj_is_latlong(msObj->Map->projection.proj)
481 && (msObj->Map->extent.minx >= -180.0 && msObj->Map->extent.minx <= 180.0)
83fd48e0 » sdlime
2003-08-20 Fixed obscure error with auto projection of map extents with scalebar…
482 && (msObj->Map->extent.miny >= -90.0 && msObj->Map->extent.miny <= 90.0)
483 && (msObj->Map->extent.maxx >= -180.0 && msObj->Map->extent.maxx <= 180.0)
484 && (msObj->Map->extent.maxy >= -90.0 && msObj->Map->extent.maxy <= 90.0))
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
485 msProjectRect(&(msObj->Map->latlon),
486 &(msObj->Map->projection),
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
487 &(msObj->Map->extent)); /* extent is a in lat/lon */
abe3c7ac » sdlime
2000-04-11 Initial revision
488 #endif
489
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
490 if((msObj->Map->extent.minx != msObj->Map->extent.maxx) && (msObj->Map->extent.miny != msObj->Map->extent.maxy)) { /* extent seems ok */
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
491 msObj->CoordSource = FROMUSERBOX;
abe3c7ac » sdlime
2000-04-11 Initial revision
492 QueryCoordSource = FROMUSERBOX;
493 }
494 }
495
496 continue;
497 }
498
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
499 if(strcasecmp(msObj->request->ParamNames[i],"minx") == 0) { /* extent of the new map, in pieces */
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
500 msObj->Map->extent.minx = getNumeric(msObj->request->ParamValues[i]);
abe3c7ac » sdlime
2000-04-11 Initial revision
501 continue;
502 }
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
503 if(strcasecmp(msObj->request->ParamNames[i],"maxx") == 0) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
504 msObj->Map->extent.maxx = getNumeric(msObj->request->ParamValues[i]);
abe3c7ac » sdlime
2000-04-11 Initial revision
505 continue;
506 }
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
507 if(strcasecmp(msObj->request->ParamNames[i],"miny") == 0) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
508 msObj->Map->extent.miny = getNumeric(msObj->request->ParamValues[i]);
abe3c7ac » sdlime
2000-04-11 Initial revision
509 continue;
510 }
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
511 if(strcasecmp(msObj->request->ParamNames[i],"maxy") == 0) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
512 msObj->Map->extent.maxy = getNumeric(msObj->request->ParamValues[i]);
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
513 msObj->CoordSource = FROMUSERBOX;
abe3c7ac » sdlime
2000-04-11 Initial revision
514 QueryCoordSource = FROMUSERBOX;
515 continue;
516 }
517
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
518 if(strcasecmp(msObj->request->ParamNames[i],"mapxy") == 0) { /* user map coordinate */
abe3c7ac » sdlime
2000-04-11 Initial revision
519
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
520 if(strncasecmp(msObj->request->ParamValues[i],"shape",5) == 0) {
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
521 msObj->UseShapes = MS_TRUE;
abe3c7ac » sdlime
2000-04-11 Initial revision
522 } else {
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
523 tokens = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
524
525 if(!tokens) {
526 msSetError(MS_MEMERR, NULL, "loadForm()");
527 writeError();
528 }
529
530 if(n != 2) {
531 msSetError(MS_WEBERR, "Not enough arguments for mapxy.", "loadForm()");
532 writeError();
533 }
534
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
535 msObj->MapPnt.x = getNumeric(tokens[0]);
536 msObj->MapPnt.y = getNumeric(tokens[1]);
abe3c7ac » sdlime
2000-04-11 Initial revision
537
538 msFreeCharArray(tokens, 2);
539
540 #ifdef USE_PROJ
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
541 if(msObj->Map->projection.proj && !pj_is_latlong(msObj->Map->projection.proj)
542 && (msObj->MapPnt.x >= -180.0 && msObj->MapPnt.x <= 180.0)
543 && (msObj->MapPnt.y >= -90.0 && msObj->MapPnt.y <= 90.0))
5dc8454e » sdlime
2004-10-15 Fixed small bug in mapserv.c for autoprojecting mapxy from latlon to …
544 msProjectPoint(&(msObj->Map->latlon),
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
545 &(msObj->Map->projection),
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
546 &msObj->MapPnt); /* point is a in lat/lon */
abe3c7ac » sdlime
2000-04-11 Initial revision
547 #endif
548
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
549 if(msObj->CoordSource == NONE) { /* don't override previous settings (i.e. buffer or scale ) */
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
550 msObj->CoordSource = FROMUSERPNT;
abe3c7ac » sdlime
2000-04-11 Initial revision
551 QueryCoordSource = FROMUSERPNT;
552 }
553 }
554 continue;
555 }
556
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
557 if(strcasecmp(msObj->request->ParamNames[i],"mapshape") == 0) { /* query shape */
abe3c7ac » sdlime
2000-04-11 Initial revision
558 lineObj line={0,NULL};
559 char **tmp=NULL;
560 int n, j;
561
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
562 tmp = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
563
564 if((line.point = (pointObj *)malloc(sizeof(pointObj)*(n/2))) == NULL) {
565 msSetError(MS_MEMERR, NULL, "loadForm()");
566 writeError();
567 }
568 line.numpoints = n/2;
569
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
570 msInitShape(&(msObj->SelectShape));
571 msObj->SelectShape.type = MS_SHAPE_POLYGON;
9914b679 » sdlime
2001-10-24 Fixed problem with mapshape option, input shape is now of MS_SHAPE_PO…
572
abe3c7ac » sdlime
2000-04-11 Initial revision
573 for(j=0; j<n/2; j++) {
574 line.point[j].x = atof(tmp[2*j]);
575 line.point[j].y = atof(tmp[2*j+1]);
576
577 #ifdef USE_PROJ
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
578 if(msObj->Map->projection.proj && !pj_is_latlong(msObj->Map->projection.proj)
b5cc8b5a » warmerdam
2001-03-21 use pj_is_latlong and io_projection
579 && (line.point[j].x >= -180.0 && line.point[j].x <= 180.0)
580 && (line.point[j].y >= -90.0 && line.point[j].y <= 90.0))
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
581 msProjectPoint(&(msObj->Map->latlon),
582 &(msObj->Map->projection),
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
583 &line.point[j]); /* point is a in lat/lon */
abe3c7ac » sdlime
2000-04-11 Initial revision
584 #endif
585 }
586
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
587 if(msAddLine(&msObj->SelectShape, &line) == -1) writeError();
9914b679 » sdlime
2001-10-24 Fixed problem with mapshape option, input shape is now of MS_SHAPE_PO…
588
589 msFree(line.point);
abe3c7ac » sdlime
2000-04-11 Initial revision
590 msFreeCharArray(tmp, n);
591
592 QueryCoordSource = FROMUSERSHAPE;
593 continue;
594 }
595
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
596 if(strcasecmp(msObj->request->ParamNames[i],"img.x") == 0) { /* mouse click, in pieces */
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
597 msObj->ImgPnt.x = getNumeric(msObj->request->ParamValues[i]);
df8c1e00 » sdlime
2003-09-24 Fixed bug 435. There is a new mapObj parameter called MAXSIZE. The de…
598 if((msObj->ImgPnt.x > (2*msObj->Map->maxsize)) || (msObj->ImgPnt.x < (-2*msObj->Map->maxsize))) {
abe3c7ac » sdlime
2000-04-11 Initial revision
599 msSetError(MS_WEBERR, "Coordinate out of range.", "loadForm()");
600 writeError();
601 }
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
602 msObj->CoordSource = FROMIMGPNT;
abe3c7ac » sdlime
2000-04-11 Initial revision
603 QueryCoordSource = FROMIMGPNT;
604 continue;
605 }
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
606 if(strcasecmp(msObj->request->ParamNames[i],"img.y") == 0) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
607 msObj->ImgPnt.y = getNumeric(msObj->request->ParamValues[i]);
df8c1e00 » sdlime
2003-09-24 Fixed bug 435. There is a new mapObj parameter called MAXSIZE. The de…
608 if((msObj->ImgPnt.y > (2*msObj->Map->maxsize)) || (msObj->ImgPnt.y < (-2*msObj->Map->maxsize))) {
abe3c7ac » sdlime
2000-04-11 Initial revision
609 msSetError(MS_WEBERR, "Coordinate out of range.", "loadForm()");
610 writeError();
611 }
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
612 msObj->CoordSource = FROMIMGPNT;
abe3c7ac » sdlime
2000-04-11 Initial revision
613 QueryCoordSource = FROMIMGPNT;
614 continue;
615 }
616
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
617 if(strcasecmp(msObj->request->ParamNames[i],"imgxy") == 0) { /* mouse click, single variable */
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
618 if(msObj->CoordSource == FROMIMGPNT)
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
619 continue;
abe3c7ac » sdlime
2000-04-11 Initial revision
620
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
621 tokens = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
622
623 if(!tokens) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
624 msSetError(MS_MEMERR, NULL, "loadForm()");
625 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
626 }
627
628 if(n != 2) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
629 msSetError(MS_WEBERR, "Not enough arguments for imgxy.", "loadForm()");
630 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
631 }
632
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
633 msObj->ImgPnt.x = getNumeric(tokens[0]);
634 msObj->ImgPnt.y = getNumeric(tokens[1]);
abe3c7ac » sdlime
2000-04-11 Initial revision
635
636 msFreeCharArray(tokens, 2);
637
df8c1e00 » sdlime
2003-09-24 Fixed bug 435. There is a new mapObj parameter called MAXSIZE. The de…
638 if((msObj->ImgPnt.x > (2*msObj->Map->maxsize)) || (msObj->ImgPnt.x < (-2*msObj->Map->maxsize)) || (msObj->ImgPnt.y > (2*msObj->Map->maxsize)) || (msObj->ImgPnt.y < (-2*msObj->Map->maxsize))) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
639 msSetError(MS_WEBERR, "Reference map coordinate out of range.", "loadForm()");
640 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
641 }
642
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
643 if(msObj->CoordSource == NONE) { /* override nothing since this parameter is usually used to hold a default value */
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
644 msObj->CoordSource = FROMIMGPNT;
645 QueryCoordSource = FROMIMGPNT;
abe3c7ac » sdlime
2000-04-11 Initial revision
646 }
647 continue;
648 }
649
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
650 if(strcasecmp(msObj->request->ParamNames[i],"imgbox") == 0) { /* selection box (eg. mouse drag) */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
651 tokens = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
652
653 if(!tokens) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
654 msSetError(MS_MEMERR, NULL, "loadForm()");
655 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
656 }
657
658 if(n != 4) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
659 msSetError(MS_WEBERR, "Not enough arguments for imgbox.", "loadForm()");
660 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
661 }
662
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
663 msObj->ImgBox.minx = getNumeric(tokens[0]);
664 msObj->ImgBox.miny = getNumeric(tokens[1]);
665 msObj->ImgBox.maxx = getNumeric(tokens[2]);
666 msObj->ImgBox.maxy = getNumeric(tokens[3]);
abe3c7ac » sdlime
2000-04-11 Initial revision
667
668 msFreeCharArray(tokens, 4);
669
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
670 if((msObj->ImgBox.minx != msObj->ImgBox.maxx) && (msObj->ImgBox.miny != msObj->ImgBox.maxy)) { /* must not degenerate into a point */
4183deed » sdlime
2004-06-02 Removed spurrious DOS linefeeds from mapserv.c and mapserv_fcgi.c.
671 msObj->CoordSource = FROMIMGBOX;
672 QueryCoordSource = FROMIMGBOX;
abe3c7ac » sdlime
2000-04-11 Initial revision
673 }
674 continue;
675 }
676
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
677 if(strcasecmp(msObj->request->ParamNames[i],"imgshape") == 0) { /* shape given in image coordinates */
abe3c7ac » sdlime
2000-04-11 Initial revision
678 lineObj line={0,NULL};
679 char **tmp=NULL;
680 int n, j;
681
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
682 tmp = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
683
684 if((line.point = (pointObj *)malloc(sizeof(pointObj)*(n/2))) == NULL) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
685 msSetError(MS_MEMERR, NULL, "loadForm()");
686 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
687 }
688 line.numpoints = n/2;
689
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
690 msInitShape(&msObj->SelectShape);
691 msObj->SelectShape.type = MS_SHAPE_POLYGON;
9914b679 » sdlime
2001-10-24 Fixed problem with mapshape option, input shape is now of MS_SHAPE_PO…
692
abe3c7ac » sdlime
2000-04-11 Initial revision
693 for(j=0; j<n/2; j++) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
694 line.point[j].x = atof(tmp[2*j]);
695 line.point[j].y = atof(tmp[2*j+1]);
abe3c7ac » sdlime
2000-04-11 Initial revision
696 }
697
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
698 if(msAddLine(&msObj->SelectShape, &line) == -1) writeError();
9914b679 » sdlime
2001-10-24 Fixed problem with mapshape option, input shape is now of MS_SHAPE_PO…
699
700 msFree(line.point);
abe3c7ac » sdlime
2000-04-11 Initial revision
701 msFreeCharArray(tmp, n);
702
703 QueryCoordSource = FROMIMGSHAPE;
704 continue;
705 }
706
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
707 if(strcasecmp(msObj->request->ParamNames[i],"ref.x") == 0) { /* mouse click in reference image, in pieces */
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
708 msObj->RefPnt.x = getNumeric(msObj->request->ParamValues[i]);
df8c1e00 » sdlime
2003-09-24 Fixed bug 435. There is a new mapObj parameter called MAXSIZE. The de…
709 if((msObj->RefPnt.x > (2*msObj->Map->maxsize)) || (msObj->RefPnt.x < (-2*msObj->Map->maxsize))) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
710 msSetError(MS_WEBERR, "Coordinate out of range.", "loadForm()");
711 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
712 }
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
713 msObj->CoordSource = FROMREFPNT;
abe3c7ac » sdlime
2000-04-11 Initial revision
714 continue;
715 }
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
716 if(strcasecmp(msObj->request->ParamNames[i],"ref.y") == 0) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
717 msObj->RefPnt.y = getNumeric(msObj->request->ParamValues[i]);
df8c1e00 » sdlime
2003-09-24 Fixed bug 435. There is a new mapObj parameter called MAXSIZE. The de…
718 if((msObj->RefPnt.y > (2*msObj->Map->maxsize)) || (msObj->RefPnt.y < (-2*msObj->Map->maxsize))) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
719 msSetError(MS_WEBERR, "Coordinate out of range.", "loadForm()");
720 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
721 }
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
722 msObj->CoordSource = FROMREFPNT;
abe3c7ac » sdlime
2000-04-11 Initial revision
723 continue;
724 }
725
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
726 if(strcasecmp(msObj->request->ParamNames[i],"refxy") == 0) { /* mouse click in reference image, single variable */
727 tokens = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
728
729 if(!tokens) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
730 msSetError(MS_MEMERR, NULL, "loadForm()");
731 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
732 }
733
734 if(n != 2) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
735 msSetError(MS_WEBERR, "Not enough arguments for imgxy.", "loadForm()");
736 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
737 }
738
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
739 msObj->RefPnt.x = getNumeric(tokens[0]);
740 msObj->RefPnt.y = getNumeric(tokens[1]);
abe3c7ac » sdlime
2000-04-11 Initial revision
741
742 msFreeCharArray(tokens, 2);
743
df8c1e00 » sdlime
2003-09-24 Fixed bug 435. There is a new mapObj parameter called MAXSIZE. The de…
744 if((msObj->RefPnt.x > (2*msObj->Map->maxsize)) || (msObj->RefPnt.x < (-2*msObj->Map->maxsize)) || (msObj->RefPnt.y > (2*msObj->Map->maxsize)) || (msObj->RefPnt.y < (-2*msObj->Map->maxsize))) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
745 msSetError(MS_WEBERR, "Reference map coordinate out of range.", "loadForm()");
746 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
747 }
748
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
749 msObj->CoordSource = FROMREFPNT;
abe3c7ac » sdlime
2000-04-11 Initial revision
750 continue;
751 }
752
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
753 if(strcasecmp(msObj->request->ParamNames[i],"buffer") == 0) { /* radius (map units), actually 1/2 square side */
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
754 msObj->Buffer = getNumeric(msObj->request->ParamValues[i]);
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
755 msObj->CoordSource = FROMBUF;
abe3c7ac » sdlime
2000-04-11 Initial revision
756 QueryCoordSource = FROMUSERPNT;
757 continue;
758 }
759
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
760 if(strcasecmp(msObj->request->ParamNames[i],"scale") == 0) { /* scale for new map */
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
761 msObj->Scale = getNumeric(msObj->request->ParamValues[i]);
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
762 if(msObj->Scale <= 0) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
763 msSetError(MS_WEBERR, "Scale out of range.", "loadForm()");
764 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
765 }
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
766 msObj->CoordSource = FROMSCALE;
abe3c7ac » sdlime
2000-04-11 Initial revision
767 QueryCoordSource = FROMUSERPNT;
768 continue;
769 }
770
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
771 if(strcasecmp(msObj->request->ParamNames[i],"imgsize") == 0) { /* size of existing image (pixels) */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
772 tokens = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
773
774 if(!tokens) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
775 msSetError(MS_MEMERR, NULL, "loadForm()");
776 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
777 }
778
779 if(n != 2) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
780 msSetError(MS_WEBERR, "Not enough arguments for imgsize.", "loadForm()");
781 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
782 }
783
23ecd5d5 » warmerdam
2004-11-09 avoid lots of casting warnings
784 msObj->ImgCols = (int)getNumeric(tokens[0]);
785 msObj->ImgRows = (int)getNumeric(tokens[1]);
abe3c7ac » sdlime
2000-04-11 Initial revision
786
787 msFreeCharArray(tokens, 2);
788
df8c1e00 » sdlime
2003-09-24 Fixed bug 435. There is a new mapObj parameter called MAXSIZE. The de…
789 if(msObj->ImgCols > msObj->Map->maxsize || msObj->ImgRows > msObj->Map->maxsize || msObj->ImgCols < 0 || msObj->ImgRows < 0) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
790 msSetError(MS_WEBERR, "Image size out of range.", "loadForm()");
791 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
792 }
793
794 continue;
795 }
796
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
797 if(strcasecmp(msObj->request->ParamNames[i],"mapsize") == 0) { /* size of new map (pixels) */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
798 tokens = split(msObj->request->ParamValues[i], ' ', &n);
abe3c7ac » sdlime
2000-04-11 Initial revision
799
800 if(!tokens) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
801 msSetError(MS_MEMERR, NULL, "loadForm()");
802 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
803 }
804
805 if(n != 2) {
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
806 msSetError(MS_WEBERR, "Not enough arguments for mapsize.", "loadForm()");
807 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
808 }
809
23ecd5d5 » warmerdam
2004-11-09 avoid lots of casting warnings
810 msObj->Map->width = (int)getNumeric(tokens[0]);
811 msObj->Map->height = (int)getNumeric(tokens[1]);
abe3c7ac » sdlime
2000-04-11 Initial revision
812
813 msFreeCharArray(tokens, 2);
814
df8c1e00 » sdlime
2003-09-24 Fixed bug 435. There is a new mapObj parameter called MAXSIZE. The de…
815 if(msObj->Map->width > msObj->Map->maxsize || msObj->Map->height > msObj->Map->maxsize || msObj->Map->width < 0 || msObj->Map->height < 0) {
3a591ccf » sdlime
2004-06-02 Trivial format changes.
816 msSetError(MS_WEBERR, "Image size out of range.", "loadForm()");
817 writeError();
abe3c7ac » sdlime
2000-04-11 Initial revision
818 }
819 continue;
820 }
821
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
822 if(strncasecmp(msObj->request->ParamNames[i],"layers", 6) == 0) { /* turn a set of layers, delimited by spaces, on */
abe3c7ac » sdlime
2000-04-11 Initial revision
823
4d802d2e » dmorissette
2004-10-14 Added ability to pass 'layers=all' to quickly turn on all layers (bug…
824 /* If layers=all then turn on all layers */
825 if (strcasecmp(msObj->request->ParamValues[i], "all") == 0 && msObj->Map != NULL)
826 {
827 int l;
828
829 /* Reset NumLayers=0. If individual layers were already selected then free the previous values. */
830 for(l=0; l<msObj->NumLayers; l++)
831 msFree(msObj->Layers[l]);
832 msObj->NumLayers=0;
833
834 for(msObj->NumLayers=0; msObj->NumLayers < msObj->Map->numlayers; msObj->NumLayers++)
835 {
836 if (msObj->Map->layers[msObj->NumLayers].name)
837 {
838 msObj->Layers[msObj->NumLayers] = strdup(msObj->Map->layers[msObj->NumLayers].name);
839 }
840 else
841 {
842 msObj->Layers[msObj->NumLayers] = strdup("");
843 }
844 }
845 }
846 else
847 {
848 int num_layers=0, l;
849 char **layers=NULL;
850
851 layers = split(msObj->request->ParamValues[i], ' ', &(num_layers));
852 for(l=0; l<num_layers; l++)
853 msObj->Layers[msObj->NumLayers+l] = strdup(layers[l]);
854 msObj->NumLayers += l;
855
856 msFreeCharArray(layers, num_layers);
857 num_layers = 0;
858 }
abe3c7ac » sdlime
2000-04-11 Initial revision
859
860 continue;
861 }
862
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
863 if(strncasecmp(msObj->request->ParamNames[i],"layer", 5) == 0) { /* turn a single layer/group on */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
864 msObj->Layers[msObj->NumLayers] = strdup(msObj->request->ParamValues[i]);
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
865 msObj->NumLayers++;
abe3c7ac » sdlime
2000-04-11 Initial revision
866 continue;
867 }
868
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
869 if(strcasecmp(msObj->request->ParamNames[i],"qlayer") == 0) { /* layer to query (i.e search) */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
870 QueryLayer = strdup(msObj->request->ParamValues[i]);
abe3c7ac » sdlime
2000-04-11 Initial revision
871 continue;
872 }
873
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
874 if(strcasecmp(msObj->request->ParamNames[i],"qitem") == 0) { /* attribute to query on (optional) */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
875 QueryItem = strdup(msObj->request->ParamValues[i]);
e94fe2c4 » sdlime
2002-05-10 Changed the way attribute queries are done. No longer do you set a la…
876 continue;
877 }
878
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
879 if(strcasecmp(msObj->request->ParamNames[i],"qstring") == 0) { /* attribute query string */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
880 QueryString = strdup(msObj->request->ParamValues[i]);
e94fe2c4 » sdlime
2002-05-10 Changed the way attribute queries are done. No longer do you set a la…
881 continue;
882 }
883
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
884 if(strcasecmp(msObj->request->ParamNames[i],"slayer") == 0) { /* layer to select (for feature based search) */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
885 SelectLayer = strdup(msObj->request->ParamValues[i]);
abe3c7ac » sdlime
2000-04-11 Initial revision
886 continue;
887 }
888
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
889 if(strcasecmp(msObj->request->ParamNames[i],"shapeindex") == 0) { /* used for index queries */
23ecd5d5 » warmerdam
2004-11-09 avoid lots of casting warnings
890 ShapeIndex = (int)getNumeric(msObj->request->ParamValues[i]);
6e46133d » sdlime
2001-04-08 Added query by index capability to mapserv and as a query function.
891 continue;
892 }
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
893 if(strcasecmp(msObj->request->ParamNames[i],"tileindex") == 0) {
23ecd5d5 » warmerdam
2004-11-09 avoid lots of casting warnings
894 TileIndex = (int)getNumeric(msObj->request->ParamValues[i]);
6e46133d » sdlime
2001-04-08 Added query by index capability to mapserv and as a query function.
895 continue;
896 }
897
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
898 if(strcasecmp(msObj->request->ParamNames[i],"mode") == 0) { /* set operation mode */
e542f86e » sdlime
2001-07-24 More tweaks to get attribute queries working. A bit more to do...
899 for(j=0; j<numModes; j++) {
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
900 if(strcasecmp(msObj->request->ParamValues[i], modeStrings[j]) == 0) {
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
901 msObj->Mode = j;
e542f86e » sdlime
2001-07-24 More tweaks to get attribute queries working. A bit more to do...
902
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
903 if(msObj->Mode == ZOOMIN) {
904 msObj->ZoomDirection = 1;
905 msObj->Mode = BROWSE;
e542f86e » sdlime
2001-07-24 More tweaks to get attribute queries working. A bit more to do...
906 }
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
907 if(msObj->Mode == ZOOMOUT) {
908 msObj->ZoomDirection = -1;
909 msObj->Mode = BROWSE;
e542f86e » sdlime
2001-07-24 More tweaks to get attribute queries working. A bit more to do...
910 }
911
912 break;
913 }
914 }
915
916 if(j == numModes) {
917 msSetError(MS_WEBERR, "Invalid mode.", "loadForm()");
918 writeError();
919 }
920
921 continue;
922 }
923
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
924 /* check to see if there are any additions to the mapfile, this has been moved to loadMap() */
925 /* if(strncasecmp(msObj->request->ParamNames[i],"map_",4) == 0) { */
926 /* if(msLoadMapString(msObj->Map, msObj->request->ParamNames[i], msObj->request->ParamValues[i]) == -1) */
927 /* writeError(); */
928 /* continue; */
929 /* } */
34099bd6 » sdlime
2003-06-15 Moved code to alter the mapfile via a URL to loadMap in mapserv.c so …
930
dc2f9159 » Assefa Yewondwossen
2002-05-23 Add support for the Rosa applet parameters.
931 /* -------------------------------------------------------------------- */
932 /* The following code is used to support the rosa applet (for */
933 /* more information on Rosa, please consult : */
934 /* http://www2.dmsolutions.ca/webtools/rosa/index.html) . */
935 /* This code was provided by Tim.Mackey@agso.gov.au. */
936 /* */
937 /* For Application using it can be seen at : */
938 /*http://mapserver.gis.umn.edu/wilma/mapserver-users/0011/msg00077.html */
939 /* http://www.agso.gov.au/map/pilbara/ */
940 /* */
941 /* -------------------------------------------------------------------- */
942
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
943 if(strcasecmp(msObj->request->ParamNames[i],"INPUT_TYPE") == 0)
dc2f9159 » Assefa Yewondwossen
2002-05-23 Add support for the Rosa applet parameters.
944 { /* Rosa input type */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
945 if(strcasecmp(msObj->request->ParamValues[i],"auto_rect") == 0)
dc2f9159 » Assefa Yewondwossen
2002-05-23 Add support for the Rosa applet parameters.
946 {
947 rosa_type=1; /* rectangle */
948 continue;
949 }
950
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
951 if(strcasecmp(msObj->request->ParamValues[i],"auto_point") == 0)
dc2f9159 » Assefa Yewondwossen
2002-05-23 Add support for the Rosa applet parameters.
952 {
953 rosa_type=2; /* point */
954 continue;
955 }
956 }
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
957 if(strcasecmp(msObj->request->ParamNames[i],"INPUT_COORD") == 0)
dc2f9159 » Assefa Yewondwossen
2002-05-23 Add support for the Rosa applet parameters.
958 { /* Rosa coordinates */
959
960 switch(rosa_type)
961 {
962 case 1:
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
963 sscanf(msObj->request->ParamValues[i],"%lf,%lf;%lf,%lf",
dc2f9159 » Assefa Yewondwossen
2002-05-23 Add support for the Rosa applet parameters.
964 &msObj->ImgBox.minx,&msObj->ImgBox.miny,&msObj->ImgBox.maxx,
965 &msObj->ImgBox.maxy);
966 if((msObj->ImgBox.minx != msObj->ImgBox.maxx) &&
967 (msObj->ImgBox.miny != msObj->ImgBox.maxy))
968 {
969 msObj->CoordSource = FROMIMGBOX;
970 QueryCoordSource = FROMIMGBOX;
971 }
972 else
973 {
974 msObj->CoordSource = FROMIMGPNT;
975 QueryCoordSource = FROMIMGPNT;
976 msObj->ImgPnt.x=msObj->ImgBox.minx;
977 msObj->ImgPnt.y=msObj->ImgBox.miny;
978 }
979 break;
980 case 2:
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
981 sscanf(msObj->request->ParamValues[i],"%lf,%lf",&msObj->ImgPnt.x,
dc2f9159 » Assefa Yewondwossen
2002-05-23 Add support for the Rosa applet parameters.
982 &msObj->ImgPnt.y);
983 msObj->CoordSource = FROMIMGPNT;
984 QueryCoordSource = FROMIMGPNT;
985 break;
986 }
987 continue;
988 }
989 /* -------------------------------------------------------------------- */
990 /* end of code for Rosa support. */
991 /* -------------------------------------------------------------------- */
992
993
abe3c7ac » sdlime
2000-04-11 Initial revision
994 }
995
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
996 if(ZoomSize != 0) { /* use direction and magnitude to calculate zoom */
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
997 if(msObj->ZoomDirection == 0) {
998 msObj->fZoom = 1;
abe3c7ac » sdlime
2000-04-11 Initial revision
999 } else {
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1000 msObj->fZoom = ZoomSize*msObj->ZoomDirection;
1001 if(msObj->fZoom < 0)
1002 msObj->fZoom = 1.0/MS_ABS(msObj->fZoom);
abe3c7ac » sdlime
2000-04-11 Initial revision
1003 }
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1004 } else { /* use single value for zoom */
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1005 if((msObj->Zoom >= -1) && (msObj->Zoom <= 1)) {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1006 msObj->fZoom = 1; /* pan */
abe3c7ac » sdlime
2000-04-11 Initial revision
1007 } else {
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1008 if(msObj->Zoom < 0)
1009 msObj->fZoom = 1.0/MS_ABS(msObj->Zoom);
abe3c7ac » sdlime
2000-04-11 Initial revision
1010 else
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1011 msObj->fZoom = msObj->Zoom;
abe3c7ac » sdlime
2000-04-11 Initial revision
1012 }
1013 }
1014
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
1015 if(msObj->ImgRows == -1) msObj->ImgRows = msObj->Map->height;
1016 if(msObj->ImgCols == -1) msObj->ImgCols = msObj->Map->width;
1017 if(msObj->Map->height == -1) msObj->Map->height = msObj->ImgRows;
ed057871 » sdlime
2004-06-02 New version of getNumeric for mapserv.c and mapserv_fcgi.c.
1018 if(msObj->Map->width == -1) msObj->Map->width = msObj->ImgCols;
abe3c7ac » sdlime
2000-04-11 Initial revision
1019 }
1020
e5f634d3 » sdlime
2005-01-28 Applied patch to make function prototypes ANSI C compliant. Thanks to…
1021 void setExtentFromShapes(void) {
abe3c7ac » sdlime
2000-04-11 Initial revision
1022 int found=0;
5207811e » sdlime
2001-11-29 Finally nailed the map only query modes. Added buffer and scale suppo…
1023 double dx, dy, cellsize;
abe3c7ac » sdlime
2000-04-11 Initial revision
1024
70e076f4 » sdlime
2001-08-29 Changed scale computation function to throw errors with bad input dat…
1025 rectObj tmpext={-1.0,-1.0,-1.0,-1.0};
1026 pointObj tmppnt={-1.0,-1.0};
1027
5db61a0e » dmorissette
2002-12-17 Created msGetQueryResultBounds()
1028 found = msGetQueryResultBounds(msObj->Map, &(tmpext));
abe3c7ac » sdlime
2000-04-11 Initial revision
1029
70e076f4 » sdlime
2001-08-29 Changed scale computation function to throw errors with bad input dat…
1030 dx = tmpext.maxx - tmpext.minx;
1031 dy = tmpext.maxy - tmpext.miny;
1032
dda9a517 » sdlime
2001-12-04 Fixed stupid error in setExtentFromShapes().
1033 tmppnt.x = (tmpext.maxx + tmpext.minx)/2;
1034 tmppnt.y = (tmpext.maxy + tmpext.miny)/2;
70e076f4 » sdlime
2001-08-29 Changed scale computation function to throw errors with bad input dat…
1035 tmpext.minx -= dx*EXTENT_PADDING/2.0;
1036 tmpext.maxx += dx*EXTENT_PADDING/2.0;
1037 tmpext.miny -= dy*EXTENT_PADDING/2.0;
1038 tmpext.maxy += dy*EXTENT_PADDING/2.0;
1039
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1040 if(msObj->Scale != 0) { /* apply the scale around the center point (tmppnt) */
1041 cellsize = (msObj->Scale/msObj->Map->resolution)/msInchesPerUnit(msObj->Map->units,0); /* user supplied a point and a scale */
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1042 tmpext.minx = tmppnt.x - cellsize*msObj->Map->width/2.0;
1043 tmpext.miny = tmppnt.y - cellsize*msObj->Map->height/2.0;
1044 tmpext.maxx = tmppnt.x + cellsize*msObj->Map->width/2.0;
1045 tmpext.maxy = tmppnt.y + cellsize*msObj->Map->height/2.0;
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1046 } else if(msObj->Buffer != 0) { /* apply the buffer around the center point (tmppnt) */
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
1047 tmpext.minx = tmppnt.x - msObj->Buffer;
1048 tmpext.miny = tmppnt.y - msObj->Buffer;
1049 tmpext.maxx = tmppnt.x + msObj->Buffer;
1050 tmpext.maxy = tmppnt.y + msObj->Buffer;
5207811e » sdlime
2001-11-29 Finally nailed the map only query modes. Added buffer and scale suppo…
1051 }
1052
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1053 /* in case we don't get usable extent at this point (i.e. single point result) */
9c9cce95 » Howard Butler
2004-07-29 redefine MS_VALID_EXTENT to test an extent rather than the quartet of…
1054 if(!MS_VALID_EXTENT(tmpext)) {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1055 if(msObj->Map->web.minscale > 0) { /* try web object minscale first */
1056 cellsize = (msObj->Map->web.minscale/msObj->Map->resolution)/msInchesPerUnit(msObj->Map->units,0); /* user supplied a point and a scale */
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1057 tmpext.minx = tmppnt.x - cellsize*msObj->Map->width/2.0;
1058 tmpext.miny = tmppnt.y - cellsize*msObj->Map->height/2.0;
1059 tmpext.maxx = tmppnt.x + cellsize*msObj->Map->width/2.0;
1060 tmpext.maxy = tmppnt.y + cellsize*msObj->Map->height/2.0;
5207811e » sdlime
2001-11-29 Finally nailed the map only query modes. Added buffer and scale suppo…
1061 } else {
1062 msSetError(MS_WEBERR, "No way to generate a valid map extent from selected shapes.", "mapserv()");
1063 writeError();
1064 }
1065 }
abe3c7ac » sdlime
2000-04-11 Initial revision
1066
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1067 msObj->MapPnt = tmppnt;
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1068 msObj->Map->extent = msObj->RawExt = tmpext; /* save unadjusted extent */
5207811e » sdlime
2001-11-29 Finally nailed the map only query modes. Added buffer and scale suppo…
1069
abe3c7ac » sdlime
2000-04-11 Initial revision
1070 return;
1071 }
1072
75bf6207 » sdlime
2001-11-26 Fixed some problems with application logic and map only query methods…
1073
58949bff » sdlime
2001-02-07 Added support to mapserv.c to allow a default map file to be define u…
1074 /* FIX: NEED ERROR CHECKING HERE FOR IMGPNT or MAPPNT */
e5f634d3 » sdlime
2005-01-28 Applied patch to make function prototypes ANSI C compliant. Thanks to…
1075 void setCoordinate(void)
abe3c7ac » sdlime
2000-04-11 Initial revision
1076 {
1077 double cellx,celly;
1078
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
1079 cellx = MS_CELLSIZE(msObj->ImgExt.minx, msObj->ImgExt.maxx, msObj->ImgCols);
1080 celly = MS_CELLSIZE(msObj->ImgExt.miny, msObj->ImgExt.maxy, msObj->ImgRows);
abe3c7ac » sdlime
2000-04-11 Initial revision
1081
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
1082 msObj->MapPnt.x = MS_IMAGE2MAP_X(msObj->ImgPnt.x, msObj->ImgExt.minx, cellx);
1083 msObj->MapPnt.y = MS_IMAGE2MAP_Y(msObj->ImgPnt.y, msObj->ImgExt.maxy, celly);
abe3c7ac » sdlime
2000-04-11 Initial revision
1084
1085 return;
1086 }
1087
e5f634d3 » sdlime
2005-01-28 Applied patch to make function prototypes ANSI C compliant. Thanks to…
1088 void returnCoordinate(pointObj pnt)
abe3c7ac » sdlime
2000-04-11 Initial revision
1089 {
47eaecfe » warmerdam
2002-01-09 avoid use of ms_error global
1090 msSetError(MS_NOERR,
1091 "Your \"<i>click</i>\" corresponds to (approximately): (%g, %g).",
1092 NULL,
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1093 msObj->MapPnt.x, msObj->MapPnt.y);
abe3c7ac » sdlime
2000-04-11 Initial revision
1094
1095 #ifdef USE_PROJ
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1096 if(msObj->Map->projection.proj != NULL && !pj_is_latlong(msObj->Map->projection.proj) ) {
1097 pointObj p=msObj->MapPnt;
1098 msProjectPoint(&(msObj->Map->projection), &(msObj->Map->latlon), &p);
47eaecfe » warmerdam
2002-01-09 avoid use of ms_error global
1099 msSetError( MS_NOERR,
1100 "%s Computed lat/lon value is (%g, %g).\n", NULL, p.x, p.y);
abe3c7ac » sdlime
2000-04-11 Initial revision
1101 }
1102 #endif
1103
1104 writeError();
1105 }
1106
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
1107 /************************************************************************/
1108 /* FastCGI cleanup functions. */
1109 /************************************************************************/
fbc84bcc » warmerdam
2004-10-28 Implemented signal catching on unix (non-win32) platforms. The signal
1110 #ifndef WIN32
1111 void msCleanupOnSignal( int nInData )
1112
1113 {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1114 /* For some reason, the fastcgi message code does not seem to work */
1115 /* from within the signal handler on Unix. So we force output through */
1116 /* normal stdio functions. */
fbc84bcc » warmerdam
2004-10-28 Implemented signal catching on unix (non-win32) platforms. The signal
1117 msIO_installHandlers( NULL, NULL, NULL );
1118 msIO_fprintf( stderr, "In msCleanupOnSignal.\n" );
1119 msCleanup();
1120 exit( 3 );
1121 }
1122 #endif
1123
317843f4 » warmerdam
2004-10-28 added win32/fastcgi support using atexit()
1124 #ifdef WIN32
1125 void msCleanupOnExit( void )
1126 {
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1127 /* note that stderr and stdout seem to be non-functional in the */
1128 /* fastcgi/win32 case. If you really want to check functioning do */
1129 /* some sort of hack logging like below ... otherwise just trust it! */
317843f4 » warmerdam
2004-10-28 added win32/fastcgi support using atexit()
1130
1131 #ifdef notdef
1132 FILE *fp_out = fopen( "D:\\temp\\mapserv.log", "w" );
1133
1134 fprintf( fp_out, "In msCleanupOnExit\n" );
1135 fclose( fp_out );
1136 #endif
1137 msCleanup();
1138 }
1139 #endif
1140
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1141 /* FIX: need to consider 5% shape extent expansion */
a8a1b665 » sdlime
2001-02-08 More update of query components of mapserv.c
1142
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
1143 /************************************************************************/
1144 /* main() */
1145 /************************************************************************/
abe3c7ac » sdlime
2000-04-11 Initial revision
1146 int main(int argc, char *argv[]) {
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
1147 int i,j, iArg;
abe3c7ac » sdlime
2000-04-11 Initial revision
1148 char buffer[1024];
36e89639 » Assefa Yewondwossen
2002-05-02 Add imageObj support to be able to output additional formats.
1149 imageObj *img=NULL;
07ca80e8 » sdlime
2001-02-06 Initial code for 3.5 changes. Basically a state of chaos at the moment.
1150 int status;
abe3c7ac » sdlime
2000-04-11 Initial revision
1151
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
1152 /* -------------------------------------------------------------------- */
1153 /* Process arguments. In normal use as a cgi-bin there are no */
1154 /* commandline switches, but we provide a few for test/debug */
1155 /* purposes, and to query the version info. */
1156 /* -------------------------------------------------------------------- */
1157 for( iArg = 1; iArg < argc; iArg++ )
de45010f » dmorissette
2002-06-27 Added msTokenizeMap() in MapServer and PHP MapScript (3.7 branch)
1158 {
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
1159 if( strcmp(argv[iArg],"-v") == 0 ) {
1160 printf("%s\n", msGetVersion());
1161 fflush(stdout);
1162 exit(0);
1163 }
1164 else if( iArg < argc-1 && strcmp(argv[iArg], "-tmpbase") == 0) {
1165 msForceTmpFileBase( argv[++iArg] );
1166 }
1167 else if( iArg < argc-1 && strcmp(argv[iArg], "-t") == 0) {
1168 char **tokens;
1169 int numtokens=0;
1170 if ((tokens=msTokenizeMap(argv[iArg+1], &numtokens)) != NULL)
1171 {
1172 int i;
1173 for(i=0; i<numtokens; i++)
1174 printf("%s\n", tokens[i]);
1175 msFreeCharArray(tokens, numtokens);
1176 }
1177 else
1178 {
1179 writeError();
1180 }
1181
1182 exit(0);
1183 }
1184 else if ( strncmp(argv[iArg], "QUERY_STRING=", 13) == 0) {
1185 /* Debugging hook... pass "QUERY_STRING=..." on the command-line */
b6a08ea6 » warmerdam
2005-07-25 Removed unnecessary strdup() calls for QUERY_STRING commandline arg.
1186 putenv( "REQUEST_METHOD=GET" );
1187 putenv( argv[1] );
de45010f » dmorissette
2002-06-27 Added msTokenizeMap() in MapServer and PHP MapScript (3.7 branch)
1188 }
1189 else
1190 {
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
1191 /* we don't produce a usage message as some web servers pass
1192 junk arguments */
de45010f » dmorissette
2002-06-27 Added msTokenizeMap() in MapServer and PHP MapScript (3.7 branch)
1193 }
07ad530d » dmorissette
2001-02-24 Added QUERY_STRING=... command-line param for debugging
1194 }
67f4a0f8 » sdlime
2000-11-17 Added -v command-line switch
1195
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
1196 /* -------------------------------------------------------------------- */
1197 /* Setup cleanup magic, mainly for FastCGI case. */
1198 /* -------------------------------------------------------------------- */
fbc84bcc » warmerdam
2004-10-28 Implemented signal catching on unix (non-win32) platforms. The signal
1199 #ifndef WIN32
1200 signal( SIGUSR1, msCleanupOnSignal );
1201 signal( SIGTERM, msCleanupOnSignal );
1202 #endif
1203
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
1204 #ifdef USE_FASTCGI
1205 msIO_installFastCGIRedirect();
1206
317843f4 » warmerdam
2004-10-28 added win32/fastcgi support using atexit()
1207 #ifdef WIN32
1208 atexit( msCleanupOnExit );
1209 #endif
1210
f6e6a66f » dmorissette
2005-02-18 Turned all C++ (//) comments into C comments (bug 1238)
1211 /* In FastCGI case we loop accepting multiple requests. In normal CGI */
1212 /* use we only accept and process one request. */
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
1213 while( FCGI_Accept() >= 0 )
1214 {
1215 #endif /* def USE_FASTCGI */
1216
dc00d8ad » warmerdam
2005-02-09 added msForceTmpFileBase and -tmpbase mapserv switch
1217 /* -------------------------------------------------------------------- */
1218 /* Process a request. */
1219 /* -------------------------------------------------------------------- */
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
1220 msObj = msAllocMapServObj();
1221
c6f51d0b » sdlime
2006-08-29 Fixed buffer overflow with POSTs and huge numbers of name/value pairs…
1222 msObj->request->ParamNames = (char **) malloc(MS_MAX_CGI_PARAMS*sizeof(char*));
1223 msObj->request->ParamValues = (char **) malloc(MS_MAX_CGI_PARAMS*sizeof(char*));
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
1224 if (msObj->request->ParamNames==NULL || msObj->request->ParamValues==NULL) {
85e62756 » sdlime
2001-05-02 Moved from the old entry structure to 2 arrays of strings. This shoul…
1225 msSetError(MS_MEMERR, NULL, "mapserv()");
1226 writeError();
1227 }
1228
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
1229 msObj->request->NumParams = loadParams(msObj->request);
7c6a9ffd » warmerdam
2007-02-13 msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
1230 if( msObj->request->NumParams == -1 )
1231 {
1232 #ifdef USE_FASTCGI
1233 /* FCGI_ --- return to top of loop */
1234 msResetErrorList();
1235 continue;
1236 #else
1237 /* normal case, processing is complete */
1238 msCleanup();
1239 exit( 0 );
1240 #endif
1241 }
1242
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1243 msObj->Map = loadMap();
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
1244
1d057192 » warmerdam
2004-10-29 Added a bit of debugging for new requests in fastcgi mode, with the
1245 #ifdef USE_FASTCGI
1246 if( msObj->Map->debug )
1247 {
1248 static int nRequestCounter = 1;
1249
1250 msDebug( "CGI Request %d on process %d\n",
1251 nRequestCounter, getpid() );
1252
1253 nRequestCounter++;
1254 }
1255 #endif
1256
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
1257 /*
55a0127e » sdlime
2004-02-05 Added WCS to the list of possible services checked by the MapServer C…
1258 ** Start by calling the WMS/WFS/WCS Dispatchers. If they fail then we'll
e1f6aba0 » dmorissette
2002-09-03 Set the bases for WFS Server support + moved some WMS/WFS stuff to ma…
1259 ** process this as a regular MapServer request.
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
1260 */
1763a51a » Assefa Yewondwossen
2003-09-19 Modify of the request handling to add support for post requests.
1261 if ((status = msOWSDispatch(msObj->Map, msObj->request)) != MS_DONE )
e1f6aba0 » dmorissette
2002-09-03 Set the bases for WFS Server support + moved some WMS/WFS stuff to ma…
1262 {
7c6a9ffd » warmerdam
2007-02-13 msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
1263 /*
1264 ** Normally if the OWS service fails it will issue an exception,
1265 ** and clear the error stack but still return MS_FAILURE. But in
1266 ** a few situations it can't issue the exception and will instead
1267 ** just an error and let us report it.
1268 */
1269 if( status == MS_FAILURE )
1270 {
1271 errorObj *ms_error = msGetErrorObj();
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
1272
7c6a9ffd » warmerdam
2007-02-13 msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
1273 if( ms_error->code != MS_NOERR )
1274 writeError();
1275 }
1276
1277 /* This was a WMS/WFS request... cleanup and exit
1278 * At this point any error has already been handled
1279 * as an XML exception by the OGC service.
1280 */
1281 msFreeMapServObj(msObj);
1282
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
1283 #ifdef USE_FASTCGI
7c6a9ffd » warmerdam
2007-02-13 msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
1284 /* FCGI_ --- return to top of loop */
1285 continue;
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
1286 #else
7c6a9ffd » warmerdam
2007-02-13 msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
1287 /* normal case, processing is complete */
1288 msCleanup();
1289 exit( 0 );
fbe49981 » dmorissette
2001-03-30 Added --without-wms configure option and USE_WMS compile flag
1290 #endif
bf2b346f » dmorissette
2001-03-26 Call the WMS dispatch function from mapserv
1291
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
1292 }
7c6a9ffd » warmerdam
2007-02-13 msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
1293
1294 /*
1295 ** Try to report a meaningful message if we had an OGC request but
1296 ** we couldn't handle it because we don't have support compiled in.
1297 */
1298 {
1299 const char *service = NULL;
1300
1301 for(i=0; i<msObj->request->NumParams; i++) {
1302 if (strcasecmp(msObj->request->ParamNames[i], "SERVICE") == 0)
1303 service = msObj->request->ParamValues[i];
1304 }
1305
1306 if( service != NULL
1307 && (strcasecmp(service,"WMS") == 0
1308 || strcasecmp(service,"WCS") == 0
1309 || strcasecmp(service,"WFS") == 0
1310 || strcasecmp(service,"SOS") == 0) )
1311 {
1312 msSetError(MS_WEBERR,
1313 "SERVICE=%s requested, but that OGC web service is not enabled in this build. Please rebuild MapServer with appropriate options.",
1314 "mapserv() ",
1315 service );
1316 writeError();
1317 }
1318 }
1319
1320 /*
1321 ** Do "traditional" mode processing.
1322 */
4c0963c4 » warmerdam
2004-10-01 implement FastCGI support
1323
abe3c7ac » sdlime
2000-04-11 Initial revision
1324 loadForm();
9bf571a0 » sdlime
2001-02-09 More mapserv.c work, should compile today.
1325
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1326 if(msObj->SaveMap) {
1327 sprintf(buffer, "%s%s%s.map", msObj->Map->web.imagepath, msObj->Map->name, msObj->Id);
1328 if(msSaveMap(msObj->Map, buffer) == -1) writeError();
b7aed751 » sdlime
2000-07-14 Fixed a couple of map file writing bugs, enabled savemap option as a …
1329 }
1330
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
1331 if((msObj->CoordSource == FROMIMGPNT) || (msObj->CoordSource == FROMIMGBOX)) /* make sure extent of existing image matches shape of image */
1332 msObj->Map->cellsize = msAdjustExtent(&msObj->ImgExt, msObj->ImgCols, msObj->ImgRows);
abe3c7ac » sdlime
2000-04-11 Initial revision
1333
1334 /*
1335 ** For each layer lets set layer status
1336 */
eba56f96 » Assefa Yewondwossen
2004-11-01 Work on Bug 1023 : only layers coming from a mapcontext use the
1337
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1338 for(i=0;i<msObj->Map->numlayers;i++) {
1339 if((msObj->Map->layers[i].status != MS_DEFAULT)) {
a5ebd339 » Assefa Yewondwossen
2004-11-02 Add a 2nd optional argument to msLoadMapContext function (Bug 1023).
1340 if(isOn(msObj, msObj->Map->layers[i].name, msObj->Map->layers[i].group) == MS_TRUE) /* Set layer status */
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1341 msObj->Map->layers[i].status = MS_ON;
abe3c7ac » sdlime
2000-04-11 Initial revision
1342 else
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1343 msObj->Map->layers[i].status = MS_OFF;
abe3c7ac » sdlime
2000-04-11 Initial revision
1344 }
1345 }
1346
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
1347 if(msObj->CoordSource == FROMREFPNT) /* force browse mode if the reference coords are set */
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1348 msObj->Mode = BROWSE;
abe3c7ac » sdlime
2000-04-11 Initial revision
1349
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1350 if(msObj->Mode == BROWSE) {
abe3c7ac » sdlime
2000-04-11 Initial revision
1351
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1352 if(!msObj->Map->web.template) {
7c6a9ffd » warmerdam
2007-02-13 msOWSDispatch() is no longer invoked conditionally. If msOWSDispatch()
1353 msSetError(MS_WEBERR,
1354 "Traditional BROWSE mode requires a TEMPLATE in the WEB section, but none was provided.",
1355 "mapserv()");
9bf571a0 » sdlime
2001-02-09 More mapserv.c work, should compile today.
1356 writeError();
1357 }
1358
1359 if(QueryFile) {
033a460d » Sacha Fournier
2002-01-24 Move all template related functions to a new file called maptemplate.…
1360 status = msLoadQuery(msObj->Map, QueryFile);
9bf571a0 » sdlime
2001-02-09 More mapserv.c work, should compile today.
1361 if(status != MS_SUCCESS) writeError();
1362 }
1363
10dc143c » Sacha Fournier
2002-02-08 Added template support to WMS.
1364 setExtent(msObj);
1365 checkWebScale(msObj);
58ec4bd6 » Assefa Yewondwossen
2002-03-07 Add template processing functions that can be called from mapscript.
1366
1367 /* -------------------------------------------------------------------- */
1368 /* generate map, legend, scalebar and refernce images. */
1369 /* -------------------------------------------------------------------- */
1370 if (msGenerateImages(msObj, QueryFile, MS_TRUE) == MS_FALSE)
1371 writeError();
9bf571a0 » sdlime
2001-02-09 More mapserv.c work, should compile today.
1372
1373 if(QueryFile) {
50593baa » sdlime
2003-11-11 Added QUERYFORMAT to the webObj and updated the template code to use …