[Geoserver-devel] sld filter function 'area' returning area in pixels?

Hi Devs,

having a polygon dataset, I want to show small polygons (<1m2) different from the rest of the polygons

I thought to use the 'area' function which according to this:
http://docs.geoserver.org/stable/en/user/filter/function_reference.html
would give:
"The area of the specified geometry. Works in a Cartesian plane, the result will be in the same unit of measure as the geometry coordinates (which also means the results won’t make any sense for geographic data)"

But what I observe here is that it returns the size in pixels, while data is in meters.

Because zooming in I saw the style of some bigger polygons change (while off course the geometry area itself stays the same).
Also showing the area in a label shows that on zooming in the area is changing on every zoomlevel...

QUESTION:
- is this supposed behaviour or is this a bug?
- IS it possible to use the geometry area in filters/labels

Note: Tried both Area and area

Regards,

Richard Duivenvoorde

PS: example rule below

         <Rule>
         <Name>poly</Name>
         <Title>poly</Title>
         <ogc:Filter>
                 <ogc:PropertyIsGreaterThan>
                     <ogc:Function name="area">
                         <ogc:PropertyName>GEOM</ogc:PropertyName>
                     </ogc:Function>
                     <ogc:Literal>1.0</ogc:Literal>
                </ogc:PropertyIsGreaterThan>

         </ogc:Filter>
         <PolygonSymbolizer>
             <Fill>
                 <CssParameter name="fill">#104DAF</CssParameter>
                 <CssParameter name="fill-opacity">
                     <ogc:Literal>0.4</ogc:Literal>
                 </CssParameter>
             </Fill>
             <Stroke>
                 <CssParameter name="stroke">#104DAF</CssParameter>
                 <CssParameter name="stroke-width">1</CssParameter>
             </Stroke>
         </PolygonSymbolizer>

     <TextSymbolizer>
         <Label>
                     <ogc:Function name="Area">
                         <ogc:PropertyName>GEOM</ogc:PropertyName>
                     </ogc:Function>
         </Label>
         <Font>
           <CssParameter name="font-family">Arial</CssParameter>
           <CssParameter name="font-size">14</CssParameter>
           <CssParameter name="font-style">normal</CssParameter>
           <CssParameter name="font-weight">bold</CssParameter>
         </Font>
         <LabelPlacement>
           <PointPlacement>
             <AnchorPoint>
               <AnchorPointX>0.5</AnchorPointX>
               <AnchorPointY>0.5</AnchorPointY>
             </AnchorPoint>
           </PointPlacement>
         </LabelPlacement>
         <Fill>
           <CssParameter name="fill">#000000</CssParameter>
         </Fill>
       </TextSymbolizer>

     </Rule>

     <Rule>
         <Name>point</Name>
         <Title>point</Title>
         <ogc:Filter>
                 <ogc:PropertyIsLessThanOrEqualTo>
                     <ogc:Function name="area">
                         <ogc:PropertyName>GEOM</ogc:PropertyName>
                     </ogc:Function>
                     <ogc:Literal>1</ogc:Literal>
                </ogc:PropertyIsLessThanOrEqualTo>
         </ogc:Filter>
         <PointSymbolizer>
             <Graphic>
                 <ExternalGraphic>
                     <OnlineResource xlink:type="simple" xlink:href="point.svg" />
                 <Format>image/svg+xml</Format>
              </ExternalGraphic>
             </Graphic>
         </PointSymbolizer>
         <PolygonSymbolizer>
             <Fill>
                 <CssParameter name="fill">#ff0000</CssParameter>
                 <CssParameter name="fill-opacity">
                     <ogc:Literal>0.4</ogc:Literal>
                 </CssParameter>
             </Fill>
             <Stroke>
                 <CssParameter name="stroke">#ff0000</CssParameter>
                 <CssParameter name="stroke-width">1</CssParameter>
             </Stroke>
         </PolygonSymbolizer>

     </Rule>

On Wed, Nov 30, 2016 at 10:51 AM, Richard Duivenvoorde <rdmailings@anonymised.com..>
wrote:

QUESTION:
- is this supposed behaviour or is this a bug?

I don't think it was ever given much of a thought, but I'd classify it as a
bug. One somewhat hard to
fix, geometries are generalized, reprojected and transformed in screen
space "in place" to limit
garbage generation, so the label should be evaluated before that happens.

Fixing that without causing a visible performance regression in normal
rendering might be tricky business, but should be doable.
I'd open a ticket.

Cheers
Andrea

--

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.

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

I wonder if we could tie the area calculation to UOM? Looks like currently UOM is an attribute on the symbolizer, so not quite in the right place to work with area, but might be something to think about.

In the interim, you may be able to use the wms_scale_denominator environment variable to calculate the proper area from the area in pixels.

Torben

···

On Wed, Nov 30, 2016 at 2:57 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:



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

On Wed, Nov 30, 2016 at 10:51 AM, Richard Duivenvoorde <rdmailings@anonymised.com> wrote:

QUESTION:

  • is this supposed behaviour or is this a bug?

I don’t think it was ever given much of a thought, but I’d classify it as a bug. One somewhat hard to
fix, geometries are generalized, reprojected and transformed in screen space “in place” to limit
garbage generation, so the label should be evaluated before that happens.

Fixing that without causing a visible performance regression in normal rendering might be tricky business, but should be doable.
I’d open a ticket.

Cheers
Andrea

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


On 30-11-16 18:25, Torben Barsballe wrote:

I wonder if we could tie the area calculation to UOM
<http://docs.geoserver.org/2.1.4/user/styling/sld-extensions/uom.html&gt;?
Looks like currently UOM is an attribute on the symbolizer, so not quite
in the right place to work with area, but might be something to think about.

In the interim, you may be able to use the wms_scale_denominator
environment variable
<http://docs.geoserver.org/2.2.4/user/styling/sld-extensions/substitution.html#predefined-variables&gt;
to calculate the proper area from the area in pixels.

Ah! That is a cool trick. Did not come up on this one, Thanks!
For me it does not have to be very precise, I just want to have some artificial treshold to say "and now it is a point".
So I think if I can pull wms_scale_denominator into my function I'm happy.

Regards,

Richard