[mapserver-users] Mapserver Template - Conditionals
Hi List, A few questions/points on templating: 1. I know it's possible to use "item" in a template as follows: [item name="featurecode" pattern="10021" format="BuildingsBuilding" escape=none] But, is it possible to do something like: [item featurecode="10021" pattern="1" AND item lineitem="12345" pattern="2" format="."] That is, returns true of both, or more, criteria are met. The only other way I can think of doing this is in the SQL query that runs on the layer. 2. Also, when I use use [item ...] and the criteria isn't met, it still causes an additional blank line to be created in the output file. It would be quite good if it did not create the cr/lf. Maybe nullformat could be used to enforce this in some way but nullformat="" still creates a blank line. 3. It would be nice if the item tag could also deal with a case/select statement e.g. [item name="A" pattern="1" format="Output1"] ELSE [item name="B" pattern="2" format="Output2"] ELSE [item name="C" pattern="3" format="Output3"] DEFAULT [item name="D" pattern="4" format="Output4"] 4. And finally, when using: [resultset layer=LayerName] [feature] Two blank lines are created in the output file. It would be good if these tags didn't do that. Many thanks. Regards, Donald ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mapserver Template - Conditionals
Hi Donald: To answer your questions... 1. You can't do an AND with [item ...] tags. They are single item only. We'd really need to introduce true conditionals into the templates. It's done a bit for legend templates but I don't know how much work is necessary to extend that. One work around idea would be to create a compound item if using a RDMS data source and write patterns against that. 2. Consider filing ticket for that one. Covers item 4 too. 3. I actually had something along those lines in mind at one point. I'll have to check my old notes. Note that if the patterns are mutually exclusive you can just write: [item name="A" pattern="1" format="Output1"][item name="B" pattern="2" format="Output2"][item name="C" pattern="3" format="Output3" nullformat="Output4"] The default format would just be the null format for one of these. But I agree this has it's limits... Steve -Original Message- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Donald Kerr Sent: Wednesday, July 25, 2012 2:25 PM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Mapserver Template - Conditionals Hi List, A few questions/points on templating: 1. I know it's possible to use "item" in a template as follows: [item name="featurecode" pattern="10021" format="BuildingsBuilding" escape=none] But, is it possible to do something like: [item featurecode="10021" pattern="1" AND item lineitem="12345" pattern="2" format="."] That is, returns true of both, or more, criteria are met. The only other way I can think of doing this is in the SQL query that runs on the layer. 2. Also, when I use use [item ...] and the criteria isn't met, it still causes an additional blank line to be created in the output file. It would be quite good if it did not create the cr/lf. Maybe nullformat could be used to enforce this in some way but nullformat="" still creates a blank line. 3. It would be nice if the item tag could also deal with a case/select statement e.g. [item name="A" pattern="1" format="Output1"] ELSE [item name="B" pattern="2" format="Output2"] ELSE [item name="C" pattern="3" format="Output3"] DEFAULT [item name="D" pattern="4" format="Output4"] 4. And finally, when using: [resultset layer=LayerName] [feature] Two blank lines are created in the output file. It would be good if these tags didn't do that. Many thanks. Regards, Donald ___ 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] Mapserver Template - Conditionals
Steve, Thanks for your input again. I've filed a ticket for 2 and 4 as I think that would tidy things up a good deal. Although blank lines don't really cause any problem, it's a bit untidy and, if there are a load of "item" declarations, there can be a lot of blank lines. See ticket here: https://github.com/mapserver/mapserver/issues/4415 As for 1 and 3, I can get around that with case statements in Postgres SQL but I was trying to do it all in either SQL or the template rather than a bit of both. Thanks again. Regards. Donald -Original Message- From: Lime, Steve D (DNR) [mailto:steve.l...@state.mn.us] Sent: 03 August 2012 18:22 To: Donald Kerr; mapserver-users@lists.osgeo.org Subject: RE: [mapserver-users] Mapserver Template - Conditionals Hi Donald: To answer your questions... 1. You can't do an AND with [item ...] tags. They are single item only. We'd really need to introduce true conditionals into the templates. It's done a bit for legend templates but I don't know how much work is necessary to extend that. One work around idea would be to create a compound item if using a RDMS data source and write patterns against that. 2. Consider filing ticket for that one. Covers item 4 too. 3. I actually had something along those lines in mind at one point. I'll have to check my old notes. Note that if the patterns are mutually exclusive you can just write: [item name="A" pattern="1" format="Output1"][item name="B" pattern="2" format="Output2"][item name="C" pattern="3" format="Output3" nullformat="Output4"] The default format would just be the null format for one of these. But I agree this has it's limits... Steve -Original Message- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Donald Kerr Sent: Wednesday, July 25, 2012 2:25 PM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Mapserver Template - Conditionals Hi List, A few questions/points on templating: 1. I know it's possible to use "item" in a template as follows: [item name="featurecode" pattern="10021" format="BuildingsBuilding" escape=none] But, is it possible to do something like: [item featurecode="10021" pattern="1" AND item lineitem="12345" pattern="2" format="."] That is, returns true of both, or more, criteria are met. The only other way I can think of doing this is in the SQL query that runs on the layer. 2. Also, when I use use [item ...] and the criteria isn't met, it still causes an additional blank line to be created in the output file. It would be quite good if it did not create the cr/lf. Maybe nullformat could be used to enforce this in some way but nullformat="" still creates a blank line. 3. It would be nice if the item tag could also deal with a case/select statement e.g. [item name="A" pattern="1" format="Output1"] ELSE [item name="B" pattern="2" format="Output2"] ELSE [item name="C" pattern="3" format="Output3"] DEFAULT [item name="D" pattern="4" format="Output4"] 4. And finally, when using: [resultset layer=LayerName] [feature] Two blank lines are created in the output file. It would be good if these tags didn't do that. Many thanks. Regards, Donald ___ 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