[Geoserver-devel] GetLegendGraphics, dpi, and decorations (oh my...)

Hi,
I’m working on http://jira.codehaus.org/browse/GEOS-4100 to add support for custom dpi to the
GetLegendGraphics code. Some changes in that directions (with support for UOM too)
were already made by a user contributed patch (http://jira.codehaus.org/browse/GEOS-4927)
however proper dpi support needed some fixes.
Done that, and then realized a discussion is needed about a couple of details, about interactions
with other code.

Let’s have a look at a sample output from the states layer:

http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states

states.png

Now, when applying dpi=180 the expected result is to have all lines get thicker, all point symbols grow bigger,
and have text grow as well. The result I have so far is this one:

http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states&legend_options=dpi:180

states_180-nq8.png

The behavior is as expected, but there is maybe one gotcha, see the square blocks also grew?
I’m not 100% sure about that. The request asks for 20x20 legend icons, and that amount has
been multiplied by 2 due to the dpi.
The result looks natural to me, however if we look at how GetMap works, we can see that
adding dpi does not make the map bigger, it’s the caller tha has to ask for a larger raster instead.
Would GetLegendGraphics do the same, assume the caller asks for a larger sample width/height,
instead?

There are implications when putting the legend into a layout. For example, see how the current
code works:

http://localhost:8080/geoserver/topp/wms?FORMAT_OPTIONS=layout%3Alegend&LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=780&HEIGHT=330&bgcolor=0xDDDDDD&format_options=layout:legend

states-layout-nq8.png

http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=780&HEIGHT=330&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140

states-layout1-nq8.png

Scaling up the samples seems desirable behavior here, if we don’t, in order to have symbols proportional to the fonts
we’d need to create by hand a custom layout file that has different values for the samples size.

Notice however how the scale line did not grow in size… I’m inclined to consider this a bug, everything in the layout
should grow according to the dpi to get something that can be printed.

Soo… long story short, I’m inclined to leave the legend graphics work as is, and eventually fix the rest of map decorations
to account for dpi values, even if the behavior does not seem consistent with the GetMap one… but I definitely
could use some feedback :slight_smile:

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


So Andrea, in adding dpi to GetLegendGraphic request, is this a fair
summary?:

Text grows: Expected
Line Doesn't Get thicker: Unexpected
Points grow: Expected
Legend icons grow: Should they?

Hmm. It falls in that fussy area between spatial and page coordinates,
doesn't it. When a getmap request is processed, the user specifies the dpi
to force the scaling of elements, and then independently requests the actual
full size of the map. In the case of a legend element, only one is
specified, so we have an ambiguous case, as we are dealing with a purely
page coordinates case, unlike the getmap.

Should legend icons grow? I'd say they should grow (disclosure: I have a
vested interest in this outcome). If someone is applying DPI to the
request, the expectation is that the legend icons would match the font size.
The legend itself doesn't make sense as a single request otherwise. Yes, it
makes for a bit of a mess to put it into a layout, but that's where we have
a mix of page and map expectations, where this request might make more
sense:

http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=1560&HEIGHT=660&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140
http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=1560&HEIGHT=660&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140

than this:

http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=780&HEIGHT=330&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140
http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=780&HEIGHT=330&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/GetLegendGraphics-dpi-and-decorations-oh-my-tp4468887p4469949.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.

On Tue, Feb 14, 2012 at 8:37 PM, Stephen Mather <mather.stephen@anonymised.com> wrote:

So Andrea, in adding dpi to GetLegendGraphic request, is this a fair
summary?:

Text grows: Expected
Line Doesn’t Get thicker: Unexpected

Line does actually get thicker, it’s just (very) hard to notice since the original width is 0.2, so when
you double it it’s still just 0.4 thick, which visually does not make much of a difference.
If we use a much larger dpi it gets thicker in a visible way, see the attached legend generated
at 1200dpi.

I’ve also attached a sample with a legend using a point symbolizer for the “poi”, normal and
at 1200dpi.

Points grow: Expected
Legend icons grow: Should they?

Hmm. It falls in that fussy area between spatial and page coordinates,
doesn’t it. When a getmap request is processed, the user specifies the dpi
to force the scaling of elements, and then independently requests the actual
full size of the map. In the case of a legend element, only one is
specified, so we have an ambiguous case, as we are dealing with a purely
page coordinates case, unlike the getmap.

Should legend icons grow? I’d say they should grow (disclosure: I have a
vested interest in this outcome). If someone is applying DPI to the
request, the expectation is that the legend icons would match the font size.
The legend itself doesn’t make sense as a single request otherwise. Yes, it
makes for a bit of a mess to put it into a layout, but that’s where we have
a mix of page and map expectations, where this request might make more
sense:

http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=1560&HEIGHT=660&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140
http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=1560&HEIGHT=660&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140

than this:

http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=780&HEIGHT=330&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140
http://localhost:8080/geoserver/topp/wms?LAYERS=topp%3Astates&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-144.13570042969,17.896190337891,-56.139554062508,55.125329185547&WIDTH=780&HEIGHT=330&bgcolor=0xDDDDDD&format_options=layout:legend;dpi:140

Agreed

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


(attachments)

states-legend-nq8.png
poi.png
poi_1200-nq8.png