Re: [mapserver-users] Parameterized MapFile using CGI variable
Yes. Just as you have suggested. Have a CGI wrapper script, which determines the variable's value based on hostname (or whatever), then append this (to the QUERY_STRING prior to executing mapserver. See: http://mapserver.org/cgi/wrapper.html As shown in the link below, both the CONNECTION & DATA strings in the mapfile are supported by the preprocessor for variable substitution. http://mapserver.org/mapfile/variable_sub.html Cheers, Brent Wood --- On Sat, 4/30/11, Nicolas BOUTET wrote: From: Nicolas BOUTET Subject: [mapserver-users] Parameterized MapFile using CGI variable To: mapserver-users@lists.osgeo.org Date: Saturday, April 30, 2011, 1:56 AM Dear All, I have 2 MapServer servers. One for Production use, and the other for Validation use.The MAP files placed on those servers are similar except that each server has a different Oracle database as datasource.For now, I have some different CONNECTION values depending if the map file is on the Production or on the Validation server. So finally I must have different MAP files. Is there a way to have exactly the same map files on the 2 servers, and to use a variable to parameterize the CONNECTION. For example, I would like to set the CONNECTION of my layers to “%ORACLECONNECTIONSTRING%” and to set a CGI Environment variable named ORACLECONNECTIONSTRING to the correct value on each server. Nicolas -Inline Attachment Follows- ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] Parameterized MapFile using CGI variable
Yes, I realize reading you that the include statement can be inserted at any place in the main Map file. So, it works !!! Thanks a lot David De : Fawcett, David (MPCA) [mailto:david.fawc...@state.mn.us] Envoyé : vendredi 29 avril 2011 17:03 À : nicolas.bou...@geosys.com; mapserver-users@lists.osgeo.org Objet : RE: [mapserver-users] Parameterized MapFile using CGI variable Nicolas, I didnt have a mapfile that utilizes connection handy, but I did test using INCLUDE to substitute the value for DATA in an individual layer. Here is part of the layer definition: LAYER NAME "watersheds" STATUS DEFAULT #DATA 'majclip' INCLUDE "inc_data_majclip.map" TYPE POLYGON The file inc_data_majclip.map contains: DATA "majclip" Based on this, I would assume that you should be able to do the same with the CONNECTION for each of your layers. David. From: Nicolas BOUTET [mailto:nicolas.bou...@geosys.com] Sent: Friday, April 29, 2011 9:49 AM To: Fawcett, David (MPCA); mapserver-users@lists.osgeo.org Subject: RE: [mapserver-users] Parameterized MapFile using CGI variable Thank you David, Yes, using INCLUDE should be a good solution. But as I know in MapServer 5.6, CONNECTION is a parameter of my LAYER objects, and not an object itself. So I cannot have a CONNECTION object declared in a separate map file And I prefer to not have to duplicate the layers in different map files. Nicolas De : Fawcett, David (MPCA) [mailto:david.fawc...@state.mn.us] Envoyé : vendredi 29 avril 2011 16:37 À : nicolas.bou...@geosys.com; mapserver-users@lists.osgeo.org Objet : RE: [mapserver-users] Parameterized MapFile using CGI variable One potential way to do it would be with the use of includes. http://mapserver.org/mapfile/Include.html The primary mapfile wouldnt have a connection object, but it would contain: INCLUDE connect_info.map Then on each machine, you would have a different version of connect_info.map that contained the correct connection object for that machine. This wouldnt give you the flexibility of changing it through the CGI interface, but would allow you to use the same exact mapfile on both machines. David. From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Nicolas BOUTET Sent: Friday, April 29, 2011 8:57 AM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Parameterized MapFile using CGI variable Dear All, I have 2 MapServer servers. One for Production use, and the other for Validation use. The MAP files placed on those servers are similar except that each server has a different Oracle database as datasource. For now, I have some different CONNECTION values depending if the map file is on the Production or on the Validation server. So finally I must have different MAP files. Is there a way to have exactly the same map files on the 2 servers, and to use a variable to parameterize the CONNECTION. For example, I would like to set the CONNECTION of my layers to %ORACLECONNECTIONSTRING% and to set a CGI Environment variable named ORACLECONNECTIONSTRING to the correct value on each server. Nicolas ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Parameterized MapFile using CGI variable
Hi, No problem at all. I have it this way For each layer LAYER STATUS ON GROUP "default" PROJECTION "init=epsg:3067" END INCLUDE "/usr/map/connection_osm_i.map" maxscaledenom 500010 minscaledenom 250010 TYPE LINE NAME "roadsclose" DATA "way from (select way, osm_id ,highway,ref, name, tunnel from osm_line where highway is not null order by priority desc) as foo using unique osm_id using srid=3067" ... ... And the "/usr/map/connection_osm_i.map" file is CONNECTIONTYPE postgis CONNECTION "host=localhost dbname=xxx user=yyy password=zzz port=5432" PROCESSING "CLOSE_CONNECTION=DEFER" Helps a lot when changing something on the database side also because there is only one place to update in the mapfiles. -Jukka Rahkonen- -Alkuperäi nen viesti- Lähettäjä: mapserver-users-boun...@lists.osgeo.org puolesta: Nicolas BOUTET Lähetetty: pe 29.4.2011 17:49 Vastaanottaja: 'Fawcett, David (MPCA)'; mapserver-users@lists.osgeo.org Aihe: RE: [mapserver-users] Parameterized MapFile using CGI variable Thank you David, Yes, using INCLUDE should be a good solution. But as I know in MapServer 5.6, CONNECTION is a parameter of my LAYER objects, and not an object itself. So I cannot have a CONNECTION object declared in a separate map file. And I prefer to not have to duplicate the layers in different map files. Nicolas De : Fawcett, David (MPCA) [mailto:david.fawc...@state.mn.us] Envoyé : vendredi 29 avril 2011 16:37 À : nicolas.bou...@geosys.com; mapserver-users@lists.osgeo.org Objet : RE: [mapserver-users] Parameterized MapFile using CGI variable One potential way to do it would be with the use of 'include's. http://mapserver.org/mapfile/Include.html The primary mapfile wouldn't have a connection object, but it would contain: INCLUDE "connect_info.map" Then on each machine, you would have a different version of connect_info.map that contained the correct connection object for that machine. This wouldn't give you the flexibility of changing it through the CGI interface, but would allow you to use the same exact mapfile on both machines. David. From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Nicolas BOUTET Sent: Friday, April 29, 2011 8:57 AM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Parameterized MapFile using CGI variable Dear All, I have 2 MapServer servers. One for Production use, and the other for Validation use. The MAP files placed on those servers are similar except that each server has a different Oracle database as datasource. For now, I have some different CONNECTION values depending if the map file is on the Production or on the Validation server. So finally I must have different MAP files. Is there a way to have exactly the same map files on the 2 servers, and to use a variable to parameterize the CONNECTION. For example, I would like to set the CONNECTION of my layers to "%ORACLECONNECTIONSTRING%" and to set a CGI Environment variable named ORACLECONNECTIONSTRING to the correct value on each server. Nicolas ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Parameterized MapFile using CGI variable
As David stated, the INCLUDE keyword does not have to be a full mapserver object, it can be any valid mapserver keywords. -- thomas On Fri, Apr 29, 2011 at 16:49, Nicolas BOUTET wrote: > Thank you David, > > > > Yes, using INCLUDE should be a good solution. But as I know in MapServer > 5.6, CONNECTION is a parameter of my LAYER objects, and not an object > itself. So I cannot have a CONNECTION object declared in a separate map > file… And I prefer to not have to duplicate the layers in different map > files. > > > > Nicolas > > > > > > De : Fawcett, David (MPCA) [mailto:david.fawc...@state.mn.us] > > Envoyé : vendredi 29 avril 2011 16:37 > À : nicolas.bou...@geosys.com; mapserver-users@lists.osgeo.org > Objet : RE: [mapserver-users] Parameterized MapFile using CGI variable > > > > One potential way to do it would be with the use of ‘include’s. > > > > http://mapserver.org/mapfile/Include.html > > > > The primary mapfile wouldn’t have a connection object, but it would contain: > > > > INCLUDE “connect_info.map” > > > > Then on each machine, you would have a different version of connect_info.map > that contained the correct connection object for that machine. > > > > This wouldn’t give you the flexibility of changing it through the CGI > interface, but would allow you to use the same exact mapfile on both > machines. > > > > David. > > > > From: mapserver-users-boun...@lists.osgeo.org > [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Nicolas BOUTET > Sent: Friday, April 29, 2011 8:57 AM > To: mapserver-users@lists.osgeo.org > Subject: [mapserver-users] Parameterized MapFile using CGI variable > > > > Dear All, > > > > I have 2 MapServer servers. One for Production use, and the other for > Validation use. > > The MAP files placed on those servers are similar except that each server > has a different Oracle database as datasource. > > For now, I have some different CONNECTION values depending if the map file > is on the Production or on the Validation server. So finally I must have > different MAP files. > > > > Is there a way to have exactly the same map files on the 2 servers, and to > use a variable to parameterize the CONNECTION. > > > > For example, I would like to set the CONNECTION of my layers to > “%ORACLECONNECTIONSTRING%” and to set a CGI Environment variable named > ORACLECONNECTIONSTRING to the correct value on each server. > > > > Nicolas > > > > ___ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/mapserver-users > > ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] Parameterized MapFile using CGI variable
Thank you David, Yes, using INCLUDE should be a good solution. But as I know in MapServer 5.6, CONNECTION is a parameter of my LAYER objects, and not an object itself. So I cannot have a CONNECTION object declared in a separate map file And I prefer to not have to duplicate the layers in different map files. Nicolas De : Fawcett, David (MPCA) [mailto:david.fawc...@state.mn.us] Envoyé : vendredi 29 avril 2011 16:37 À : nicolas.bou...@geosys.com; mapserver-users@lists.osgeo.org Objet : RE: [mapserver-users] Parameterized MapFile using CGI variable One potential way to do it would be with the use of includes. http://mapserver.org/mapfile/Include.html The primary mapfile wouldnt have a connection object, but it would contain: INCLUDE connect_info.map Then on each machine, you would have a different version of connect_info.map that contained the correct connection object for that machine. This wouldnt give you the flexibility of changing it through the CGI interface, but would allow you to use the same exact mapfile on both machines. David. From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Nicolas BOUTET Sent: Friday, April 29, 2011 8:57 AM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Parameterized MapFile using CGI variable Dear All, I have 2 MapServer servers. One for Production use, and the other for Validation use. The MAP files placed on those servers are similar except that each server has a different Oracle database as datasource. For now, I have some different CONNECTION values depending if the map file is on the Production or on the Validation server. So finally I must have different MAP files. Is there a way to have exactly the same map files on the 2 servers, and to use a variable to parameterize the CONNECTION. For example, I would like to set the CONNECTION of my layers to %ORACLECONNECTIONSTRING% and to set a CGI Environment variable named ORACLECONNECTIONSTRING to the correct value on each server. Nicolas ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] Parameterized MapFile using CGI variable
Nicolas, I didn't have a mapfile that utilizes connection handy, but I did test using INCLUDE to substitute the value for DATA in an individual layer. Here is part of the layer definition: LAYER NAME "watersheds" STATUS DEFAULT #DATA 'majclip' INCLUDE "inc_data_majclip.map" TYPE POLYGON The file inc_data_majclip.map contains: DATA "majclip" Based on this, I would assume that you should be able to do the same with the CONNECTION for each of your layers. David. From: Nicolas BOUTET [mailto:nicolas.bou...@geosys.com] Sent: Friday, April 29, 2011 9:49 AM To: Fawcett, David (MPCA); mapserver-users@lists.osgeo.org Subject: RE: [mapserver-users] Parameterized MapFile using CGI variable Thank you David, Yes, using INCLUDE should be a good solution. But as I know in MapServer 5.6, CONNECTION is a parameter of my LAYER objects, and not an object itself. So I cannot have a CONNECTION object declared in a separate map file... And I prefer to not have to duplicate the layers in different map files. Nicolas De : Fawcett, David (MPCA) [mailto:david.fawc...@state.mn.us] Envoyé : vendredi 29 avril 2011 16:37 À : nicolas.bou...@geosys.com; mapserver-users@lists.osgeo.org Objet : RE: [mapserver-users] Parameterized MapFile using CGI variable One potential way to do it would be with the use of 'include's. http://mapserver.org/mapfile/Include.html The primary mapfile wouldn't have a connection object, but it would contain: INCLUDE "connect_info.map" Then on each machine, you would have a different version of connect_info.map that contained the correct connection object for that machine. This wouldn't give you the flexibility of changing it through the CGI interface, but would allow you to use the same exact mapfile on both machines. David. From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Nicolas BOUTET Sent: Friday, April 29, 2011 8:57 AM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Parameterized MapFile using CGI variable Dear All, I have 2 MapServer servers. One for Production use, and the other for Validation use. The MAP files placed on those servers are similar except that each server has a different Oracle database as datasource. For now, I have some different CONNECTION values depending if the map file is on the Production or on the Validation server. So finally I must have different MAP files. Is there a way to have exactly the same map files on the 2 servers, and to use a variable to parameterize the CONNECTION. For example, I would like to set the CONNECTION of my layers to "%ORACLECONNECTIONSTRING%" and to set a CGI Environment variable named ORACLECONNECTIONSTRING to the correct value on each server. Nicolas ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] Parameterized MapFile using CGI variable
One potential way to do it would be with the use of 'include's. http://mapserver.org/mapfile/Include.html The primary mapfile wouldn't have a connection object, but it would contain: INCLUDE "connect_info.map" Then on each machine, you would have a different version of connect_info.map that contained the correct connection object for that machine. This wouldn't give you the flexibility of changing it through the CGI interface, but would allow you to use the same exact mapfile on both machines. David. From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Nicolas BOUTET Sent: Friday, April 29, 2011 8:57 AM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Parameterized MapFile using CGI variable Dear All, I have 2 MapServer servers. One for Production use, and the other for Validation use. The MAP files placed on those servers are similar except that each server has a different Oracle database as datasource. For now, I have some different CONNECTION values depending if the map file is on the Production or on the Validation server. So finally I must have different MAP files. Is there a way to have exactly the same map files on the 2 servers, and to use a variable to parameterize the CONNECTION. For example, I would like to set the CONNECTION of my layers to "%ORACLECONNECTIONSTRING%" and to set a CGI Environment variable named ORACLECONNECTIONSTRING to the correct value on each server. Nicolas ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users