[Geoserver-users] GetLegendGraphic fails if SLD uses filter function round

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

vdline

Hastighedsgrænser

Visualisering af hastighedsgrænsedata

Skiltet hastighed 40

Skiltet hastighed 40 km/t

Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende hastighed (hast_gaeld)

ogc:Filter

ogc:PropertyIsEqualTo

ogc:PropertyNamehast_lokal</ogc:PropertyName>

ogc:Literal40</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

#0000ff

1

<ogc:Function name=“round”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

10

Arial

#0000aa

0

ogc:Literal1</ogc:Literal>

#f4faf6

#0000aa

50

true

true

true

The complete SLD contains multiple s for various values of hast_lokal.

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

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

If I modify the SLD, specifically the , removing the <ogc:Function name=”round”>, so that it becomes

ogc:PropertyNamehast_gaeld</ogc:PropertyName>

I get a nice legend. Is that a bug?

Regards,

/julian

Nope it isn’t a bug - the error is quite clear

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

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 <julian@…5218…> 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"?>

vdline

Hastighedsgrænser

Visualisering af hastighedsgrænsedata

Skiltet hastighed 40

Skiltet hastighed 40 km/t

Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende hastighed (hast_gaeld)

ogc:Filter

ogc:PropertyIsEqualTo

ogc:PropertyNamehast_lokal</ogc:PropertyName>

ogc:Literal40</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

#0000ff

1

<ogc:Function name=“round”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

10

Arial

#0000aa

0

ogc:Literal1</ogc:Literal>

#f4faf6

#0000aa

50

true

true

true

The complete SLD contains multiple s for various values of hast_lokal.

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

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

If I modify the SLD, specifically the , removing the <ogc:Function name=”round”>, so that it becomes

ogc:PropertyNamehast_gaeld</ogc:PropertyName>

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
Geoserver-users@…382…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton

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:ijturton@…84…]
Sendt: 15. februar 2017 16:07
Til: Julian Hollingbery <julian@…5218…>
Cc: geoserver-users@lists.sourceforge.net
Emne: Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter function round

Nope it isn’t a bug - the error is quite clear

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

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 <julian@…5218…> 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"?>

vdline

Hastighedsgrænser

Visualisering af hastighedsgrænsedata

Skiltet hastighed 40

Skiltet hastighed 40 km/t

Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende hastighed (hast_gaeld)

ogc:Filter

ogc:PropertyIsEqualTo

ogc:PropertyNamehast_lokal</ogc:PropertyName>

ogc:Literal40</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

#0000ff

1

<ogc:Function name=“round”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

10

Arial

#0000aa

0

ogc:Literal1</ogc:Literal>

#f4faf6

#0000aa

50

true

true

true

The complete SLD contains multiple s for various values of hast_lokal.

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

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

If I modify the SLD, specifically the , removing the <ogc:Function name=”round”>, so that it becomes

ogc:PropertyNamehast_gaeld</ogc:PropertyName>

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
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton

Then you’ll need something like

<ogc:Function name=“round”>

<ogc:Function name=“if_then_else”><ogc:Function name=“isNull”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>ogc:Literal0.0</ogc:Literal>,ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

</ogc:Function>

···

On 15 February 2017 at 15:17, Julian Hollingbery <julian@…5218…> 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:ijturton@…84…]
Sendt: 15. februar 2017 16:07
Til: Julian Hollingbery <julian@…5218…>
Cc: geoserver-users@…382…sourceforge.net
Emne: Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter function round

Nope it isn’t a bug - the error is quite clear

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

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 <julian@…5218…> 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"?>

vdline

Hastighedsgrænser

Visualisering af hastighedsgrænsedata

Skiltet hastighed 40

Skiltet hastighed 40 km/t

Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende hastighed (hast_gaeld)

ogc:Filter

ogc:PropertyIsEqualTo

ogc:PropertyNamehast_lokal</ogc:PropertyName>

ogc:Literal40</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

#0000ff

1

<ogc:Function name=“round”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

10

Arial

#0000aa

0

ogc:Literal1</ogc:Literal>

#f4faf6

#0000aa

50

true

true

true

The complete SLD contains multiple s for various values of hast_lokal.

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

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

If I modify the SLD, specifically the , removing the <ogc:Function name=”round”>, so that it becomes

ogc:PropertyNamehast_gaeld</ogc:PropertyName>

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
Geoserver-users@…382…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton

Ian Turton

Hi Ian,
it might, or might not… to build legend graphics we create a sample features with all default
values for the data types of the feature… it might be that map rendering works,
but legend graphic fails

Cheers
Andrea

···

On Wed, Feb 15, 2017 at 4:07 PM, Ian Turton <ijturton@…84…> wrote:

Nope it isn’t a bug - the error is quite clear

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

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)


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
Geoserver-users@…382…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

On 15 February 2017 at 14:51, Julian Hollingbery <julian@…5218…> 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"?>

vdline

Hastighedsgrænser

Visualisering af hastighedsgrænsedata

Skiltet hastighed 40

Skiltet hastighed 40 km/t

Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende hastighed (hast_gaeld)

ogc:Filter

ogc:PropertyIsEqualTo

ogc:PropertyNamehast_lokal</ogc:PropertyName>

ogc:Literal40</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

#0000ff

1

<ogc:Function name=“round”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

10

Arial

#0000aa

0

ogc:Literal1</ogc:Literal>

#f4faf6

#0000aa

50

true

true

true

The complete SLD contains multiple s for various values of hast_lokal.

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

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

If I modify the SLD, specifically the , removing the <ogc:Function name=”round”>, so that it becomes

ogc:PropertyNamehast_gaeld</ogc:PropertyName>

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
Geoserver-users@…454…rge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

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.


Thanks, that did the trick J

Still seem a bit odd that GetLegendGraphic is more brittle than GetMap…

···

Then you’ll need something like

<ogc:Function name=“round”>

<ogc:Function name=“if_then_else”><ogc:Function name=“isNull”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>ogc:Literal0.0</ogc:Literal>,ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

</ogc:Function>

On 15 February 2017 at 15:17, Julian Hollingbery <julian@…5218…> 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:ijturton@…84…]
Sendt: 15. februar 2017 16:07
Til: Julian Hollingbery <julian@…5218…>
Cc: geoserver-users@lists.sourceforge.net
Emne: Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter function round

Nope it isn’t a bug - the error is quite clear

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

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 <julian@…5218…> 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"?>

vdline

Hastighedsgrænser

Visualisering af hastighedsgrænsedata

Skiltet hastighed 40

Skiltet hastighed 40 km/t

Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende hastighed (hast_gaeld)

ogc:Filter

ogc:PropertyIsEqualTo

ogc:PropertyNamehast_lokal</ogc:PropertyName>

ogc:Literal40</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

#0000ff

1

<ogc:Function name=“round”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

10

Arial

#0000aa

0

ogc:Literal1</ogc:Literal>

#f4faf6

#0000aa

50

true

true

true

The complete SLD contains multiple s for various values of hast_lokal.

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

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

If I modify the SLD, specifically the , removing the <ogc:Function name=”round”>, so that it becomes

ogc:PropertyNamehast_gaeld</ogc:PropertyName>

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
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton

Ian Turton

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 <julian@…5218…> wrote:

Thanks, that did the trick J

Still seem a bit odd that GetLegendGraphic is more brittle than GetMap…

Fra: Ian Turton [mailto:ijturton@…84…]
Sendt: 15. februar 2017 16:22

Til: Julian Hollingbery <julian@…5218…>
Cc: geoserver-users@…382…sourceforge.net
Emne: Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter function round

Then you’ll need something like

<ogc:Function name=“round”>

<ogc:Function name=“if_then_else”><ogc:Function name=“isNull”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>ogc:Literal0.0</ogc:Literal>,ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

</ogc:Function>

On 15 February 2017 at 15:17, Julian Hollingbery <julian@…5218…> 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:ijturton@…84…]
Sendt: 15. februar 2017 16:07
Til: Julian Hollingbery <julian@…5218…>
Cc: geoserver-users@…382…sourceforge.net
Emne: Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter function round

Nope it isn’t a bug - the error is quite clear

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

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 <julian@…5218…> 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"?>

vdline

Hastighedsgrænser

Visualisering af hastighedsgrænsedata

Skiltet hastighed 40

Skiltet hastighed 40 km/t

Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende hastighed (hast_gaeld)

ogc:Filter

ogc:PropertyIsEqualTo

ogc:PropertyNamehast_lokal</ogc:PropertyName>

ogc:Literal40</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

#0000ff

1

<ogc:Function name=“round”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

10

Arial

#0000aa

0

ogc:Literal1</ogc:Literal>

#f4faf6

#0000aa

50

true

true

true

The complete SLD contains multiple s for various values of hast_lokal.

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

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

If I modify the SLD, specifically the , removing the <ogc:Function name=”round”>, so that it becomes

ogc:PropertyNamehast_gaeld</ogc:PropertyName>

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
Geoserver-users@…382…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton

Ian Turton

Ian Turton

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 <ijturton@…84…> 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 <julian@…5218…> wrote:

Thanks, that did the trick J

Still seem a bit odd that GetLegendGraphic is more brittle than GetMap…

Fra: Ian Turton [mailto:ijturton@…84…]
Sendt: 15. februar 2017 16:22

Til: Julian Hollingbery <julian@…5218…>
Cc: geoserver-users@…454…rge.net
Emne: Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter function round

Then you’ll need something like

<ogc:Function name=“round”>

<ogc:Function name=“if_then_else”><ogc:Function name=“isNull”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>ogc:Literal0.0</ogc:Literal>,ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

</ogc:Function>

On 15 February 2017 at 15:17, Julian Hollingbery <julian@…5218…> 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:ijturton@…84…]
Sendt: 15. februar 2017 16:07
Til: Julian Hollingbery <julian@…5218…>
Cc: geoserver-users@…454…rge.net
Emne: Re: [Geoserver-users] GetLegendGraphic fails if SLD uses filter function round

Nope it isn’t a bug - the error is quite clear

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

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 <julian@…5218…> 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"?>

vdline

Hastighedsgrænser

Visualisering af hastighedsgrænsedata

Skiltet hastighed 40

Skiltet hastighed 40 km/t

Skiltet hastighed (hast_lokal) 40 km/t. Etiket viser gældende hastighed (hast_gaeld)

ogc:Filter

ogc:PropertyIsEqualTo

ogc:PropertyNamehast_lokal</ogc:PropertyName>

ogc:Literal40</ogc:Literal>

</ogc:PropertyIsEqualTo>

</ogc:Filter>

#0000ff

1

<ogc:Function name=“round”>ogc:PropertyNamehast_gaeld</ogc:PropertyName></ogc:Function>

10

Arial

#0000aa

0

ogc:Literal1</ogc:Literal>

#f4faf6

#0000aa

50

true

true

true

The complete SLD contains multiple s for various values of hast_lokal.

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

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

If I modify the SLD, specifically the , removing the <ogc:Function name=”round”>, so that it becomes

ogc:PropertyNamehast_gaeld</ogc:PropertyName>

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
Geoserver-users@…454…rge.net
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.