[Geoserver-devel] getLegendGraphic as text

Hi,
I’d like to know if someone discussed about the way to get the legend in a textual format (json or xml).
Does it make sense to return the lists of rules (filtered) as XML or json if someone requests the getLegendGraphic in that format (application/xml, application/json)?

@devs:
is there a “standard” way to transport the rules and relatives symbolizers in json?

Note:

I’ve noticed that the getLegendGraphic does not implements all the output format supported by the getMap as specified here:
http://docs.geoserver.org/latest/en/user/services/wms/get_legend_graphic/legendgraphic.html#get-legend-graphic
Anyway this is not important to me right now.

Carlo

On Wed, Oct 3, 2012 at 5:52 PM, Carlo Cancellieri <ccancellieri@anonymised.com…> wrote:

Hi,
I’d like to know if someone discussed about the way to get the legend in a textual format (json or xml).
Does it make sense to return the lists of rules (filtered) as XML or json if someone requests the getLegendGraphic in that format (application/xml, application/json)?

I guess so? What’s the use case, trying to generate the legend client side?
Doing so is not easy as you may end up with different symbolizers for the same feature, different feature type
styles and figuring out how they can be combined is sort of work of magic unless you are also doing a full
evaluation against of the features and see what combinations are used in reality

@devs:
is there a “standard” way to transport the rules and relatives symbolizers in json?

Not aware of one

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

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


Hi,

On Wed, Oct 3, 2012 at 5:52 PM, Carlo Cancellieri <ccancellieri@anonymised.com> wrote:

Hi,

I’d like to know if someone discussed about the way to get the legend in a textual format (json or xml).

Does it make sense to return the lists of rules (filtered) as XML or json if someone requests the getLegendGraphic in that format (application/xml, application/json)?

I guess so? What’s the use case, trying to generate the legend client side?

Yes, that’s what I really need.

Doing so is not easy as you may end up with different symbolizers for the same feature, different feature type

styles and figuring out how they can be combined is sort of work of magic unless you are also doing a full

evaluation against of the features and see what combinations are used in reality

My intention is to reproduce the current implementation of the getLegendGraphic serializing the obtained final set of rules (used to renderize the legend) to a text representation (xml and json).I still have to investigate on possible problems and the amount of time to code needed, so I’m just looking around right now.

@devs:

is there a “standard” way to transport the rules and relatives symbolizers in json?

Not aware of one

Cheers

Andrea

thank you,
Carlo

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

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


Hi all,
so this seams to be not interesting for you (nobody)?

In that case I'll create an extension for my purposes which simply returns a json representation of the rules (in my case for all the interesting layers, all the rules are applied to all the features and each feature matches only one rule).

If you are interested in this extension, please replay to this mail, so I'll start producing a better and more general purpose implementation of this response handler following Andrea's suggestions (evaluate all the features to create the stack of filter rules to actually use).

Here is an example of the generated json (it is simply a json representation of the style right now):

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetLegendGraphic&layer=sf:sfdem&styles=&bbox=589980.0,4913700.0,609000.0,4928010.0&width=512&height=385&srs=EPSG:26713&format=image/png

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetLegendGraphic&layer=sf:sfdem&styles=&bbox=589980.0,4913700.0,609000.0,4928010.0&width=512&height=385&srs=EPSG:26713&format=application/json&outputFormat=application/json

{
getLegendGraphic: [
{
description: null,
title: null,
name: null,
symbolyzers: [
{
name: null,
description: null,
title: null,
type: "RasterSymbolizer",
colormap: {
entries: [
{
label: "nodata",
opacity: "0.0",
quantity: "-500",
color: "#000000"
},
{
label: "values",
opacity: null,
quantity: "0",
color: "#AAFFAA"
},
{
label: null,
opacity: null,
quantity: "1000",
color: "#00FF00"
},
{
label: "values",
opacity: null,
quantity: "1200",
color: "#FFFF00"
},
{
label: "values",
opacity: null,
quantity: "1400",
color: "#FF7F00"
},
{
label: "values",
opacity: null,
quantity: "1600",
color: "#BF7F3F"
},
{
label: "values",
opacity: null,
quantity: "2000",
color: "#000000"
}
]
},
geometry: "geom",
geometryPropertyName: "geom"
}
]
}
]
}

This is the style:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
xmlns:xlink="http://www.w3.org/1999/xlink&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd&quot;&gt;
<NamedLayer>
<Name>gtopo</Name>
<UserStyle>
<Name>dem</Name>
<Title>Simple DEM style</Title>
<Abstract>Classic elevation color progression</Abstract>
<FeatureTypeStyle>
<Rule>
<RasterSymbolizer>
<Opacity>1.0</Opacity>
<ColorMap>
<ColorMapEntry color="#000000" quantity="-500" label="nodata" opacity="0.0" />
<ColorMapEntry color="#AAFFAA" quantity="0" label="values" />
<ColorMapEntry color="#00FF00" quantity="1000"/>
<ColorMapEntry color="#FFFF00" quantity="1200" label="values" />
<ColorMapEntry color="#FF7F00" quantity="1400" label="values" />
<ColorMapEntry color="#BF7F3F" quantity="1600" label="values" />
<ColorMapEntry color="#000000" quantity="2000" label="values" />
</ColorMap>
</RasterSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

Another example:
{
getLegendGraphic: [
{
description: null,
title: "0 400k",
name: null,
filter: "[ PERSONS BETWEEN 0 AND 400000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "0 400k",
type: "PolygonSymbolizer",
color: "#444444",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "400k - 2M",
name: null,
filter: "[ PERSONS BETWEEN 400000 AND 2000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "400k - 2M",
type: "PolygonSymbolizer",
color: "#DDDDDD",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "2M - 4M",
name: null,
filter: "[ PERSONS BETWEEN 2000000 AND 4000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "2M - 4M",
type: "PolygonSymbolizer",
color: "#FF4D4D",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "> 4M - 5M",
name: null,
filter: "[ PERSONS BETWEEN 4000000 AND 5000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "> 4M - 5M",
type: "PolygonSymbolizer",
color: "#4D4DFF",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "Boundary",
name: null,
symbolyzers: [
{
name: null,
description: null,
title: "Boundary",
type: "LineSymbolizer",
perpendicularOffset: null,
strokeColor: "#000000",
dashArray: "null",
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: "Boundary",
type: "TextSymbolizer",
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "> 9M",
name: null,
filter: "[ PERSONS > 9000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "> 9M",
type: "PolygonSymbolizer",
color: "#AAAAAA",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "Boundary",
name: null,
symbolyzers: [
{
name: null,
description: null,
title: "Boundary",
type: "LineSymbolizer",
perpendicularOffset: null,
strokeColor: "#000000",
dashArray: "null",
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: "Boundary",
type: "TextSymbolizer",
geometry: null,
geometryPropertyName: null
}
]
}
]
}

From: ccancellieri@anonymised.com
To: andrea.aime@anonymised.com
Date: Thu, 4 Oct 2012 08:54:53 +0000
CC: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] getLegendGraphic as text

Hi,
On Wed, Oct 3, 2012 at 5:52 PM, Carlo Cancellieri <ccancellieri@anonymised.com> wrote:
Hi,
I'd like to know if someone discussed about the way to get the legend in a textual format (json or xml).
Does it make sense to return the lists of rules (filtered) as XML or json if someone requests the getLegendGraphic in that format (application/xml, application/json)?

I guess so? What's the use case, trying to generate the legend client side?

Yes, that's what I really need.

Doing so is not easy as you may end up with different symbolizers for the same feature, different feature type
styles and figuring out how they can be combined is sort of work of magic unless you are also doing a full
evaluation against of the features and see what combinations are used in reality

My intention is to reproduce the current implementation of the getLegendGraphic serializing the obtained final set of rules (used to renderize the legend) to a text representation (xml and json).
I still have to investigate on possible problems and the amount of time to code needed, so I'm just looking around right now.

@devs:
is there a "standard" way to transport the rules and relatives symbolizers in json?

Not aware of one

Cheers
Andrea

thank you,
Carlo

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

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

-------------------------------------------------------

------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________ Geoserver-devel mailing list Geoserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-devel

definitely interested, and i find its highly beneficial. a while back i
started some internal discussions with a developer about dong exactly
this, but we simply have not had the time. there are tremendous benefits
to this approach as it allows for building the legends on the client
side. this allows for much better control and options for legend layout,
such as responsive design, better printable legends, and interactive
legends.

how are you looking to handle the use of graphics or shapes? such as
squares, triangles, circles, stars, open arrows, etc.

-andrés
[845.365.8986]

On 10/09/2012 12:14 PM, Carlo Cancellieri wrote:

Hi all,
so this seams to be not interesting for you (nobody)?

In that case I'll create an extension for my purposes which simply returns a json representation of the rules (in my case for all the interesting layers, all the rules are applied to all the features and each feature matches only one rule).

If you are interested in this extension, please replay to this mail, so I'll start producing a better and more general purpose implementation of this response handler following Andrea's suggestions (evaluate all the features to create the stack of filter rules to actually use).

Here is an example of the generated json (it is simply a json representation of the style right now):

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetLegendGraphic&layer=sf:sfdem&styles=&bbox=589980.0,4913700.0,609000.0,4928010.0&width=512&height=385&srs=EPSG:26713&format=image/png

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetLegendGraphic&layer=sf:sfdem&styles=&bbox=589980.0,4913700.0,609000.0,4928010.0&width=512&height=385&srs=EPSG:26713&format=application/json&outputFormat=application/json

{
getLegendGraphic: [
{
description: null,
title: null,
name: null,
symbolyzers: [
{
name: null,
description: null,
title: null,
type: "RasterSymbolizer",
colormap: {
entries: [
{
label: "nodata",
opacity: "0.0",
quantity: "-500",
color: "#000000"
},
{
label: "values",
opacity: null,
quantity: "0",
color: "#AAFFAA"
},
{
label: null,
opacity: null,
quantity: "1000",
color: "#00FF00"
},
{
label: "values",
opacity: null,
quantity: "1200",
color: "#FFFF00"
},
{
label: "values",
opacity: null,
quantity: "1400",
color: "#FF7F00"
},
{
label: "values",
opacity: null,
quantity: "1600",
color: "#BF7F3F"
},
{
label: "values",
opacity: null,
quantity: "2000",
color: "#000000"
}
]
},
geometry: "geom",
geometryPropertyName: "geom"
}
]
}
]
}

This is the style:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
  xmlns:xlink="http://www.w3.org/1999/xlink&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd&quot;&gt;
  <NamedLayer>
    <Name>gtopo</Name>
    <UserStyle>
      <Name>dem</Name>
      <Title>Simple DEM style</Title>
      <Abstract>Classic elevation color progression</Abstract>
      <FeatureTypeStyle>
        <Rule>
          <RasterSymbolizer>
            <Opacity>1.0</Opacity>
            <ColorMap>
              <ColorMapEntry color="#000000" quantity="-500" label="nodata" opacity="0.0" />
              <ColorMapEntry color="#AAFFAA" quantity="0" label="values" />
              <ColorMapEntry color="#00FF00" quantity="1000"/>
              <ColorMapEntry color="#FFFF00" quantity="1200" label="values" />
              <ColorMapEntry color="#FF7F00" quantity="1400" label="values" />
              <ColorMapEntry color="#BF7F3F" quantity="1600" label="values" />
              <ColorMapEntry color="#000000" quantity="2000" label="values" />
            </ColorMap>
          </RasterSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Another example:
{
getLegendGraphic: [
{
description: null,
title: "0 400k",
name: null,
filter: "[ PERSONS BETWEEN 0 AND 400000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "0 400k",
type: "PolygonSymbolizer",
color: "#444444",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "400k - 2M",
name: null,
filter: "[ PERSONS BETWEEN 400000 AND 2000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "400k - 2M",
type: "PolygonSymbolizer",
color: "#DDDDDD",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "2M - 4M",
name: null,
filter: "[ PERSONS BETWEEN 2000000 AND 4000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "2M - 4M",
type: "PolygonSymbolizer",
color: "#FF4D4D",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "> 4M - 5M",
name: null,
filter: "[ PERSONS BETWEEN 4000000 AND 5000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "> 4M - 5M",
type: "PolygonSymbolizer",
color: "#4D4DFF",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "Boundary",
name: null,
symbolyzers: [
{
name: null,
description: null,
title: "Boundary",
type: "LineSymbolizer",
perpendicularOffset: null,
strokeColor: "#000000",
dashArray: "null",
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: "Boundary",
type: "TextSymbolizer",
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "> 9M",
name: null,
filter: "[ PERSONS > 9000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "> 9M",
type: "PolygonSymbolizer",
color: "#AAAAAA",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "Boundary",
name: null,
symbolyzers: [
{
name: null,
description: null,
title: "Boundary",
type: "LineSymbolizer",
perpendicularOffset: null,
strokeColor: "#000000",
dashArray: "null",
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: "Boundary",
type: "TextSymbolizer",
geometry: null,
geometryPropertyName: null
}
]
}
]
}

From: ccancellieri@anonymised.com
To: andrea.aime@anonymised.com
Date: Thu, 4 Oct 2012 08:54:53 +0000
CC: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] getLegendGraphic as text

Hi,
On Wed, Oct 3, 2012 at 5:52 PM, Carlo Cancellieri <ccancellieri@anonymised.com> wrote:
Hi,
I'd like to know if someone discussed about the way to get the legend in a textual format (json or xml).
Does it make sense to return the lists of rules (filtered) as XML or json if someone requests the getLegendGraphic in that format (application/xml, application/json)?

I guess so? What's the use case, trying to generate the legend client side?

Yes, that's what I really need.

Doing so is not easy as you may end up with different symbolizers for the same feature, different feature type
styles and figuring out how they can be combined is sort of work of magic unless you are also doing a full
evaluation against of the features and see what combinations are used in reality

My intention is to reproduce the current implementation of the getLegendGraphic serializing the obtained final set of rules (used to renderize the legend) to a text representation (xml and json).
I still have to investigate on possible problems and the amount of time to code needed, so I'm just looking around right now.

@devs:
  is there a "standard" way to transport the rules and relatives symbolizers in json?

Not aware of one

Cheers
Andrea

thank you,
Carlo

Hi Andreas,
I'm currently working on a textual representation of the getLegendGraphic (are you interested?) and I'd like to produce it in an OpenLayer 'like' format.
The format will be essentially an object called getLegendGraphic containing an array of rules (see previous mails for details).
Now, looking at the serialized version (by OpenLayers) of the style I see that each rule can have more than one symbolyzer but you don't handle that structure as an array, why?

This is my version
{
description: null,
title: "Boundary",
name: null,
symbolyzers: [
{
name: null,
description: null,
title: "Boundary",
Line: {
strokeColor: "#000000",
strokeDashArray: "null",
strokeDashOffset: 0
},
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: "Boundary",
Text: {
fontFamily: "Times New Roman",
fontBold: "Normal",
fontWeight: "normal",
fontSize: 16
},
geometry: null,
geometryPropertyName: null
}
]
}

This is your:
{
"symbolizer" : {
"Polygon" : {
"fill" : true,
"stroke" : true,
"fillColor" : "#ffffff",
"strokeColor" : "#000000",
"strokeWidth" : "1"
},
"Text" : {
"label" : "${FOO}",

               \.\.\. 
                                         &quot;fontColor&quot; : &quot;\#000000&quot;
                 \}
                             \},
                  &quot;id&quot; : &quot;OpenLayers\.Rule\_79&quot;,
                  &quot;name&quot; : &quot;stortsteen&quot;,
                  &quot;filter&quot; : \{
                           &quot;type&quot; : &quot;==&quot;,
                          &quot;property&quot; : &quot;CTE&quot;,
                           &quot;value&quot; : &quot;V0305&quot;
                  \},
         &quot;maxScaleDenominator&quot; : 50000
   \}

Regards,
Carlo

----------------------------------------

From: Francesca.Vigetti@anonymised.com
To: ccancellieri@anonymised.com
Date: Wed, 10 Oct 2012 12:08:24 +0200
Subject: RE: [Geoserver-devel] getLegendGraphic as text

Ecco due esempi, uno é l'sld che mi hai mandato tu e l'altro é una colormap
Dopo te ne mando altri

POLYGON - LINE SYMBOLIZER

var sld =
'<StyledLayerDescriptor version="1.0.0" ' +
'xmlns="http://www.opengis.net/sld&quot; ' +
'xmlns:gml="http://www.opengis.net/gml&quot; ' +
'xmlns:ogc="http://www.opengis.net/ogc&quot; ' +
'xmlns:xlink="http://www.w3.org/1999/xlink&quot; ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; ' +
'xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd&quot;&gt;&#39; +
'<NamedLayer>' +
'<Name>AAA161</Name>' +
'<UserStyle>' +
'<FeatureTypeStyle>' +
'<Rule>' +
'<Name>stortsteen</Name>' +
'<ogc:Filter>' +
'<ogc:PropertyIsEqualTo>' +
'<ogc:PropertyName>CTE</ogc:PropertyName>' +
'<ogc:Literal>V0305</ogc:Literal>' +
'</ogc:PropertyIsEqualTo>' +
'</ogc:Filter>' +
'<MaxScaleDenominator>50000</MaxScaleDenominator>' +
'<PolygonSymbolizer>' +
'<Fill>' +
'<CssParameter name="fill">#ffffff</CssParameter>' +
'</Fill>' +
'<Stroke>' +
'<CssParameter name="stroke">#000000</CssParameter>' +
'<CssParameter name="stroke-width">1</CssParameter>' +
'</Stroke>' +
'</PolygonSymbolizer>' +
'<TextSymbolizer>' +
'<Label>' +
'<ogc:PropertyName>FOO</ogc:PropertyName>' +
'</Label>' +
'' +
'<CssParameter name="font-family">Arial</CssParameter>' +
'<CssParameter name="font-size">14</CssParameter>' +
'<CssParameter name="font-weight">bold</CssParameter>' +
'<CssParameter name="font-style">normal</CssParameter>' +
'' +
'<Halo>' +
'<Radius>3</Radius>' +
'<Fill>' +
'<CssParameter name="fill">#ffffff</CssParameter>' +
'</Fill>' +
'</Halo>' +
'<Fill>' +
'<CssParameter name="fill">#000000</CssParameter>' +
'</Fill>' +
'</TextSymbolizer>' +
'</Rule>' +
'<Rule>' +
'<Name>betonbekleding</Name>' +
'<ogc:Filter>' +
'<ogc:PropertyIsLessThan>' +
'<ogc:PropertyName>CTE</ogc:PropertyName>' +
'<ogc:Literal>1000</ogc:Literal>' +
'</ogc:PropertyIsLessThan>' +
'</ogc:Filter>' +
'<MaxScaleDenominator>50000</MaxScaleDenominator>' +
'<PolygonSymbolizer>' +
'<Fill>' +
'<CssParameter name="fill">#ffff00</CssParameter>' +
'</Fill>' +
'<Stroke>' +
'<CssParameter name="stroke">#0000ff</CssParameter>' +
'<CssParameter name="stroke-width">1</CssParameter>' +
'</Stroke>' +
'</PolygonSymbolizer>' +
'</Rule>' +
'</FeatureTypeStyle>' +
'</UserStyle>' +
'</NamedLayer>' +
'<NamedLayer>' +
'<Name>Second Layer</Name>' +
'<UserStyle>' +
'<FeatureTypeStyle>' +
'<Rule>' +
'<Name>first rule second layer</Name>' +
'<ogc:Filter>' +
'<ogc:Or>' +
'<ogc:PropertyIsBetween>' +
'<ogc:PropertyName>number</ogc:PropertyName>' +
'<ogc:LowerBoundary>' +
'<ogc:Literal>1064866676</ogc:Literal>' +
'</ogc:LowerBoundary>' +
'<ogc:UpperBoundary>' +
'<ogc:Literal>1065512599</ogc:Literal>' +
'</ogc:UpperBoundary>' +
'</ogc:PropertyIsBetween>' +
'<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">' +
'<ogc:PropertyName>cat</ogc:PropertyName>' +
'<ogc:Literal>*dog.food!*good</ogc:Literal>' +
'</ogc:PropertyIsLike>' +
'<ogc:Not>' +
'<ogc:PropertyIsLessThanOrEqualTo>' +
'<ogc:PropertyName>FOO</ogc:PropertyName>' +
'<ogc:Literal>5000</ogc:Literal>' +
'</ogc:PropertyIsLessThanOrEqualTo>' +
'</ogc:Not>' +
'</ogc:Or>' +
'</ogc:Filter>' +
'<MaxScaleDenominator>10000</MaxScaleDenominator>' +
'<PointSymbolizer>' +
'<Graphic>' +
'<Mark>' +
'<WellKnownName>star</WellKnownName>' +
'<Fill>' +
'<CssParameter name="fill">lime</CssParameter>' +
'</Fill>' +
'<Stroke>' +
'<CssParameter name="stroke">olive</CssParameter>' +
'<CssParameter name="stroke-width">2</CssParameter>' +
'</Stroke>' +
'</Mark>' +
'</Graphic>' +
'</PointSymbolizer>' +
'</Rule>' +
'</FeatureTypeStyle>' +
'</UserStyle>' +
'</NamedLayer>' +
'</StyledLayerDescriptor>';

var json = {
"namedLayers" : {
"AAA161" : {
"userStyles" : [ {
"defaultsPerSymbolizer" : true,
"rules" : [ {
"symbolizer" : {
"Polygon" : {
"fill" : true,
"stroke" : true,
"fillColor" : "#ffffff",
"strokeColor" : "#000000",
"strokeWidth" : "1"
},
"Text" : {
"label" : "${FOO}",
"fontFamily" : "Arial",
"fontSize" : "14",
"fontWeight" : "bold",
"fontStyle" : "normal",
"haloRadius" : "3",
"haloColor" : "#ffffff",
"fill" : true,
"fontColor" : "#000000"
}
},
"id" : "OpenLayers.Rule_79",
"name" : "stortsteen",
"filter" : {
"type" : "==",
"property" : "CTE",
"value" : "V0305"
},
"maxScaleDenominator" : 50000
}, {
"symbolizer" : {
"Polygon" : {
"fill" : true,
"stroke" : true,
"fillColor" : "#ffff00",
"strokeColor" : "#0000ff",
"strokeWidth" : "1"
}
},
"id" : "OpenLayers.Rule_80",
"name" : "betonbekleding",
"filter" : {
"type" : "<",
"property" : "CTE",
"value" : 1000
},
"maxScaleDenominator" : 50000
} ],
"propertyStyles" : {
"label" : true
},
"defaultStyle" : {
"fillColor" : "#808080",
"fillOpacity" : 1,
"strokeColor" : "#000000",
"strokeOpacity" : 1,
"strokeWidth" : 1,
"strokeDashstyle" : "solid",
"pointRadius" : 3,
"graphicName" : "square"
},
"id" : "OpenLayers.Style_81",
"layerName" : "AAA161"
} ],
"namedStyles" : ,
"name" : "AAA161"
},
"Second Layer" : {
"userStyles" : [ {
"defaultsPerSymbolizer" : true,
"rules" : [ {
"symbolizer" : {
"Point" : {
"fill" : true,
"stroke" : true,
"graphic" : true,
"strokeColor" : "olive",
"strokeWidth" : "2",
"fillColor" : "lime",
"graphicName" : "star"
}
},
"id" : "OpenLayers.Rule_82",
"name" : "first rule second layer",
"filter" : {
"filters" : [ {
"type" : "..",
"property" : "number",
"lowerBoundary" : 1064866676,
"upperBoundary" : 1065512599
}, {
"type" : "~",
"matchCase" : null,
"property" : "cat",
"value" : ".*dog.food\\*good"
}, {
"filters" : [ {
"type" : "<=",
"property" : "FOO",
"value" : 5000
} ],
"type" : "!"
} ],
"type" : "||"
},
"maxScaleDenominator" : 10000
} ],
"propertyStyles" : {},
"defaultStyle" : {
"fillColor" : "#808080",
"fillOpacity" : 1,
"strokeColor" : "#000000",
"strokeOpacity" : 1,
"strokeWidth" : 1,
"strokeDashstyle" : "solid",
"pointRadius" : 3,
"graphicName" : "square"
},
"id" : "OpenLayers.Style_83",
"layerName" : "Second Layer"
} ],
"namedStyles" : ,
"name" : "Second Layer"
}
},
"version" : "1.0.0"
};

COLORMAP

var sld =
'<?xml version="1.0" encoding="ISO-8859-1"?>'+
'<StyledLayerDescriptor version="1.0.0" '+
'xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" '+
'xmlns="http://www.opengis.net/sld&quot; '+
'xmlns:ogc="http://www.opengis.net/ogc&quot; '+
'xmlns:xlink="http://www.w3.org/1999/xlink&quot; '+
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;&#39;\+
'<!-- a named layer is the basic building block of an sld document -->'+

'<NamedLayer>'+
'<Name>COUNTRYPROFILES:srtm30</Name>'+
'<UserStyle>'+
'<!-- they have names, titles and abstracts -->'+

'<Title>A boring default style</Title>'+
'<Abstract>A sample style that just prints out a green line</Abstract>'+
'<!-- FeatureTypeStyles describe how to render different features -->'+
'<!-- a feature type for lines -->'+

'<FeatureTypeStyle>'+
'<!--FeatureTypeName>Feature</FeatureTypeName-->'+
'<Rule>'+
'<RasterSymbolizer>'+
'<ColorMap>'+
'<ColorMapEntry color="#FFFFFF" quantity="-1" label="No data" opacity="0"/>'+
'<ColorMapEntry color="#CEC3FF" quantity="0" label="Below Sea Level" opacity="1"/>'+
'<ColorMapEntry color="#008100" quantity="100" label="0-100" opacity="1"/>'+
'<ColorMapEntry color="#299E11" quantity="200" label="100-200" opacity="1"/>'+
'<ColorMapEntry color="#59BE30" quantity="300" label="200-300" opacity="1"/>'+
'<ColorMapEntry color="#8CDB5B" quantity="400" label="300-400" opacity="1"/>'+
'<ColorMapEntry color="#C6F78C" quantity="500" label="400-500" opacity="1"/>'+
'<ColorMapEntry color="#C6EB7A" quantity="750" label="500-750" opacity="1"/>'+
'<ColorMapEntry color="#CEDF6C" quantity="1000" label="750-1000" opacity="1"/>'+
'<ColorMapEntry color="#CFD364" quantity="1500" label="1000-1500" opacity="1"/>'+
'<ColorMapEntry color="#C6BB52" quantity="2000" label="1500-2000" opacity="1"/>'+
'<ColorMapEntry color="#BD9E4B" quantity="3000" label="2000-3000" opacity="1"/>'+
'<ColorMapEntry color="#AD8339" quantity="4000" label="3000-4000" opacity="1"/>'+
'<ColorMapEntry color="#A46530" quantity="5000" label="4000-5000" opacity="1"/>'+
'<ColorMapEntry color="#FFFFFF" quantity="8685" label=">5000" opacity="1"/> '+
'</ColorMap>'+
'</RasterSymbolizer>'+
'</Rule>'+

'</FeatureTypeStyle>'+
'</UserStyle>'+
'</NamedLayer>'+
'</StyledLayerDescriptor>';

var a = {
"namedLayers" : {
"COUNTRYPROFILES:srtm30" : {
"userStyles" : [ {
"defaultsPerSymbolizer" : true,
"rules" : [ {
"symbolizer" : {
"Raster" : {
"colorMap" : [ {
"color" : "#FFFFFF",
"quantity" : -1,
"label" : "No data",
"opacity" : 0
}, {
"color" : "#CEC3FF",
"quantity" : 0,
"label" : "Below Sea Level",
"opacity" : 1
}, {
"color" : "#008100",
"quantity" : 100,
"label" : "0-100",
"opacity" : 1
}, {
"color" : "#299E11",
"quantity" : 200,
"label" : "100-200",
"opacity" : 1
}, {
"color" : "#59BE30",
"quantity" : 300,
"label" : "200-300",
"opacity" : 1
}, {
"color" : "#8CDB5B",
"quantity" : 400,
"label" : "300-400",
"opacity" : 1
}, {
"color" : "#C6F78C",
"quantity" : 500,
"label" : "400-500",
"opacity" : 1
}, {
"color" : "#C6EB7A",
"quantity" : 750,
"label" : "500-750",
"opacity" : 1
}, {
"color" : "#CEDF6C",
"quantity" : 1000,
"label" : "750-1000",
"opacity" : 1
}, {
"color" : "#CFD364",
"quantity" : 1500,
"label" : "1000-1500",
"opacity" : 1
}, {
"color" : "#C6BB52",
"quantity" : 2000,
"label" : "1500-2000",
"opacity" : 1
}, {
"color" : "#BD9E4B",
"quantity" : 3000,
"label" : "2000-3000",
"opacity" : 1
}, {
"color" : "#AD8339",
"quantity" : 4000,
"label" : "3000-4000",
"opacity" : 1
}, {
"color" : "#A46530",
"quantity" : 5000,
"label" : "4000-5000",
"opacity" : 1
}, {
"color" : "#FFFFFF",
"quantity" : 8685,
"label" : ">5000",
"opacity" : 1
} ]
}
},
"id" : "OpenLayers.Rule_79"
} ],
"title" : "A boring default style",
"description" : "A sample style that just prints out a green line",
"propertyStyles" : {},
"defaultStyle" : {
"fillColor" : "#808080",
"fillOpacity" : 1,
"strokeColor" : "#000000",
"strokeOpacity" : 1,
"strokeWidth" : 1,
"strokeDashstyle" : "solid",
"pointRadius" : 3,
"graphicName" : "square"
},
"id" : "OpenLayers.Style_80",
"layerName" : "COUNTRYPROFILES:srtm30"
} ],
"namedStyles" : ,
"name" : "COUNTRYPROFILES:srtm30"
}
},
"version" : "1.0.0"
};

-----Original Message-----
From: Carlo Cancellieri [mailto:ccancellieri@anonymised.com]
Sent: 10 October 2012 9:35 AM
To: Vigetti, Francesca (CIOK)
Subject: FW: [Geoserver-devel] getLegendGraphic as text

FYI,
mi contatti appena puoi pls?
Ciao,
Carlo

----------------------------------------

From: ccancellieri@anonymised.com
To: andrea.aime@anonymised.com
Date: Tue, 9 Oct 2012 16:14:55 +0000
CC: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] getLegendGraphic as text

Hi all,
so this seams to be not interesting for you (nobody)?

In that case I'll create an extension for my purposes which simply returns a json representation of the rules (in my case for all the interesting layers, all the rules are applied to all the features and each feature matches only one rule).

If you are interested in this extension, please replay to this mail, so I'll start producing a better and more general purpose implementation of this response handler following Andrea's suggestions (evaluate all the features to create the stack of filter rules to actually use).

Here is an example of the generated json (it is simply a json representation of the style right now):

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&reque
st=GetLegendGraphic&layer=sf:sfdem&styles=&bbox=589980.0,4913700.0,609
000.0,4928010.0&width=512&height=385&srs=EPSG:26713&format=image/png

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&reque
st=GetLegendGraphic&layer=sf:sfdem&styles=&bbox=589980.0,4913700.0,609
000.0,4928010.0&width=512&height=385&srs=EPSG:26713&format=application
/json&outputFormat=application/json

{
getLegendGraphic: [
{
description: null,
title: null,
name: null,
symbolyzers: [
{
name: null,
description: null,
title: null,
type: "RasterSymbolizer",
colormap: {
entries: [
{
label: "nodata",
opacity: "0.0",
quantity: "-500",
color: "#000000"
},
{
label: "values",
opacity: null,
quantity: "0",
color: "#AAFFAA"
},
{
label: null,
opacity: null,
quantity: "1000",
color: "#00FF00"
},
{
label: "values",
opacity: null,
quantity: "1200",
color: "#FFFF00"
},
{
label: "values",
opacity: null,
quantity: "1400",
color: "#FF7F00"
},
{
label: "values",
opacity: null,
quantity: "1600",
color: "#BF7F3F"
},
{
label: "values",
opacity: null,
quantity: "2000",
color: "#000000"
}
]
},
geometry: "geom",
geometryPropertyName: "geom"
}
]
}
]
}

This is the style:

<?xml version="1.0" encoding="ISO-8859-1"?> <StyledLayerDescriptor
version="1.0.0" xmlns="http://www.opengis.net/sld&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
xmlns:xlink="http://www.w3.org/1999/xlink&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="http://www.opengis.net/sld
http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd&quot;&gt;
<NamedLayer>
<Name>gtopo</Name>
<UserStyle>
<Name>dem</Name>
<Title>Simple DEM style</Title>
<Abstract>Classic elevation color progression</Abstract>
<FeatureTypeStyle> <Rule> <RasterSymbolizer> <Opacity>1.0</Opacity>
<ColorMap> <ColorMapEntry color="#000000" quantity="-500"
label="nodata" opacity="0.0" /> <ColorMapEntry color="#AAFFAA"
quantity="0" label="values" /> <ColorMapEntry color="#00FF00"
quantity="1000"/> <ColorMapEntry color="#FFFF00" quantity="1200"
label="values" /> <ColorMapEntry color="#FF7F00" quantity="1400"
label="values" /> <ColorMapEntry color="#BF7F3F" quantity="1600"
label="values" /> <ColorMapEntry color="#000000" quantity="2000"
label="values" /> </ColorMap> </RasterSymbolizer> </Rule>
</FeatureTypeStyle> </UserStyle> </NamedLayer>
</StyledLayerDescriptor>

Another example:
{
getLegendGraphic: [
{
description: null,
title: "0 400k",
name: null,
filter: "[ PERSONS BETWEEN 0 AND 400000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "0 400k",
type: "PolygonSymbolizer",
color: "#444444",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "400k - 2M",
name: null,
filter: "[ PERSONS BETWEEN 400000 AND 2000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "400k - 2M",
type: "PolygonSymbolizer",
color: "#DDDDDD",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "2M - 4M",
name: null,
filter: "[ PERSONS BETWEEN 2000000 AND 4000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "2M - 4M",
type: "PolygonSymbolizer",
color: "#FF4D4D",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "> 4M - 5M",
name: null,
filter: "[ PERSONS BETWEEN 4000000 AND 5000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "> 4M - 5M",
type: "PolygonSymbolizer",
color: "#4D4DFF",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "Boundary",
name: null,
symbolyzers: [
{
name: null,
description: null,
title: "Boundary",
type: "LineSymbolizer",
perpendicularOffset: null,
strokeColor: "#000000",
dashArray: "null",
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: "Boundary",
type: "TextSymbolizer",
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "> 9M",
name: null,
filter: "[ PERSONS> 9000000 ]",
symbolyzers: [
{
name: null,
description: null,
title: "> 9M",
type: "PolygonSymbolizer",
color: "#AAAAAA",
opacity: "0.7",
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: "Boundary",
name: null,
symbolyzers: [
{
name: null,
description: null,
title: "Boundary",
type: "LineSymbolizer",
perpendicularOffset: null,
strokeColor: "#000000",
dashArray: "null",
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: "Boundary",
type: "TextSymbolizer",
geometry: null,
geometryPropertyName: null
}
]
}
]
}

From: ccancellieri@anonymised.com
To: andrea.aime@anonymised.com
Date: Thu, 4 Oct 2012 08:54:53 +0000
CC: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] getLegendGraphic as text

Hi,
On Wed, Oct 3, 2012 at 5:52 PM, Carlo Cancellieri <ccancellieri@anonymised.com> wrote:
Hi,
I'd like to know if someone discussed about the way to get the legend in a textual format (json or xml).
Does it make sense to return the lists of rules (filtered) as XML or json if someone requests the getLegendGraphic in that format (application/xml, application/json)?

I guess so? What's the use case, trying to generate the legend client side?

Yes, that's what I really need.

Doing so is not easy as you may end up with different symbolizers for
the same feature, different feature type styles and figuring out how
they can be combined is sort of work of magic unless you are also
doing a full evaluation against of the features and see what
combinations are used in reality

My intention is to reproduce the current implementation of the getLegendGraphic serializing the obtained final set of rules (used to renderize the legend) to a text representation (xml and json).
I still have to investigate on possible problems and the amount of time to code needed, so I'm just looking around right now.

@devs:
is there a "standard" way to transport the rules and relatives symbolizers in json?

Not aware of one

Cheers
Andrea

thank you,
Carlo

--

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

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

-------------------------------------------------------

----------------------------------------------------------------------
-------- Don't let slow site performance ruin your business. Deploy
New Relic APM Deploy New Relic app performance management and know
exactly what is happening inside your Ruby, Python, PHP, Java, and
.NET app Try New Relic at no cost today and get our sweet Data Nerd
shirt too! http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________ Geoserver-devel
mailing list Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel
----------------------------------------------------------------------
-------- Don't let slow site performance ruin your business. Deploy
New Relic APM Deploy New Relic app performance management and know
exactly what is happening inside your Ruby, Python, PHP, Java, and
.NET app Try New Relic at no cost today and get our sweet Data Nerd
shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

andrés,
I’ll make a proposal as soon for this improvement.
Regards,
Carlo

Date: Tue, 9 Oct 2012 12:35:25 -0400
From: agonzale@anonymised.com
To: ccancellieri@anonymised.com
CC: andrea.aime@anonymised.com; geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] getLegendGraphic as text

definitely interested, and i find its highly beneficial. a while back i
started some internal discussions with a developer about dong exactly
this, but we simply have not had the time. there are tremendous benefits
to this approach as it allows for building the legends on the client
side. this allows for much better control and options for legend layout,
such as responsive design, better printable legends, and interactive
legends.

how are you looking to handle the use of graphics or shapes? such as
squares, triangles, circles, stars, open arrows, etc.

-andrés
[845.365.8986]

On 10/09/2012 12:14 PM, Carlo Cancellieri wrote:

Hi all,
so this seams to be not interesting for you (nobody)?

In that case I’ll create an extension for my purposes which simply returns a json representation of the rules (in my case for all the interesting layers, all the rules are applied to all the features and each feature matches only one rule).

If you are interested in this extension, please replay to this mail, so I’ll start producing a better and more general purpose implementation of this response handler following Andrea’s suggestions (evaluate all the features to create the stack of filter rules to actually use).

Here is an example of the generated json (it is simply a json representation of the style right now):

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetLegendGraphic&layer=sf:sfdem&styles=&bbox=589980.0,4913700.0,609000.0,4928010.0&width=512&height=385&srs=EPSG:26713&format=image/png

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetLegendGraphic&layer=sf:sfdem&styles=&bbox=589980.0,4913700.0,609000.0,4928010.0&width=512&height=385&srs=EPSG:26713&format=application/json&outputFormat=application/json

{
getLegendGraphic: [
{
description: null,
title: null,
name: null,
symbolyzers: [
{
name: null,
description: null,
title: null,
type: “RasterSymbolizer”,
colormap: {
entries: [
{
label: “nodata”,
opacity: “0.0”,
quantity: “-500”,
color: “#000000
},
{
label: “values”,
opacity: null,
quantity: “0”,
color: “#AAFFAA
},
{
label: null,
opacity: null,
quantity: “1000”,
color: “#00FF00
},
{
label: “values”,
opacity: null,
quantity: “1200”,
color: “#FFFF00
},
{
label: “values”,
opacity: null,
quantity: “1400”,
color: “#FF7F00
},
{
label: “values”,
opacity: null,
quantity: “1600”,
color: “#BF7F3F
},
{
label: “values”,
opacity: null,
quantity: “2000”,
color: “#000000
}
]
},
geometry: “geom”,
geometryPropertyName: “geom”
}
]
}
]
}

This is the style:

<?xml version="1.0" encoding="ISO-8859-1"?>



gtopo

dem

Simple DEM style Classic elevation color progression 1.0

Another example:
{
getLegendGraphic: [
{
description: null,
title: “0 400k”,
name: null,
filter: “[ PERSONS BETWEEN 0 AND 400000 ]”,
symbolyzers: [
{
name: null,
description: null,
title: “0 400k”,
type: “PolygonSymbolizer”,
color: “#444444”,
opacity: “0.7”,
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: “400k - 2M”,
name: null,
filter: “[ PERSONS BETWEEN 400000 AND 2000000 ]”,
symbolyzers: [
{
name: null,
description: null,
title: “400k - 2M”,
type: “PolygonSymbolizer”,
color: “#DDDDDD”,
opacity: “0.7”,
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: “2M - 4M”,
name: null,
filter: “[ PERSONS BETWEEN 2000000 AND 4000000 ]”,
symbolyzers: [
{
name: null,
description: null,
title: “2M - 4M”,
type: “PolygonSymbolizer”,
color: “#FF4D4D”,
opacity: “0.7”,
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: “> 4M - 5M”,
name: null,
filter: “[ PERSONS BETWEEN 4000000 AND 5000000 ]”,
symbolyzers: [
{
name: null,
description: null,
title: “> 4M - 5M”,
type: “PolygonSymbolizer”,
color: “#4D4DFF”,
opacity: “0.7”,
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: “Boundary”,
name: null,
symbolyzers: [
{
name: null,
description: null,
title: “Boundary”,
type: “LineSymbolizer”,
perpendicularOffset: null,
strokeColor: “#000000”,
dashArray: “null”,
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: “Boundary”,
type: “TextSymbolizer”,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: “> 9M”,
name: null,
filter: “[ PERSONS > 9000000 ]”,
symbolyzers: [
{
name: null,
description: null,
title: “> 9M”,
type: “PolygonSymbolizer”,
color: “#AAAAAA”,
opacity: “0.7”,
perpendicularOffset: null,
geometry: null,
geometryPropertyName: null
}
]
},
{
description: null,
title: “Boundary”,
name: null,
symbolyzers: [
{
name: null,
description: null,
title: “Boundary”,
type: “LineSymbolizer”,
perpendicularOffset: null,
strokeColor: “#000000”,
dashArray: “null”,
geometry: null,
geometryPropertyName: null
},
{
name: null,
description: null,
title: “Boundary”,
type: “TextSymbolizer”,
geometry: null,
geometryPropertyName: null
}
]
}
]
}

From: ccancellieri@anonymised.com
To: andrea.aime@anonymised.com
Date: Thu, 4 Oct 2012 08:54:53 +0000
CC: geoserver-devel@lists.sourceforge.net
Subject: Re: [Geoserver-devel] getLegendGraphic as text

Hi,
On Wed, Oct 3, 2012 at 5:52 PM, Carlo Cancellieri ccancellieri@anonymised.com wrote:
Hi,
I’d like to know if someone discussed about the way to get the legend in a textual format (json or xml).
Does it make sense to return the lists of rules (filtered) as XML or json if someone requests the getLegendGraphic in that format (application/xml, application/json)?

I guess so? What’s the use case, trying to generate the legend client side?

Yes, that’s what I really need.

Doing so is not easy as you may end up with different symbolizers for the same feature, different feature type
styles and figuring out how they can be combined is sort of work of magic unless you are also doing a full
evaluation against of the features and see what combinations are used in reality

My intention is to reproduce the current implementation of the getLegendGraphic serializing the obtained final set of rules (used to renderize the legend) to a text representation (xml and json).
I still have to investigate on possible problems and the amount of time to code needed, so I’m just looking around right now.

@devs:
is there a “standard” way to transport the rules and relatives symbolizers in json?

Not aware of one

Cheers
Andrea

thank you,
Carlo

Hi,

I'd be interested in a way to get labels as texts (so they can be
localized client side), but not much interested in rendering the
icons... Something simpler, like:

symbolyzers: [
   {
      label: "Symbol 1",
      icon: "http://localhost:8080/geoserver/wms?request=GetLegendGraphics&&lt;parameters\-to\-get\-only\-the\-icon&gt;&quot;
   }, {
      label: "Symbol 2",
      icon: "http://localhost:8080/geoserver/wms?request=GetLegendGraphics&&lt;parameters\-to\-get\-only\-the\-icon&gt;&quot;
   }
]

Icon could be a URL, or base64 encoded inline.

Would this be possible as an option?

Thanks,

Oscar.

Hi Anrés,

how are you looking to handle the use of graphics or shapes? such as
squares, triangles, circles, stars, open arrows, etc.

My intention is to provide a textual representation of the rules, filters and the symbolizers contained by the selected style.
Essentially it will be a json representation of the most relevant (to build the legend) parts of the selected style.

Then we could improve the graphic version of the getLegendGraphic output format adding the capability to renderize single objects to integrate the textual version with url(s) to graphical objects as suggested by Oscar.

Cheers,
Carlo

I'd be interested in a way to get labels as texts (so they can be
localized client side), but not much interested in rendering the
icons... Something simpler, like:

symbolyzers: [
{
label: "Symbol 1",
icon: "http://localhost:8080/geoserver/wms?request=GetLegendGraphics&&lt;parameters\-to\-get\-only\-the\-icon&gt;&quot;
}, {
label: "Symbol 2",
icon: "http://localhost:8080/geoserver/wms?request=GetLegendGraphics&&lt;parameters\-to\-get\-only\-the\-icon&gt;&quot;
}
]

Icon could be a URL, or base64 encoded inline.

Would this be possible as an option?

I would also be interested in this idea, the udig-devel list has been breaking down the style, and especially the raster styles into smooth colour ramps and so on.

Is there a good spot in GeoTools where I could put the code (to avoid duplication).

I would also seriously consider making use of getLegendGraphic as described below - in order to provide nicer feedback. It is an excellent idea.

Jody Garnett

On Friday, 19 October 2012 at 5:06 AM, Carlo Cancellieri wrote:

Hi Anrés,

how are you looking to handle the use of graphics or shapes? such as
squares, triangles, circles, stars, open arrows, etc.

My intention is to provide a textual representation of the rules, filters and the symbolizers contained by the selected style.
Essentially it will be a json representation of the most relevant (to build the legend) parts of the selected style.

Then we could improve the graphic version of the getLegendGraphic output format adding the capability to renderize single objects to integrate the textual version with url(s) to graphical objects as suggested by Oscar.

Cheers,
Carlo

I’d be interested in a way to get labels as texts (so they can be
localized client side), but not much interested in rendering the
icons… Something simpler, like:

symbolyzers: [
{
label: “Symbol 1”,
icon: “http://localhost:8080/geoserver/wms?request=GetLegendGraphics&
}, {
label: “Symbol 2”,
icon: “http://localhost:8080/geoserver/wms?request=GetLegendGraphics&
}
]

Icon could be a URL, or base64 encoded inline.

Would this be possible as an option?


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct


Geoserver-devel mailing list
Geoserver-devel@anonymised.comrge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel