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/
> 2001/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</
> VendorOption>
>
>
>
>                            <VendorOption name="removeOverlaps">true</
> VendorOption>
>
>
>
>                            <VendorOption name="followLine">true</
> VendorOption>
>
>
>
>                            <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&;
> request=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.
> com: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
------------------------------------------------------------------------------
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