We're updating the issue view to help you get more done. 

YSLD ColorMap incorrectly recording a String (as shown in SLD conversion)

Description

We are using Geoserver REST API to upload and attach yaml style files to layers. A sample yaml file looks like this:

1 2 3 4 5 6 7 8 9 10 11 12 13 name: Test title: Test Style title abstract: Styling of Test layer feature-styles: - rules: - title: raster symbolizers: - raster: opacity: 1.0 color-map: type: values entries: - ['#e20374', 1.0, 1, Lorem Ipsum (magenta = covered)]

We use the following curl commands to upload the style:

1 2 Creating Style curl -u "$credentials" -XPOST -H "Content-type: text/xml" -d "<style><name>$style_name</name><format>ysld</format><filename>$style_name.yaml</filename><languageVersion><version>1.0.0</version></languageVersion></style>" http://host:8081/geoserver/rest/workspaces/$workspace_name/styles

Update the style with uploaded style info

1 curl -u $credentials -XPUT -H "Content-type: application/vnd.geoserver.ysld+yaml" --data-binary @$style_name.yaml http:// host:8081/geoserver/rest/workspaces/$workspace_name/styles/$style_name

Check result:

1 curl -u $credentials -XGET http:// host:8081/geoserver/rest/workspaces/$workspace_name/styles/$style_name.sld?pretty=true
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <?xml version="1.0" encoding="UTF-8"?> <sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0"> <sld:NamedLayer> <sld:Name>test</sld:Name> <sld:UserStyle> <sld:Name>Test</sld:Name> <sld:Title>Test Style</sld:Title> <sld:Abstract>Styling abstract desc.</sld:Abstract> <sld:FeatureTypeStyle> <sld:Rule> <sld:Title>raster</sld:Title> <sld:RasterSymbolizer> <sld:ColorMap type="values"> <sld:ColorMapEntry color="*{color:red}java.awt.Color[r=226,g=3,b=116]{color}*" opacity="1.0" quantity="1" label="lorem ipsum (magenta = covered)"/> </sld:ColorMapEntry> <sld:ContrastEnhancement/> </sld:RasterSymbolizer> </sld:Rule> </sld:FeatureTypeStyle> </sld:UserStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor>

As can be seen, #e20374 is converted to java.awt.Color instead of the same '#e20374' literal. When I manually edit the yaml file in geoserver (i.e replace java.awt.Color[r=226,g=3,b=116] with #e20374) , I get the correct styling.

However, if I use the the java color ( java.awt.Color[r=226,g=3,b=116]), I get the following error:

Null; Invalid color, must be one of '#RRGGBB', rgb(r,g,b), or expression: in 'reader' line 14, column 14:- java.awt.Color[r=226,g=3,b=116] ...

It seems that something goes wrong during conversion.

Environment

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 8
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 45
Stepping: 7
CPU MHz: 2493.788
BogoMIPS: 4987.57
Hypervisor vendor: Xen
Virtualization type: para
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 15360K
NUMA node0 CPU(s): 0-7

Red Hat Enterprise Linux Server release 6.5 (Santiago)
Red Hat Enterprise Linux Server release 6.5 (Santiago)
cpe:/o:redhat:enterprise_linux:6server:ga:server

GeoTools Version:16.0
Java version:1.8

Status

Assignee

Kevin Smith [Administrator]

Reporter

M. Gone

Triage

None

Fix versions

Affects versions

2.10.0

Components

Priority

High