I am attempting to determine the size of a point symbol based on scale using a custom function. However, the first test of scale (if scale >= 500000:) always evaluates to true. I have chosen the scales for the script based on the fact that my base layer in an OL3 app is an OpenLayers.Layer.ArcGISCache with the following config http://maps.nyc.gov/gis/data/tiles/conf.xml
FUNCTION (iconSize.py):
def run(value, args):
scale = args[0]
if scale >= 500000:
return 20
elif scale >= 350000:
return 22
elif scale >= 256000:
return 24
elif scale >= 128000:
return 26
elif scale >= 64000:
return 28
elif scale >= 32000:
return 30
elif scale >= 16000:
return 32
elif scale >= 8000:
return 34
elif scale >= 4000:
return 36
elif scale >= 2000:
return 38
else:
return 40
SLD:
<?xml version="1.0" encoding="UTF-8"?>
<sld:UserStyle xmlns="http://www.opengis.net/sld"
xmlns:sld="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml">
<sld:Name>Default Styler</sld:Name>
<sld:FeatureTypeStyle>
<sld:Name>name</sld:Name>
<sld:Rule>
<sld:PointSymbolizer>
<sld:Graphic>
<sld:ExternalGraphic>
<sld:OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
xlink:href="http://localhost:82/geoserver/styles/mapIcons/Recovery.svg"/>
<sld:Format>image/svg+xml</sld:Format>
</sld:ExternalGraphic>
<sld:Size>
<ogc:Function name="iconSize">
<ogc:Function name="env">
<ogc:Literal>wms_scale_denominator</ogc:Literal>
</ogc:Function>
</ogc:Function>
</sld:Size>
</sld:Graphic>
</sld:PointSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
Thanks, I’ll checkout recode. I have no idea what value I am getting for wms_scale_denominator… I even made the first test in the script scale >= 10000000 and it still returned true.
···
The recode function can be used for switch statement like logic. So no need to write a custom function.
I wonder what value you are getting for wms_scale_denominator ?
Jody Garnett
On Sun, Feb 9, 2014 at 6:22 AM, Keane, Tim <tkeane@anonymised.com> wrote:
I am attempting to determine the size of a point symbol based on scale using a custom function. However, the first test of scale (if scale >= 500000:) always evaluates to true. I have chosen the scales for the script based on the fact that my base layer in an OL3 app is an OpenLayers.Layer.ArcGISCache with the following config http://maps.nyc.gov/gis/data/tiles/conf.xml
FUNCTION (iconSize.py):
def run(value, args):
scale = args[0]
if scale >= 500000:
return 20
elif scale >= 350000:
return 22
elif scale >= 256000:
return 24
elif scale >= 128000:
return 26
elif scale >= 64000:
return 28
elif scale >= 32000:
return 30
elif scale >= 16000:
return 32
elif scale >= 8000:
return 34
elif scale >= 4000:
return 36
elif scale >= 2000:
return 38
else:
return 40
SLD:
<?xml version="1.0" encoding="UTF-8"?>
<sld:UserStyle xmlns=“http://www.opengis.net/sld”
xmlns:sld=“http://www.opengis.net/sld”
xmlns:ogc=“http://www.opengis.net/ogc”
xmlns:gml=“http://www.opengis.net/gml”>
sld:NameDefault Styler</sld:Name>
sld:FeatureTypeStyle
sld:Namename</sld:Name>
sld:Rule
sld:PointSymbolizer
sld:Graphic
sld:ExternalGraphic
<sld:OnlineResource xmlns:xlink=“http://www.w3.org/1999/xlink” xlink:type=“simple”
xlink:href=“http://localhost:82/geoserver/styles/mapIcons/Recovery.svg”/>
sld:Formatimage/svg+xml</sld:Format>
</sld:ExternalGraphic>
sld:Size
<ogc:Function name=“iconSize”>
<ogc:Function name=“env”>
ogc:Literalwms_scale_denominator</ogc:Literal>
</ogc:Function>
</ogc:Function>
</sld:Size>
</sld:Graphic>
</sld:PointSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
Geoserver-devel mailing list
Geoserver-devel@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel
On Sun, Feb 9, 2014 at 6:56 AM, Keane, Tim <tkeane@anonymised.com> wrote:
The recode function can be used for switch statement like logic. So no
need to write a custom function.
I wonder what value you are getting for wms_scale_denominator ?
Some time ago Martin Davis needed to know some of the wms related
information in his rendering
transformations, as input parameters (for heat map I think?) so I added
this:
https://github.com/geoserver/geoserver/blob/master/src/wms/src/main/java/org/geoserver/wms/RenderingVariables.java
It is called before running the code behind GetMap and GetFeatureInfo.
Cheers
Andrea
--
== Our support, Your Success! Visit http://opensdi.geo-solutions.it for
more information ==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------
On Sun, Feb 9, 2014 at 6:56 AM, Keane, Tim <tkeane@anonymised.com> wrote:
Thanks, I'll checkout recode. I have no idea what value I am getting
for wms_scale_denominator... I even made the first test in the script scale
>= 10000000 and it still returned true.
To see what value you're getting, you can either log it from your function,
or use it as a label point a point:
<Label>
<ogc:Function name="env">
<ogc:Literal>wms_scale_denominator</ogc:Literal>
</ogc:Function>
</Label>
Btw, for a case like this one a even simpler solution to make the icon grow
as the zoom increases
is to specificy its size in meters/feet:
http://docs.geoserver.org/latest/en/user/styling/sld-extensions/uom.html
Cheers
Andrea
--
== Our support, Your Success! Visit http://opensdi.geo-solutions.it for
more information ==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------