We're looking into replacing Oracle MapViewer with GeoServer, but have hit a hangup when trying to duplicate the functionality of MapViewer. Essentially, with MapViewer we can, within a style, specify a "non-spatial data provider" which is just a Java class that supplies a mapping of each feature to some value (for example, which color to draw that feature). We would like to replicate this behavior in GeoServer, but I haven't found a good way to do so. For one of our projects, we need to color each feature in a shapefile some arbitrary color which is computed from external data. In order to do this with GeoServer now, I have to 1) compute the color, 2) create an sld with one rule per feature, setting that feature's fill color to the computed value, then 3) use the rest api to send that sld to GeoServer and tell the layer to use it. Is there a better way to do this? Or is there a straightforward way we can modify GeoServer (or create/modify an extension) to get this functionality?
Thanks,
Ryan
W dniu 2010-05-14 19:41, Ryan Zoerb pisze:
We're looking into replacing Oracle MapViewer with GeoServer, but have hit a hangup when trying to duplicate the functionality of MapViewer. Essentially, with MapViewer we can, within a style, specify a "non-spatial data provider" which is just a Java class that supplies a mapping of each feature to some value (for example, which color to draw that feature). We would like to replicate this behavior in GeoServer, but I haven't found a good way to do so. For one of our projects, we need to color each feature in a shapefile some arbitrary color which is computed from external data. In order to do this with GeoServer now, I have to 1) compute the color, 2) create an sld with one rule per feature, setting that feature's fill color to the computed value, then 3) use the rest api to send that sld to GeoServer and tell the layer to use it. Is there a better way to do this? Or is there a straightforward way we can modify GeoServer (or create/modify an extension) to get this functionality?
You can put SLD into WMS url using SLD_BODY . Look here:
http://geoserver.org/display/GEOSDOC/Providing+SLD+to+GetMap+requests
In that case there is no need to upload SLD to server.
/Peter
GeoServer supports using filter functions as CssParameter values in SLD:
http://docs.geoserver.org/stable/en/user/filter/function.html#sld-formatting-example
In GeoTools/GeoServer, filter functions are just instances of Java classes conforming to some interface:
http://geoapi.sourceforge.net/snapshot/pending/org/opengis/filter/expression/Function.html
For example, here’s what Min looks like:
http://svn.osgeo.org/geotools/tags/2.6.4/modules/library/main/src/main/java/org/geotools/filter/function/math/FilterFunction_min.java
and they can be registered using the SPI mechanism:
http://svn.osgeo.org/geotools/tags/2.6.4/modules/library/main/src/main/resources/META-INF/services/org.opengis.filter.expression.Function
So if you’re not worried by the prospect of writing a little Java code it is very possible to perform arbitrarily complex color calculations as part of a style; just create a function that produces a java.awt.Color or a string with a hex color specification.
And to add one more bit to the mix see 'Parameter substitution in SLD' http://docs.geoserver.org/stable/en/user/styling/sld-extensions/substitution.html
The combination of filter functions, parameter substitution and SLD WMS should likely meet most all of your use cases. And if it doesn't all the code is open source, and there's likely some other extension points you could code in to.
best regards,
Chris
On 5/14/10 2:48 PM, David Winslow wrote:
GeoServer supports using filter functions as CssParameter values in SLD:
http://docs.geoserver.org/stable/en/user/filter/function.html#sld-formatting-example
In GeoTools/GeoServer, filter functions are just instances of Java
classes conforming to some interface:
http://geoapi.sourceforge.net/snapshot/pending/org/opengis/filter/expression/Function.html
For example, here's what Min looks like:
http://svn.osgeo.org/geotools/tags/2.6.4/modules/library/main/src/main/java/org/geotools/filter/function/math/FilterFunction_min.java
and they can be registered using the SPI mechanism:
http://svn.osgeo.org/geotools/tags/2.6.4/modules/library/main/src/main/resources/META-INF/services/org.opengis.filter.expression.Function
So if you're not worried by the prospect of writing a little Java code
it is very possible to perform arbitrarily complex color calculations as
part of a style; just create a function that produces a java.awt.Color
or a string with a hex color specification.
--
David Winslow
OpenGeo - http://opengeo.org/
On 05/14/2010 01:41 PM, Ryan Zoerb wrote:
We're looking into replacing Oracle MapViewer with GeoServer, but have hit a hangup when trying to duplicate the functionality of MapViewer. Essentially, with MapViewer we can, within a style, specify a "non-spatial data provider" which is just a Java class that supplies a mapping of each feature to some value (for example, which color to draw that feature). We would like to replicate this behavior in GeoServer, but I haven't found a good way to do so. For one of our projects, we need to color each feature in a shapefile some arbitrary color which is computed from external data. In order to do this with GeoServer now, I have to 1) compute the color, 2) create an sld with one rule per feature, setting that feature's fill color to the computed value, then 3) use the rest api to send that sld to GeoServer and tell the layer to use it. Is there a better way to do this? Or is there a straightforward way we can modify GeoServer (or create/modify an extension) t
o get this functionality?
Thanks,
Ryan
------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users