Dear List,
We are using Geoserver REST API to upload and attach yaml style files to
layers. A sample yaml file looks like this:
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:
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
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:
curl -u $credentials -XGET http://
host:8081/geoserver/rest/workspaces/$workspace_name/styles/$style_name.sld?pretty=true
<?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="java.awt.Color[r=226,g=3,b=116]" 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
It seems that something goes wrong during conversion. Does anyone know the
cause of this problem?
Regards,
Moses
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users