[Geoserver-users] Variable substitution (with ENV=) in an SLD with multiple rules

I have two possibly related issues that I’m not sure if are bugs, user error or simply something I’ve missed in the documentation.

Both have to do with using variable substitution in an SLD.

Background: I have a 16-color gradient that by default goes from 0-256 in equal steps. If the request includes ENV=min:n;max:m then instead of using 0-256 for the range, n-m is used. This part has been and is working great.

Issue 1) It seems that environment variables aren’t evaluated inside the label tag.

Now I wanted to generate a legend. Since the values at the breaks can change with the environment variables, I wanted to use the environment variables in the label. Instead of evaluating the environment variables, the literal statements are printed.

Issue 2) Variable Substitution doesn’t seem to work when multiple rules are present.

During this process I added a second rule to the SLD. When a second rule is present, it appears that variables are not substituted, although the ${env(‘max’,256)} does resolve to 256 (instead of the ENV=max:m value) and no errors are seen.

My data layers are .tiff file with various value ranges.

My SLD file is here: http://pastebin.com/iBsRU1Mk

My test request looks like this. This particular image has a value range of about 3 to 5. This is the same WMS request that the OpenLayers view makes, except with ENV=min:0;max:10 tacked on the end. It’s at scale 1:4261.

With the SLD with two rules (as in the Pasebin above) the image renders solid black which corresponds to the first bucket (0-15.99) of the default color ramp. If I delete the second rule and make the same request the image renders in red tones, which is what I expect with the dynamic color ramp.

http://myserver/geoserver/client-farms/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fjpeg&TRANSPARENT=true&STYLES=test&LAYERS=client-farms%3Afname-client_florida-10-west-qtr_18-ac-field_2013_grid-sampling_organic-matter&SRS=EPSG%3A4326&WIDTH=769&HEIGHT=331&BBOX=???.40126472711921%2C44.78623741864801%2C???.39302247762322%2C44.789780437949894&ENV=min:0;max:10

2016-06-30 11:40:14,013 INFO [org.geoserver.wms] -
Request: getMap
FeatureVersion = null
Sld = null
Filters = null
BgColor = java.awt.Color[r=255,g=255,b=255]
RemoteOwsURL = null
FormatOptions = {}
FeatureId = null
Elevation =
ViewParams = null
RemoteOwsType = null
StartIndex = null
CQLFilter = null
Tiled = false
Transparent = true
SldBody = null
StyleFormat = sld
StyleUrl = null
TilesOrigin = null
ValidateSchema = false
Interpolations =
Palette = null
SRS = EPSG:4326
Styles = [StyleImpl[ name=test]]
Layers = [org.geoserver.wms.MapLayerInfo@anonymised.com]
MaxFeatures = null
Crs = GEOGCS[“WGS 84”,
DATUM[“World Geodetic System 1984”,
SPHEROID[“WGS 84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”,“7030”]],
AUTHORITY[“EPSG”,“6326”]],
PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”,“8901”]],
UNIT[“degree”, 0.017453292519943295],
AXIS[“Geodetic longitude”, EAST],
AXIS[“Geodetic latitude”, NORTH],
AUTHORITY[“EPSG”,“4326”]]
Bbox = SRSEnvelope[???.40126472711921 : ???.39302247762322, 44.78623741864801 : 44.789780437949894]
Env = {GSUSER=admin, MAX=13, MIN=0}
Angle = 0.0
Exceptions = SE_XML
StyleBody = null
SldVersion = null
StyleVersion = null
ScaleMethod = null
Time =
Height = 331
Width = 769
Format = image/jpeg
Buffer = 0
Filter = null
Get = true
Request = GetMap
BaseUrl = http://myserver:80/geoserver/
RawKvp = {FORMAT=image/jpeg, REQUEST=GetMap, SRS=EPSG:4326, BBOX=???.40126472711921,44.78623741864801,???.39302247762322,44.789780437949894, VERSION=1.1.1, STYLES=test, WIDTH=769, SERVICE=WMS, HEIGHT=331, ENV=min:0;max:13, TRANSPARENT=true, LAYERS=client-farms:fname-client_florida-10-west-qtr_18-ac-field_2013_grid-sampling_organic-matter}
RequestCharset = UTF-8
Version = 1.1.1
2016-06-30 11:40:14,029 DEBUG [org.geoserver.config.impl] - Could not locate service of type interface org.geoserver.wms.WMSInfo in workspace WorkspaceInfoImpl[client-farms], available services were [WCSInfoImpl[WCS], WFSInfoImpl[WFS], WMSInfoImpl[WMS]]
2016-06-30 11:40:14,060 DEBUG [org.geoserver.filters] - Not compressing output for mimetype: image/jpeg
2016-06-30 11:40:14,060 DEBUG [org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1] - SecurityContextHolder now cleared, as request processing completed
2016-06-30 11:40:17,196 DEBUG [org.geoserver.security.IncludeQueryStringAntPathRequestMatcher] - Checking match of request : ‘Path: /web/wicket/bookmarkable/org.geoserver.web.admin.logpage, QueryString: 73&lines=1000’; against '/web/
2016-06-30 11:40:17,196 DEBUG [org.geoserver.security.IncludeQueryStringAntPathRequestMatcher] - Matched Path: /web/wicket/bookmarkable/org.geoserver.web.admin.logpage, QueryString: 73&lines=1000 with /web/

2016-06-30 11:40:17,196 TRACE [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/web/wicket/bookmarkable/org.geoserver.web.admin.LogPage]
2016-06-30 11:40:17,196 TRACE [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/web/wicket/bookmarkable/org.geoserver.web.admin.LogPage]
2016-06-30 11:40:17,196 TRACE [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/web/wicket/bookmarkable/org.geoserver.web.admin.LogPage]
2016-06-30 11:40:17,196 TRACE [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/web/wicket/bookmarkable/org.geoserver.web.admin.LogPage]
2016-06-30 11:40:17,227 DEBUG [org.geoserver] - Thread 20 locking in mode WRITE
2016-06-30 11:40:17,227 DEBUG [org.geoserver] - Thread 20 got the lock in mode WRITE

Info that might be relevant:

GeoServer Version
2.9-beta2
Git Revision
e0aa7e3509b12a6838cdb8187ef327c149302beb
Build Date
21-Apr-2016 04:41
GeoTools Version
15-beta2 (rev be8fc7adf7d3f016fc298dce9daeafbe50899381)
GeoWebCache Version
1.9-beta2 (rev master/806006ed652e11d6f3d4ea694d15a16a989a4852)

This is running on Windows Server 2012 (64 bit), but running 32 bit GeoServer and 32 bit java.


Michael Moore

Hi Michael,
known issue, check the archives for discussion and link to a ticket.

Cheers
Andrea

···

On Thu, Jun 30, 2016 at 6:58 PM, Michael Moore <stuporglue@anonymised.com> wrote:

I have two possibly related issues that I’m not sure if are bugs, user error or simply something I’ve missed in the documentation.

Both have to do with using variable substitution in an SLD.

Background: I have a 16-color gradient that by default goes from 0-256 in equal steps. If the request includes ENV=min:n;max:m then instead of using 0-256 for the range, n-m is used. This part has been and is working great.

Issue 1) It seems that environment variables aren’t evaluated inside the label tag.

Now I wanted to generate a legend. Since the values at the breaks can change with the environment variables, I wanted to use the environment variables in the label. Instead of evaluating the environment variables, the literal statements are printed.

Issue 2) Variable Substitution doesn’t seem to work when multiple rules are present.

During this process I added a second rule to the SLD. When a second rule is present, it appears that variables are not substituted, although the ${env(‘max’,256)} does resolve to 256 (instead of the ENV=max:m value) and no errors are seen.

My data layers are .tiff file with various value ranges.

My SLD file is here: http://pastebin.com/iBsRU1Mk

My test request looks like this. This particular image has a value range of about 3 to 5. This is the same WMS request that the OpenLayers view makes, except with ENV=min:0;max:10 tacked on the end. It’s at scale 1:4261.

With the SLD with two rules (as in the Pasebin above) the image renders solid black which corresponds to the first bucket (0-15.99) of the default color ramp. If I delete the second rule and make the same request the image renders in red tones, which is what I expect with the dynamic color ramp.

http://myserver/geoserver/client-farms/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fjpeg&TRANSPARENT=true&STYLES=test&LAYERS=client-farms%3Afname-client_florida-10-west-qtr_18-ac-field_2013_grid-sampling_organic-matter&SRS=EPSG%3A4326&WIDTH=769&HEIGHT=331&BBOX=???.40126472711921%2C44.78623741864801%2C???.39302247762322%2C44.789780437949894&ENV=min:0;max:10

2016-06-30 11:40:14,013 INFO [org.geoserver.wms] -
Request: getMap
FeatureVersion = null
Sld = null
Filters = null
BgColor = java.awt.Color[r=255,g=255,b=255]
RemoteOwsURL = null
FormatOptions = {}
FeatureId = null
Elevation =
ViewParams = null
RemoteOwsType = null
StartIndex = null
CQLFilter = null
Tiled = false
Transparent = true
SldBody = null
StyleFormat = sld
StyleUrl = null
TilesOrigin = null
ValidateSchema = false
Interpolations =
Palette = null
SRS = EPSG:4326
Styles = [StyleImpl[ name=test]]
Layers = [org.geoserver.wms.MapLayerInfo@anonymised.com]
MaxFeatures = null
Crs = GEOGCS[“WGS 84”,
DATUM[“World Geodetic System 1984”,
SPHEROID[“WGS 84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”,“7030”]],
AUTHORITY[“EPSG”,“6326”]],
PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”,“8901”]],
UNIT[“degree”, 0.017453292519943295],
AXIS[“Geodetic longitude”, EAST],
AXIS[“Geodetic latitude”, NORTH],
AUTHORITY[“EPSG”,“4326”]]
Bbox = SRSEnvelope[???.40126472711921 : ???.39302247762322, 44.78623741864801 : 44.789780437949894]
Env = {GSUSER=admin, MAX=13, MIN=0}
Angle = 0.0
Exceptions = SE_XML
StyleBody = null
SldVersion = null
StyleVersion = null
ScaleMethod = null
Time =
Height = 331
Width = 769
Format = image/jpeg
Buffer = 0
Filter = null
Get = true
Request = GetMap
BaseUrl = http://myserver:80/geoserver/
RawKvp = {FORMAT=image/jpeg, REQUEST=GetMap, SRS=EPSG:4326, BBOX=???.40126472711921,44.78623741864801,???.39302247762322,44.789780437949894, VERSION=1.1.1, STYLES=test, WIDTH=769, SERVICE=WMS, HEIGHT=331, ENV=min:0;max:13, TRANSPARENT=true, LAYERS=client-farms:fname-client_florida-10-west-qtr_18-ac-field_2013_grid-sampling_organic-matter}
RequestCharset = UTF-8
Version = 1.1.1
2016-06-30 11:40:14,029 DEBUG [org.geoserver.config.impl] - Could not locate service of type interface org.geoserver.wms.WMSInfo in workspace WorkspaceInfoImpl[client-farms], available services were [WCSInfoImpl[WCS], WFSInfoImpl[WFS], WMSInfoImpl[WMS]]
2016-06-30 11:40:14,060 DEBUG [org.geoserver.filters] - Not compressing output for mimetype: image/jpeg
2016-06-30 11:40:14,060 DEBUG [org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1] - SecurityContextHolder now cleared, as request processing completed
2016-06-30 11:40:17,196 DEBUG [org.geoserver.security.IncludeQueryStringAntPathRequestMatcher] - Checking match of request : ‘Path: /web/wicket/bookmarkable/org.geoserver.web.admin.logpage, QueryString: 73&lines=1000’; against '/web/
2016-06-30 11:40:17,196 DEBUG [org.geoserver.security.IncludeQueryStringAntPathRequestMatcher] - Matched Path: /web/wicket/bookmarkable/org.geoserver.web.admin.logpage, QueryString: 73&lines=1000 with /web/

2016-06-30 11:40:17,196 TRACE [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/web/wicket/bookmarkable/org.geoserver.web.admin.LogPage]
2016-06-30 11:40:17,196 TRACE [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/web/wicket/bookmarkable/org.geoserver.web.admin.LogPage]
2016-06-30 11:40:17,196 TRACE [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/web/wicket/bookmarkable/org.geoserver.web.admin.LogPage]
2016-06-30 11:40:17,196 TRACE [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/web/wicket/bookmarkable/org.geoserver.web.admin.LogPage]
2016-06-30 11:40:17,227 DEBUG [org.geoserver] - Thread 20 locking in mode WRITE
2016-06-30 11:40:17,227 DEBUG [org.geoserver] - Thread 20 got the lock in mode WRITE

Info that might be relevant:

GeoServer Version
2.9-beta2
Git Revision
e0aa7e3509b12a6838cdb8187ef327c149302beb
Build Date
21-Apr-2016 04:41
GeoTools Version
15-beta2 (rev be8fc7adf7d3f016fc298dce9daeafbe50899381)
GeoWebCache Version
1.9-beta2 (rev master/806006ed652e11d6f3d4ea694d15a16a989a4852)

This is running on Windows Server 2012 (64 bit), but running 32 bit GeoServer and 32 bit java.


Michael Moore


Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313

fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.