Hi Ian,
it depends on whether it has a reference layer or not in the request, it
might go into one of these:
https://github.com/geoserver/geoserver/blob/master/src/wms/src/main/java/org/geoserver/wms/legendgraphic/BufferedImageLegendGraphicBuilder.java#L759
https://github.com/geoserver/geoserver/blob/master/src/wms/src/main/java/org/geoserver/wms/legendgraphic/BufferedImageLegendGraphicBuilder.java#L780
https://github.com/geoserver/geoserver/blob/master/src/wms/src/main/java/org/geoserver/wms/legendgraphic/BufferedImageLegendGraphicBuilder.java#L856

Not sure what they do, legend graphics generation is one of the places that
I'm not really familiar with :-p

Cheers
Andrea


On Wed, Feb 15, 2017 at 4:56 PM, Ian Turton <[email protected]> wrote:

> Andrea,
>
> That seems to indicate that our fake feature does contain a NULL - may be
> because the attribute allows NULLs?
>
> Infact I think I've been bitten by this before - assuming it is using
> DataUtilities.defaultValue which does return Null if it can get away with it
>
> I used a method like:
>
> private SimpleFeature generateDefaultFeature(SimpleFeatureType schema) {
>     SimpleFeature defaultFeature = DataUtilities.template(schema,
> schema.getTypeName());
>     // we have to do this as our nullable attributes will be null if not
>     for (Property prop : defaultFeature.getProperties()) {
>       Object defaultValue = DataUtilities.defaultValue(
> prop.getType().getBinding());
>       defaultFeature.setAttribute(prop.getName(), defaultValue);
>     }
>     return defaultFeature;
>   }
>
> to avoid this issue.
>
> Ian
>
> On 15 February 2017 at 15:37, Julian Hollingbery <[email protected]>
> wrote:
>
>> Thanks, that did the trick J
>>
>>
>>
>> Still seem a bit odd that GetLegendGraphic  is more brittle than GetMap..
>>
>>
>>
>> *Fra:* Ian Turton [mailto:[email protected]]
>> *Sendt:* 15. februar 2017 16:22
>>
>> *Til:* Julian Hollingbery <[email protected]>
>> *Cc:* [email protected]
>> *Emne:* Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter
>> function round
>>
>>
>>
>> Then you'll need something like
>>
>> <Label>
>>
>>          <ogc:Function name="round">
>>
>>                         <ogc:Function name="if_then_else"><ogc:Function
>> name="isNull"><ogc:PropertyName>hast_gaeld</ogc:PropertyName>
>> </ogc:Function><ogc:Literal>0.0</ogc:Literal>,<ogc:
>> PropertyName>hast_gaeld</ogc:PropertyName></ogc:Function>
>>
>>           </ogc:Function>
>>
>> </Label>
>>
>>
>>
>>
>>
>> On 15 February 2017 at 15:17, Julian Hollingbery <[email protected]>
>> wrote:
>>
>> Two things I’d like to note:
>>
>>    1. I can make GetMap and GetFeatureInfo requests just fine over the
>>    entire area covered by the dataset. Only GetLegendGraphic fails.
>>    2. As you can see from the table definition, the parameter to the
>>    function is a double. I’ll admit that there are NULL values in a few rows,
>>    but why should that prevent GeoServer from generating a legend?
>>
>>
>>
>> *Fra:* Ian Turton [mailto:[email protected]]
>> *Sendt:* 15. februar 2017 16:07
>> *Til:* Julian Hollingbery <[email protected]>
>> *Cc:* [email protected]
>> *Emne:* Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter
>> function round
>>
>>
>>
>> Nope it isn't a bug - the error is quite clear
>>
>>
>>
>> <ServiceException>
>>
>>       java.lang.IllegalArgumentException: Filter Function problem for
>> function round argument #0 - expected type float
>>
>> Filter Function problem for function round argument #0 - expected type
>> float
>>
>> </ServiceException></ServiceExceptionReport>
>>
>>
>>
>> You are passing something that isn't a number into the round function -
>> you'll either need to check your attributes or add a check to the SLD to
>> limit the input to numbers (probably with an if_then_else and a regexp)
>>
>>
>>
>> On 15 February 2017 at 14:51, Julian Hollingbery <[email protected]>
>> wrote:
>>
>> Hi list,
>>
>>
>>
>> I wonder if anyone else has seen something like this.
>>
>>
>>
>> I have a PostGIS table defined basically as
>>
>>
>>
>> CREATE TABLE vdline
>>
>> (
>>
>>   ogc_fid serial NOT NULL,
>>
>>   hast_gener character varying,
>>
>>   kode_hast0 character varying,
>>
>>   hast_lokal double precision,
>>
>>   hast_gaeld double precision,
>>
>>   hast_anbef double precision,
>>
>>   hast_var_h character varying,
>>
>>   geometri geometry(MultiLineString),
>>
>>   CONSTRAINT vdline_pkey PRIMARY KEY (ogc_fid)
>>
>> )
>>
>> WITH (
>>
>>   OIDS=FALSE
>>
>> );
>>
>>
>>
>> I publish it through GeoServer 2.9.1, using a style looking basically
>> like this:
>>
>>
>>
>> <?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"; xmlns:ogc="http://www.opengis.net/ogc";
>> xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns:xsi="http://www.w3.org/2
>> 001/XMLSchema-instance">
>>
>>                            <NamedLayer>
>>
>>                                                       <Name>vdline</Name>
>>
>>                                                       <UserStyle>
>>
>>
>> <Title>Hastighedsgrænser</Title>
>>
>>
>> <Abstract>Visualisering af hastighedsgrænsedata</Abstract>
>>
>>
>> <FeatureTypeStyle>
>>
>>
>>                            <Rule>
>>
>>
>>
>> <Name>Skiltet hastighed 40</Name>
>>
>>
>>
>> <Title>Skiltet hastighed 40 km/t</Title>
>>
>>
>>
>> <Abstract>Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende
>> hastighed (hast_gaeld)</Abstract>
>>
>>
>>
>> <ogc:Filter>
>>
>>
>>
>>
>> <ogc:PropertyIsEqualTo>
>>
>>
>>
>>
>> <ogc:PropertyName>hast_lokal</ogc:PropertyName>
>>
>>
>>
>>
>> <ogc:Literal>40</ogc:Literal>
>>
>>
>>
>>
>> </ogc:PropertyIsEqualTo>
>>
>>
>>
>> </ogc:Filter>
>>
>>
>>
>> <LineSymbolizer>
>>
>>
>>
>>                            <Stroke>
>>
>>
>>
>>
>> <CssParameter name="stroke">#0000ff</CssParameter>
>>
>>
>>
>>
>> <CssParameter name="stroke-width">1</CssParameter>
>>
>>
>>
>>                            </Stroke>
>>
>>
>>
>> </LineSymbolizer>
>>
>>
>>
>> <TextSymbolizer>
>>
>>
>>
>>                            <Label>
>>
>>                           <ogc:Function name="round"><ogc:PropertyName
>> >hast_gaeld</ogc:PropertyName></ogc:Function>
>>
>>
>>
>>                            </Label>
>>
>>
>>
>>                                            <Font>
>>
>>
>>
>>
>> <CssParameter name="font-size">10</CssParameter>
>>
>>
>>
>>
>> <CssParameter name="font-family">Arial</CssParameter>
>>
>>
>>
>>
>> <CssParameter name="font-color">#0000aa</CssParameter>
>>
>>
>>
>>                            </Font>
>>
>>
>>
>>                            <LabelPlacement>
>>
>>
>>
>>
>> <LinePlacement>
>>
>>
>>
>>
>>
>> <PerpendicularOffset>0</PerpendicularOffset>
>>
>>
>>
>>
>> </LinePlacement>
>>
>>
>>
>>                            </LabelPlacement>
>>
>>
>>
>>                                            <Halo>
>>
>>
>>
>>
>> <Radius>
>>
>>
>>
>>
>> <ogc:Literal>1</ogc:Literal>
>>
>>
>>
>>
>> </Radius>
>>
>>
>>
>>
>> <Fill>
>>
>>
>>
>>
>> <CssParameter name="fill">#f4faf6</CssParameter>
>>
>>
>>
>>                                                       </Fill>
>>
>>
>>
>>                            </Halo>
>>
>>
>>
>>                                            <Fill>
>>
>>
>>
>>
>> <CssParameter name="fill">#0000aa</CssParameter>
>>
>>
>>
>>                                            </Fill>
>>
>>
>>
>>                            <VendorOption name="maxDisplacement">50</Ven
>> dorOption>
>>
>>
>>
>>                            <VendorOption name="removeOverlaps">true</Ve
>> ndorOption>
>>
>>
>>
>>                            <VendorOption name="followLine">true</Vendor
>> Option>
>>
>>
>>
>>                            <VendorOption name="group">true</VendorOption>
>>
>>
>>
>> </TextSymbolizer>
>>
>>
>>                                                  </Rule>
>>
>>
>> </FeatureTypeStyle>
>>
>>                                                       </UserStyle>
>>
>>                            </NamedLayer>
>>
>> </StyledLayerDescriptor>
>>
>>
>>
>> The complete SLD contains multiple <FeatureTypeStyle>s for various values
>> of <PropertyName>hast_lokal</PropertyName>.
>>
>>
>>
>> If I make a GetLegendGraphic-request like
>>
>> http://hostname/workspace/wms?service=WMS&version=1.1.0&requ
>> est=GetLegendGraphic&layer=vdline&format=image/png
>>
>> I get the error:
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE
>> ServiceExceptionReport SYSTEM "http://gs.demo.geoteamwork.co
>> m:80/schemas/wms/1.1.1/WMS_exception_1_1_1.dtd"> <ServiceExceptionReport
>> version="1.1.1" >   <ServiceException>
>>
>>       java.lang.IllegalArgumentException: Filter Function problem for
>> function round argument #0 - expected type float
>>
>> Filter Function problem for function round argument #0 - expected type
>> float
>>
>> </ServiceException></ServiceExceptionReport>
>>
>>
>>
>> If I modify the SLD, specifically the <Label>, removing the <ogc:Function
>> name=”round”>, so that it becomes
>>
>>
>>
>>                            <Label>
>>
>>                           <ogc:PropertyName>hast_gaeld</ogc:PropertyName>
>>
>>
>>
>>                            </Label>
>>
>>
>>
>> I get a nice legend. Is that a bug?
>>
>>
>>
>> Regards,
>>
>> /julian
>>
>>
>>
>>
>> ------------------------------------------------------------
>> ------------------
>> 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
>>
>>
>>
>>
>>
>> --
>>
>> Ian Turton
>>
>>
>>
>>
>>
>> --
>>
>> Ian Turton
>>
>
>
>
> --
> Ian Turton
>



-- 
==
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.

-------------------------------------------------------
------------------------------------------------------------------------------
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

Reply via email to