[mapserver-users] runtime substitution DATA

Guillaume Sueur no-reply at neogeo-online.net
Wed Feb 25 11:31:34 EST 2009


These are a really good explanation and examples Steve ! Many many
thanks, I'm going to put my hands into it !

Regards,

Guillaume


Steve Lime a écrit :
> You should be able to use either approach. To change the whole thing you'd do:
> 
>   &map.layer[mylayer]=DATA+'some new SQL string'&...
> 
> but in this case you must set DATAPATTERN at the map level to a regular expression to use
> to validate the new SQL. I think this is really hard to do properly and so should probably be
> avoided.
> 
> Another alternative is replacing just parts of the SQL, kind of an SQL template approach, here's
> an example I'm using in production now:
> 
>   DATA "point FROM (SELECT *,oid FROM sites2 WHERE has_telemetry ~ '%has_telemetry%' AND has_archive ~ '%has_archive%' AND has_water_chemistry ~ '%has_water_chemistry%' AND is_cwl_site ~ '%is_cwl_site%' AND is_flood_warning_gage ~ '%is_flood_warning_gage%') as foo USING UNIQUE oid USING SRID=-1"
>     METADATA
>       has_telemetry_validation_pattern '^[01.]$'
>       has_archive_validation_pattern '^[01.]$'
>       has_water_chemistry_validation_pattern '^[01.]$'
>       is_cwl_site_validation_pattern '^[01.]$'
>       is_flood_warning_gage_validation_pattern '^[01.]$'
>     END
> 
> In this example my data contain 0 or 1 depending on the properties of a site. I want to allow the user 
> to pick 0, 1 or either so I use regex's in PostgreSQL (hence the . being a legal character from my 
> application. The validation patterns restrict input to 0,1 or . (e.g. either). Another example:
> 
>     DATA 'point FROM (select *,oid, substring(station from 2) as station_no_char from sites2 where oid=%id%) as foo USING UNIQUE oid USING SRID=-1'
>     METADATA
>       id_validation_pattern '^[0-9]{1,14}$'
>     END
> 
> Here I'm using the oid to identify one site and the validation pattern to limit input to a sequence of 
> numbers from 1 to 14 characters in length. If the value for "id" doesn't match then an error is thrown.
> 
> Steve
> 
>>>> On 2/25/2009 at 3:07 AM, in message <49A50A6E.90406 at neogeo-online.net>,
> Guillaume Sueur <no-reply at neogeo-online.net> wrote:
>> Hi list,
>>
>> I'm trying to change the DATA statement of a PostGIS Layer on the fly,
>> from a WMS request.
>> I made it work for FILTER or EXPRESSION, but no success with DATA,
>> either using my %PARAM% in the middle of the SQL string or for the whole
>> thing.
>> I've seen here (http://mapserver.org/cgi/runsub.html) that it should
>> validate a DATAPATTERN.
>>
>> Would someone have some clues about this ?
>>
>> Thanks
>>
>> Guillaume
>> _______________________________________________
>> 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