Re: [mapserver-users] default values if not provided in the URL
On Oct 27, 2011, at 12:07 PM, Smith, Michael ERDC-CRREL-NH wrote: > I guess I get around that by passing class=1 as my filter so I can pass > 1=1 as the default > Hmmm... I didn't understand the above at all, but... > If you want to set a default that gets all, perhaps you could use a like > filter > > FILTER "Class like %class%" > > And a default of "%" > > The suggestion above works quite well. Here is what I did FILTER "class LIKE '%%class%%'" METADATA 'class_validation_pattern' '^[a-zA-Z ]+$' 'default_class' '%' END So, now I can do http://server/app and get everything. Or, request http://server/app?class=Foo and get a map with just "Foo". Now, the next problem to solve is to allow giving multiple class(es) as in http://server/app?class=Foo,Bar,Baz The only way I can think is to modify the filter like so FILTER "class IN (%class%)" which will allow me to pass values via http://server/app?class='Foo','Bar' but then I won't be able to get all the class(es). Besides, gosh, that URI looks super ugly. Thoughts? Maybe the cgi interface is malleable only to a degree. After that I have to start thinking of other ways of solving this. So, here is what I am thinking -- insert a proxy in between. That would allow me to let the user formulate queries any which way I want, and then reformat those queries to the way mapserver expect them. Of course, this proxy would have to sit between mapserver and the rest of the apps, which in my world includes OpenLayers. Would love any directions and suggestions to tackle this. > > > > On 10/27/11 9:56 AM, "Puneet Kishor" wrote: > >> >> On Oct 27, 2011, at 11:22 AM, Smith, Michael ERDC-CRREL-NH wrote: >> >>> Punnet, >>> >>> What I do in the situations where I want to default to all or allow some >>> filtered access is >>> >>> METADATA >>> "default_classes" "1=1" >>> END >>> >>> So the dummy condition is passed when no filter is specified. >>> >>> >>> >> >> >> Believe it or not, I thought up of the above solution myself but >> discarded it because I understood the text in the documents to mean the >> following -- >> >> FILTER "class = '%class%'" >> >> will be applied if a class is provided. However, if no class is provided, >> and if the following is provided >> >> METADATA >> "default_class" "1=1" >> END >> >> Then the filter will become "class = '1=1'", which is, of course not >> correct. And, I just checked the logs with the above mods, and my >> suspicion was proven correct. My log file shows ms croaking with the >> following >> >> select "class",encode(ST_AsBinary(ST_Force_2D("the_geoms"),'NDR'),'hex') >> as geom,"gid" from table where the_geoms && >> GeomFromText('POLYGON((-180.150250417362 -90,-180.150250417362 >> 90,180.150250417362 90,180.150250417362 -90,-180.150250417362 >> -90))',4326) and (class = '1=1') >> >> Obviously, I do not want "class = '1=1'" >> >> >>> >>> >>> >>> On 10/27/11 8:49 AM, "Puneet Kishor" wrote: >>> the fine manual says http://mapserver.org/cgi/runsub.html > Since version 5.6, you can provide a default value for any > substitution > parameter, that will be applied if the parameter was not found in the > url. > You do this by providing special entries inside the layer metadata : > > METADATA > 'default_sound' 'yes' > 'default_nseats' '5' > 'default_multimedia' 'yes' > END > > In this example, the mapfile will be created as if the url contained > ³&sound=yes&nseats=5&multimedia=yes² Right then. Except, I want *all* my classes to be drawn if no class has been provided. And, if one or more classes have been provided, then I want only those to be drawn. So, http://server/mapfile?mode=map should return a map with all the 100+ classes in a layer. And http://server/mapfile?mode=map&classes=Foo,Bar (or some other variation of the above) should return a map with only the requested classes in the layer. I can't think of anyway of doing the above without resorting to scripting, and I still have had no luck with WMS returned from Perl MapScripting. Suggestions. -- Puneet Kishor___ 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] default values if not provided in the URL
I guess I get around that by passing class=1 as my filter so I can pass 1=1 as the default If you want to set a default that gets all, perhaps you could use a like filter FILTER "Class like %class%" And a default of "%" Mike -- Michael Smith US Army Corps Remote Sensing GIS/Center On 10/27/11 9:56 AM, "Puneet Kishor" wrote: > >On Oct 27, 2011, at 11:22 AM, Smith, Michael ERDC-CRREL-NH wrote: > >> Punnet, >> >> What I do in the situations where I want to default to all or allow some >> filtered access is >> >> METADATA >> "default_classes" "1=1" >> END >> >> So the dummy condition is passed when no filter is specified. >> >> >> > > >Believe it or not, I thought up of the above solution myself but >discarded it because I understood the text in the documents to mean the >following -- > > FILTER "class = '%class%'" > >will be applied if a class is provided. However, if no class is provided, >and if the following is provided > > METADATA > "default_class" "1=1" > END > >Then the filter will become "class = '1=1'", which is, of course not >correct. And, I just checked the logs with the above mods, and my >suspicion was proven correct. My log file shows ms croaking with the >following > >select "class",encode(ST_AsBinary(ST_Force_2D("the_geoms"),'NDR'),'hex') >as geom,"gid" from table where the_geoms && >GeomFromText('POLYGON((-180.150250417362 -90,-180.150250417362 >90,180.150250417362 90,180.150250417362 -90,-180.150250417362 >-90))',4326) and (class = '1=1') > >Obviously, I do not want "class = '1=1'" > > >> >> >> >> On 10/27/11 8:49 AM, "Puneet Kishor" wrote: >> >>> the fine manual says http://mapserver.org/cgi/runsub.html >>> Since version 5.6, you can provide a default value for any substitution parameter, that will be applied if the parameter was not found in the url. You do this by providing special entries inside the layer metadata : METADATA 'default_sound' 'yes' 'default_nseats' '5' 'default_multimedia' 'yes' END In this example, the mapfile will be created as if the url contained ³&sound=yes&nseats=5&multimedia=yes² >>> >>> >>> Right then. Except, I want *all* my classes to be drawn if no class has >>> been provided. And, if one or more classes have been provided, then I >>> want only those to be drawn. So, >>> >>> http://server/mapfile?mode=map >>> >>> should return a map with all the 100+ classes in a layer. And >>> >>> http://server/mapfile?mode=map&classes=Foo,Bar >>> >>> (or some other variation of the above) should return a map with only >>>the >>> requested classes in the layer. I can't think of anyway of doing the >>> above without resorting to scripting, and I still have had no luck with >>> WMS returned from Perl MapScripting. >>> >>> Suggestions. >>> >>> -- >>> Puneet Kishor___ >>> 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] default values if not provided in the URL
On Oct 27, 2011, at 11:22 AM, Smith, Michael ERDC-CRREL-NH wrote: > Punnet, > > What I do in the situations where I want to default to all or allow some > filtered access is > > METADATA > "default_classes" "1=1" > END > > So the dummy condition is passed when no filter is specified. > > > Believe it or not, I thought up of the above solution myself but discarded it because I understood the text in the documents to mean the following -- FILTER "class = '%class%'" will be applied if a class is provided. However, if no class is provided, and if the following is provided METADATA "default_class" "1=1" END Then the filter will become "class = '1=1'", which is, of course not correct. And, I just checked the logs with the above mods, and my suspicion was proven correct. My log file shows ms croaking with the following select "class",encode(ST_AsBinary(ST_Force_2D("the_geoms"),'NDR'),'hex') as geom,"gid" from table where the_geoms && GeomFromText('POLYGON((-180.150250417362 -90,-180.150250417362 90,180.150250417362 90,180.150250417362 -90,-180.150250417362 -90))',4326) and (class = '1=1') Obviously, I do not want "class = '1=1'" > > > > On 10/27/11 8:49 AM, "Puneet Kishor" wrote: > >> the fine manual says http://mapserver.org/cgi/runsub.html >> >>> Since version 5.6, you can provide a default value for any substitution >>> parameter, that will be applied if the parameter was not found in the >>> url. >>> You do this by providing special entries inside the layer metadata : >>> >>> METADATA >>> 'default_sound' 'yes' >>> 'default_nseats' '5' >>> 'default_multimedia' 'yes' >>> END >>> >>> In this example, the mapfile will be created as if the url contained >>> ³&sound=yes&nseats=5&multimedia=yes² >> >> >> Right then. Except, I want *all* my classes to be drawn if no class has >> been provided. And, if one or more classes have been provided, then I >> want only those to be drawn. So, >> >> http://server/mapfile?mode=map >> >> should return a map with all the 100+ classes in a layer. And >> >> http://server/mapfile?mode=map&classes=Foo,Bar >> >> (or some other variation of the above) should return a map with only the >> requested classes in the layer. I can't think of anyway of doing the >> above without resorting to scripting, and I still have had no luck with >> WMS returned from Perl MapScripting. >> >> Suggestions. >> >> -- >> Puneet Kishor___ >> 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] default values if not provided in the URL
David, On Oct 27, 2011, at 11:19 AM, Fawcett, David (MPCA) wrote: > Two hackish thoughts: > > 1. Utilize a pair of mapfiles. The first one has all of the classes on by > default. The second one has all of the class with STATUS OFF. > > On the client side, you determine if you have any class args and route the > request to the appropriate mapfile. If the client has a request with class > args, you append one of these for each class '&map.layer[0].class[3]=status > on' (specifying the correct layer and class index values) > The mapserver request is being made in a number of ways. If there is control on the client side, then, yes, different map files can be requested. http://server/mapall returns all the classes, and http://server/mapfew?class=Foo,Bar returns only Foo and Bar However, the same URI is to be reused in other client apps as well (such as OL), so the ability to choose which map file to request is limited. In any case, for a number of "external" reasons, the URI is supposed to be unique, so http://server/mapall and http://server/mapfew violate that principle, however, http://server/mapthem (defaulting to 'class=All') and http://server/mapthem?class=Foo,Bar do not violate that uniqueness principle. Alright, moving on ... > If you only had a few classes, you could easily manage this with one mapfile > (without running up against the character limits on GET requests) > I said earlier that I have 100s of classes. I was wrong. Turns out I have 49 classes in this map file. However, in another map file I do have almost 700 classes. The use case is either the user gets all, or is able to specify one or two to filter and show only those. > 2. What are you really trying to do? It seem like classes are for selecting > and symbolizing/formatting data for output. Do you really want to filter out > the data using a filter at the layer level. If you can avoid running all of > your data through the expressions for each class, it should perform better > too. > Dunno how else to explain but with the following text -- the table (aka a layer) has a column called "classes" and these classes map to specific colors stored in another column. I want to be able to return a map as per the URI rules above. > David. > > -Original Message- > From: mapserver-users-boun...@lists.osgeo.org > [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Puneet Kishor > Sent: Thursday, October 27, 2011 10:50 AM > To: mapserver-users@lists.osgeo.org > Subject: [mapserver-users] default values if not provided in the URL > > the fine manual says http://mapserver.org/cgi/runsub.html > >> Since version 5.6, you can provide a default value for any substitution >> parameter, that will be applied if the parameter was not found in the url. >> You do this by providing special entries inside the layer metadata : >> >> METADATA >> 'default_sound' 'yes' >> 'default_nseats' '5' >> 'default_multimedia' 'yes' >> END >> >> In this example, the mapfile will be created as if the url contained >> "&sound=yes&nseats=5&multimedia=yes" > > > Right then. Except, I want *all* my classes to be drawn if no class has been > provided. And, if one or more classes have been provided, then I want only > those to be drawn. So, > > http://server/mapfile?mode=map > > should return a map with all the 100+ classes in a layer. And > > http://server/mapfile?mode=map&classes=Foo,Bar > > (or some other variation of the above) should return a map with only the > requested classes in the layer. I can't think of anyway of doing the above > without resorting to scripting, and I still have had no luck with WMS > returned from Perl MapScripting. > > Suggestions. > > -- > Puneet Kishor___ > 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] default values if not provided in the URL
Punnet, What I do in the situations where I want to default to all or allow some filtered access is METADATA "default_classes" "1=1" END So the dummy condition is passed when no filter is specified. Mike -- Michael Smith US Army Corps Remote Sensing GIS/Center On 10/27/11 8:49 AM, "Puneet Kishor" wrote: >the fine manual says http://mapserver.org/cgi/runsub.html > >> Since version 5.6, you can provide a default value for any substitution >> parameter, that will be applied if the parameter was not found in the >>url. >> You do this by providing special entries inside the layer metadata : >> >> METADATA >> 'default_sound' 'yes' >> 'default_nseats' '5' >> 'default_multimedia' 'yes' >> END >> >> In this example, the mapfile will be created as if the url contained >> ³&sound=yes&nseats=5&multimedia=yes² > > >Right then. Except, I want *all* my classes to be drawn if no class has >been provided. And, if one or more classes have been provided, then I >want only those to be drawn. So, > > http://server/mapfile?mode=map > >should return a map with all the 100+ classes in a layer. And > > http://server/mapfile?mode=map&classes=Foo,Bar > >(or some other variation of the above) should return a map with only the >requested classes in the layer. I can't think of anyway of doing the >above without resorting to scripting, and I still have had no luck with >WMS returned from Perl MapScripting. > >Suggestions. > >-- >Puneet Kishor___ >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] default values if not provided in the URL
Two hackish thoughts: 1. Utilize a pair of mapfiles. The first one has all of the classes on by default. The second one has all of the class with STATUS OFF. On the client side, you determine if you have any class args and route the request to the appropriate mapfile. If the client has a request with class args, you append one of these for each class '&map.layer[0].class[3]=status on' (specifying the correct layer and class index values) If you only had a few classes, you could easily manage this with one mapfile (without running up against the character limits on GET requests) 2. What are you really trying to do? It seem like classes are for selecting and symbolizing/formatting data for output. Do you really want to filter out the data using a filter at the layer level. If you can avoid running all of your data through the expressions for each class, it should perform better too. David. -Original Message- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Puneet Kishor Sent: Thursday, October 27, 2011 10:50 AM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] default values if not provided in the URL the fine manual says http://mapserver.org/cgi/runsub.html > Since version 5.6, you can provide a default value for any substitution > parameter, that will be applied if the parameter was not found in the url. > You do this by providing special entries inside the layer metadata : > > METADATA > 'default_sound' 'yes' > 'default_nseats' '5' > 'default_multimedia' 'yes' > END > > In this example, the mapfile will be created as if the url contained > "&sound=yes&nseats=5&multimedia=yes" Right then. Except, I want *all* my classes to be drawn if no class has been provided. And, if one or more classes have been provided, then I want only those to be drawn. So, http://server/mapfile?mode=map should return a map with all the 100+ classes in a layer. And http://server/mapfile?mode=map&classes=Foo,Bar (or some other variation of the above) should return a map with only the requested classes in the layer. I can't think of anyway of doing the above without resorting to scripting, and I still have had no luck with WMS returned from Perl MapScripting. Suggestions. -- Puneet Kishor___ 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