[mapserver-users] Passing single quoted strings

Heiko Schröter schroete at iup.physik.uni-bremen.de
Thu Apr 23 03:45:11 EDT 2009


On Mittwoch, 22. April 2009 18:07:11 you wrote:

I've tested teh scenario with 3 different filter strings and attached the 
mapserver error logs with DEBUG 5 (in case need be).
The resulting URL strings are taken from apache access log file.
Please let me know if you need the full URL.

Thanks and Regards
Heiko


The OL call:
sacurabiglayer = new OpenLayers.Layer.WMS( "SACURABIG", 
					   "http://kahlo1/cgi-bin/mapserv",
					   {map:'/home/schroete/sciadaten/MapServer/country98/heiko5.map',
                                            layers: sacura_big,
                                            "map.layer[SACURABIG]": somevalue,
                                            transparent: true},
					    {singleTile:true, isBaseLayer: false,
					    buffer:5, wrapDateLine: true,
                                            queryable: true});

Setting of the string in OL:
somevalue = "filter "+"'"+" datum between "+"'"+"2002-8-8"+"'"+" and "+"'"+" 
2002-8-9 "+"''";
Results:
MAP.LAYER%5BSACURABIG%5D=filter%20'%20datum%20between%20'2002-8-8'%20and%20'%202002-8-9%20''&
(ms_error_assembled_string.txt)

Setting of the string in OL:
somevalue = "filter 'datum between '2002-8-8' and '2002-8-9' '";
MAP.LAYER%5BSACURABIG%5D=filter%20'datum%20between%20'2002-8-8'%20and%20'2002-8-9'%20'&
(ms_error_unescaped_string.txt)

Setting of the string in OL:
somevalue = "filter 'datum between \'2002-8-8\' and \'2002-8-9\' '";
MAP.LAYER%5BSACURABIG%5D=filter%20'datum%20between%20'2002-8-8'%20and%20'2002-8-9'%20'&
(ms_error_escaped_single_quotes.txt)


The Mapfile Layer definition:
	LAYER
		CONNECTIONTYPE POSTGIS
		NAME "SACURABIG"
		PROCESSING "CLOSE_CONNECTION=DEFER"
		OPACITY 60
		STATUS ON
		METADATA
			"wms_title" "sacurabig layer"
			"wms_srs" "init=epsg:4326"
		END
		PROJECTION
			"init=epsg:4326"
		END
		CONNECTION "user=fei password=foo dbname=fum host=kahlo1"
		DATA "geocenter from sacura_big"
   VALIDATION
     'filter' "^."    # Just for testing
   END
		FILTER "orbitnr=0"
		TYPE POINT
                SIZEUNITS meters
		CLASS
                   NAME "sacura_big_class"
                   STYLE
			COLOR [farbe]
			SYMBOL "circle"
			SIZE 35000
                   END
		END
	END # Layer



> What does the URL OL generate look like? I'm curious how it escapes the
> text
> for the URL. That should give us a hint.
>
> Steve
>
> >>> Heiko Schröter <schroete at iup.physik.uni-bremen.de> 04/21/09 1:53 AM
>
> Hello,
>
> i have to pass single quoted strings from Open Layer through mapserver
> to a
> postgis/postgres database.
>
> i.e. "filter 'value=1 and datum between '2005-1-1' and '2005-1-3' ";
> The postgres db expects (afaik) the date in a single quoted string.
>
> The problem is that mapserver stops scanning the filter string when
> coming
> across the second single quote and bails out.
>
> The Validation string in the mapfile:
>     VALIDATION
>      'filter' "^."
>    END
>
> Even when allowing single quotes explicitly by inserting escaped single
> quotes
> in the validation string it doesn't work. Escaping the single quotes in
> the
> assembled OL string won't help either.
>
> Does anyone has an idea of how to pass such strings through mapserver ?
>
> Now i do use an ugly hack of converting the date to abstime on the
> client side
> (with all the UTC converting hassle) and pass the integer to the db.
> i.e. "filter 'value = 1 and abstime between "+fromDate+" and
> "+toDate+"'";
>
> MapServer version 5.4.0-rc1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
> OUTPUT=WBMP
> OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=ICONV
> SUPPORTS=WMS_SERVER
> INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=POSTGIS INPUT=SHAPEFILE
>
> Thanks and Regards
> Heiko
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users

-------------- next part --------------
[Thu Apr 23 09:25:11 2009].502057 loadLayer(): Unknown identifier. Parsing error near (2002):(line 1)
[Thu Apr 23 09:25:11 2009].465405 msDrawMap(): Layer 8 (COPYRIGHT), 0.000s
[Thu Apr 23 09:25:11 2009].465929 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:25:11 2009].465955 msDrawMap() total time: 0.013s
[Thu Apr 23 09:25:11 2009].526054 msSaveImage() total time: 0.060s
[Thu Apr 23 09:25:11 2009].526300 mapserv request processing time (msLoadMap not incl.): 0.075s
[Thu Apr 23 09:25:11 2009].526319 msFreeMap(): freeing map at 0x24b04c0.
[Thu Apr 23 09:25:11 2009].989454 loadLayer(): Unknown identifier. Parsing error near (2002):(line 1)
[Thu Apr 23 09:25:11 2009].733446 msDrawMap(): Layer 0 (KARTE), 0.161s
[Thu Apr 23 09:25:11 2009].770097 msDrawMap(): Layer 1 (GRID), 0.036s
[Thu Apr 23 09:25:11 2009].771038 msDrawRasterLayerLow(LOGO): entering.
[Thu Apr 23 09:25:11 2009].868430 msDrawMap(): Layer 9 (LOGO), 0.098s
[Thu Apr 23 09:25:11 2009].868541 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:25:11 2009].868560 msDrawMap() total time: 0.299s
[Thu Apr 23 09:25:12 2009].121951 msSaveImage() total time: 0.253s
[Thu Apr 23 09:25:12 2009].122137 mapserv request processing time (msLoadMap not incl.): 0.554s
[Thu Apr 23 09:25:12 2009].122157 msFreeMap(): freeing map at 0x26d24d0.
[Thu Apr 23 09:25:12 2009].145426 msDrawMap(): Layer 8 (COPYRIGHT), 0.000s
[Thu Apr 23 09:25:12 2009].145921 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:25:12 2009].145946 msDrawMap() total time: 0.003s
[Thu Apr 23 09:25:12 2009].191941 msSaveImage() total time: 0.046s
[Thu Apr 23 09:25:12 2009].192561 mapserv request processing time (msLoadMap not incl.): 0.052s
[Thu Apr 23 09:25:12 2009].192587 msFreeMap(): freeing map at 0xa1f1d0.
[Thu Apr 23 09:25:12 2009].280272 msDrawMap(): Layer 0 (KARTE), 0.200s
[Thu Apr 23 09:25:12 2009].327532 msDrawMap(): Layer 1 (GRID), 0.047s
[Thu Apr 23 09:25:12 2009].329825 msDrawRasterLayerLow(LOGO): entering.
[Thu Apr 23 09:25:12 2009].408793 msDrawMap(): Layer 9 (LOGO), 0.081s
[Thu Apr 23 09:25:12 2009].408900 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:25:12 2009].408919 msDrawMap() total time: 0.332s
[Thu Apr 23 09:25:12 2009].520515 msSaveImage() total time: 0.112s
[Thu Apr 23 09:25:12 2009].520719 mapserv request processing time (msLoadMap not incl.): 0.462s
[Thu Apr 23 09:25:12 2009].520739 msFreeMap(): freeing map at 0x14c41f0.
-------------- next part --------------
[Thu Apr 23 09:23:58 2009].941639 msDrawMap(): Layer 0 (KARTE), 0.053s
[Thu Apr 23 09:23:58 2009].947663 msDrawMap(): Layer 1 (GRID), 0.006s
[Thu Apr 23 09:23:58 2009].947688 msDrawRasterLayerLow(LOGO): entering.
[Thu Apr 23 09:23:58 2009].949698 msDrawMap(): Layer 9 (LOGO), 0.002s
[Thu Apr 23 09:23:58 2009].949725 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:23:58 2009].949733 msDrawMap() total time: 0.062s
[Thu Apr 23 09:23:58 2009].969855 msSaveImage() total time: 0.020s
[Thu Apr 23 09:23:58 2009].969900 mapserv request processing time (msLoadMap not incl.): 0.092s
[Thu Apr 23 09:23:58 2009].969909 msFreeMap(): freeing map at 0x10521e0.
[Thu Apr 23 09:23:58 2009].933896 msDrawMap(): Layer 8 (COPYRIGHT), 0.000s
[Thu Apr 23 09:23:58 2009].934126 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:23:58 2009].934137 msDrawMap() total time: 0.001s
[Thu Apr 23 09:23:58 2009].985501 msSaveImage() total time: 0.051s
[Thu Apr 23 09:23:58 2009].985608 mapserv request processing time (msLoadMap not incl.): 0.053s
[Thu Apr 23 09:23:58 2009].985617 msFreeMap(): freeing map at 0x1f0e4c0.
[Thu Apr 23 09:23:59 2009].49220 msDrawMap(): Layer 8 (COPYRIGHT), 0.000s
[Thu Apr 23 09:23:59 2009].49439 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:23:59 2009].49450 msDrawMap() total time: 0.001s
[Thu Apr 23 09:23:59 2009].64533 msSaveImage() total time: 0.015s
[Thu Apr 23 09:23:59 2009].64640 mapserv request processing time (msLoadMap not incl.): 0.040s
[Thu Apr 23 09:23:59 2009].64648 msFreeMap(): freeing map at 0x17341d0.
[Thu Apr 23 09:23:59 2009].10042 msDrawMap(): Layer 0 (KARTE), 0.232s
[Thu Apr 23 09:23:59 2009].31302 msDrawMap(): Layer 1 (GRID), 0.021s
[Thu Apr 23 09:23:59 2009].31724 msDrawRasterLayerLow(LOGO): entering.
[Thu Apr 23 09:23:59 2009].83472 msDrawMap(): Layer 9 (LOGO), 0.052s
[Thu Apr 23 09:23:59 2009].83528 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:23:59 2009].83536 msDrawMap() total time: 0.308s
[Thu Apr 23 09:23:59 2009].126123 msSaveImage() total time: 0.043s
[Thu Apr 23 09:23:59 2009].126211 mapserv request processing time (msLoadMap not incl.): 0.353s
[Thu Apr 23 09:23:59 2009].126219 msFreeMap(): freeing map at 0xfac4d0.
[Thu Apr 23 09:23:59 2009].14401 msDrawMap(): Layer 0 (KARTE), 0.123s
[Thu Apr 23 09:23:59 2009].45864 msDrawMap(): Layer 1 (GRID), 0.031s
[Thu Apr 23 09:23:59 2009].46274 msDrawRasterLayerLow(LOGO): entering.
[Thu Apr 23 09:23:59 2009].98074 msDrawMap(): Layer 9 (LOGO), 0.052s
[Thu Apr 23 09:23:59 2009].98127 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:23:59 2009].98136 msDrawMap() total time: 0.209s
[Thu Apr 23 09:23:59 2009].155909 msSaveImage() total time: 0.058s
[Thu Apr 23 09:23:59 2009].156008 mapserv request processing time (msLoadMap not incl.): 0.285s
[Thu Apr 23 09:23:59 2009].156017 msFreeMap(): freeing map at 0x267f1f0.
-------------- next part --------------
[Thu Apr 23 09:35:01 2009].63750 msDrawMap(): Layer 8 (COPYRIGHT), 0.001s
[Thu Apr 23 09:35:01 2009].63998 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:35:01 2009].64010 msDrawMap() total time: 0.002s
[Thu Apr 23 09:35:01 2009].106819 msSaveImage() total time: 0.043s
[Thu Apr 23 09:35:01 2009].106932 mapserv request processing time (msLoadMap not incl.): 0.046s
[Thu Apr 23 09:35:01 2009].106940 msFreeMap(): freeing map at 0x15581d0.
[Thu Apr 23 09:35:01 2009].143907 msDrawMap(): Layer 8 (COPYRIGHT), 0.000s
[Thu Apr 23 09:35:01 2009].144119 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:35:01 2009].144130 msDrawMap() total time: 0.001s
[Thu Apr 23 09:35:01 2009].160356 msSaveImage() total time: 0.016s
[Thu Apr 23 09:35:01 2009].160465 mapserv request processing time (msLoadMap not incl.): 0.018s
[Thu Apr 23 09:35:01 2009].160473 msFreeMap(): freeing map at 0x9ea4c0.
[Thu Apr 23 09:35:01 2009].115556 msDrawMap(): Layer 0 (KARTE), 0.027s
[Thu Apr 23 09:35:01 2009].212072 msDrawMap(): Layer 1 (GRID), 0.096s
[Thu Apr 23 09:35:01 2009].212136 msDrawRasterLayerLow(LOGO): entering.
[Thu Apr 23 09:35:01 2009].214276 msDrawMap(): Layer 9 (LOGO), 0.002s
[Thu Apr 23 09:35:01 2009].214304 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:35:01 2009].214312 msDrawMap() total time: 0.126s
[Thu Apr 23 09:35:01 2009].217904 msSaveImage() total time: 0.004s
[Thu Apr 23 09:35:01 2009].217956 mapserv request processing time (msLoadMap not incl.): 0.130s
[Thu Apr 23 09:35:01 2009].217964 msFreeMap(): freeing map at 0x10dc1e0.
[Thu Apr 23 09:35:01 2009].71492 msDrawMap(): Layer 0 (KARTE), 0.099s
[Thu Apr 23 09:35:01 2009].151667 msDrawMap(): Layer 1 (GRID), 0.080s
[Thu Apr 23 09:35:01 2009].152070 msDrawRasterLayerLow(LOGO): entering.
[Thu Apr 23 09:35:01 2009].206755 msDrawMap(): Layer 9 (LOGO), 0.055s
[Thu Apr 23 09:35:01 2009].206810 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:35:01 2009].206820 msDrawMap() total time: 0.236s
[Thu Apr 23 09:35:01 2009].294824 msSaveImage() total time: 0.088s
[Thu Apr 23 09:35:01 2009].294928 mapserv request processing time (msLoadMap not incl.): 0.327s
[Thu Apr 23 09:35:01 2009].294937 msFreeMap(): freeing map at 0x230b1f0.
[Thu Apr 23 09:35:01 2009].194030 msDrawMap(): Layer 0 (KARTE), 0.086s
[Thu Apr 23 09:35:01 2009].234645 msDrawMap(): Layer 1 (GRID), 0.040s
[Thu Apr 23 09:35:01 2009].235052 msDrawRasterLayerLow(LOGO): entering.
[Thu Apr 23 09:35:01 2009].284342 msDrawMap(): Layer 9 (LOGO), 0.050s
[Thu Apr 23 09:35:01 2009].284397 msDrawMap(): Drawing Label Cache, 0.000s
[Thu Apr 23 09:35:01 2009].284406 msDrawMap() total time: 0.177s
[Thu Apr 23 09:35:01 2009].332824 msSaveImage() total time: 0.048s
[Thu Apr 23 09:35:01 2009].332918 mapserv request processing time (msLoadMap not incl.): 0.226s
[Thu Apr 23 09:35:01 2009].332927 msFreeMap(): freeing map at 0x25d54d0.


More information about the mapserver-users mailing list