AW: [mapserver-users] Passing single quoted strings

Arnd Wippermann arnd.wippermann at web.de
Thu Apr 23 16:09:33 EDT 2009


Hi,

Another possibility:
somevalue = "filter \"datum between '2002-8-8' and '2002-8-9'\""; 

Perhaps this works.

Arnd

-----Ursprüngliche Nachricht-----
Von: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] Im Auftrag von Heiko
Schröter
Gesendet: Donnerstag, 23. April 2009 09:45
An: Steve Lime; mapserver-users at lists.osgeo.org
Betreff: Re: [mapserver-users] Passing single quoted strings

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'200
2-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'200
2-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




More information about the mapserver-users mailing list