Selection Rendering Introduction
Originally in Weave the drawing of the current selection was always done as part of the rendering the map image, this was because originally there was only a single map layer on the client. In this situation each update of the map image included a step, on the server, where the current selection was drawn on top of the map image generated by the underlying map engine before passing the image back to the browser for display.
...
Code Block |
---|
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="urn:com.cohga.server.config#1.0" xmlns:selection="urn:com.cohga.server.map.selection#1.0">
<selection:mapengine id="selection">
<!-- Selection specific configuration if required -->
</selection:mapengine>
</config>
|
Note |
---|
The above configuration describes just what's required to setup the server side portion of the selection map engine. |
Beyond that it's also possible to change some other settings that effect selection drawing.
...
Code Block |
---|
<selection:mapengine id="selection">
<maxscale>50000</maxscale>
</selection:mapengine>
|
Limiting the drawing time
...
Code Block |
---|
<selection:mapengine id="selection">
<limit>5000</limit>
<timeout>5</timeout>
</selection:mapengine>
|
Both of these setting can help ensure a speedy map response even if the user has a large number of selected features.
...
Code Block |
---|
<selection:mapengine id="selection">
<antialiasing>false</antialiasing>
</selection:mapengine>
|
Also, since the selected features are drawn in batches you can alter the number of features that are drawn in each batch. The default batch size is 1000.
Increasing this value will will reduce the overhead that's required for each batch but sometimes there are limits on the underlying infrastructure (database or spatial engine) that limit the number of features that can be retrieved at once. You can try increasing this value and selecting more than that many features and see if the selection is still drawing, if it is then it's safe to use the new limit value, otherwise it should be reduced until a safe value is determined. There's little point in setting this value to more than the limit
value, if set.
...
Code Block |
---|
<selection:mapengine id="selection">
<batchsize>2500</batchsize>
</selection:mapengine>
|
Since there are a large number of possible image formats (in regards to bits-per-pixel, colour palettes, transparency support, etc) the selection drawing plugin will generate a new image of a known format and draw the selection on top, this way a consistent image format is produced at the end (this is mainly to handle problems experienced with earlier versions of Internet Explorer).
...
Code Block |
---|
<selection:mapengine id="selection">
<format>image/png32</format>
</selection:mapengine>
|
By default the selection map engine reports that it support 32 and 8 bit png and gif, with 32 bit png being the default if no format is specified.
Note |
---|
Prior to version 1.2.3 of the selection map engine bundle the default image format was png8 which would result in solid filled polygons (if the default fill styles were used), in version 1.2.3 of the bundle this was changed to png32. |
Info |
---|
8 bit png and gif are similar in size and image quality, 32 bit png produces the best image quality but are larger than the 8 bit formats, gif is recommended if you're sure that all of your clients will be using IE6 (in which case you should also ensure that your fill styles are all fully transparent). |
Changing colours
The rendering of the selections can also be altered by adjusting the line and fill colours and transparency, the line widths, and the point symbology.
...
Code Block |
---|
<selection:mapengine id="selection">
<override>
<point>
<active>
<strokecolour>white</strokecolour>
<strokewidth>1</strokewidth>
<strokeopacity>0</strokeopacity>
<fillcolour>cyan</fillcolour>
<fillopacity>1</fillopacity>
<mark>circle</mark>
<marksize>12</marksize>
</active>
<inactive>
<strokecolour>cyan</strokecolour>
<strokewidth>2</strokewidth>
<strokeopacity>1</strokeopacity>
<fillcolour>white</fillcolour>
<fillopacity>0</fillopacity>
<mark>circle</mark>
<marksize>12</marksize>
</inactive>
</point>
<line>
<active>
<strokecolour>cyan</strokecolour>
<strokewidth>3</strokewidth>
<strokeopacity>0.75</strokeopacity>
</active>
<inactive>
<strokecolour>#00ffff</strokecolour>
<strokewidth>2</strokewidth>
<strokeopacity>0.25</strokeopacity>
</inactive>
</line>
<polygon>
<active>
<strokecolour>#00ffff</strokecolour>
<strokewidth>3</strokewidth>
<strokeopacity>0.75</strokeopacity>
<fillcolour>#00ffff</fillcolour>
<fillopacity>0.125</fillopacity>
</active>
<inactive>
<strokecolour>#00ffff</strokecolour>
<strokewidth>2</strokewidth>
<strokeopacity>0.25</strokeopacity>
<fillcolour>#00ffff</fillcolour>
<fillopacity>0.025</fillopacity>
</inactive>
</polygon>
</override>
</selection:mapengine>
|
Overriding selection drawing type for a specific entity
...
Code Block |
---|
<selection:mapengine id="selection">
<override>
<entity id="property">polygon</entity>
<entity id="road">line</entity>
<entity id="trafficlight">point</entity>
</override>
</selection:mapengine>
|
You can use point or multipoint, line, multiline, linestring or multilinestring, and polygon or multipolygon (all values will be accepted, but they'll be interpreted as 'point', 'line' or 'polygon' regardless).
...
Code Block |
---|
<selection:mapengine id="selection">
<override>
<entity id="property">
<active>
<strokecolour>green</strokecolour>
<strokewidth>3</strokewidth>
<strokeopacity>0.75</strokeopacity>
<fillcolour>green</fillcolour>
<fillopacity>0.125</fillopacity>
</active>
<inactive>
<strokecolour>green</strokecolour>
<strokewidth>2</strokewidth>
<strokeopacity>0.25</strokeopacity>
<fillcolour>green</fillcolour>
<fillopacity>0.025</fillopacity>
</inactive>
</entity>
</override>
</selection:mapengine>
|
Advanced selection rendering
...
Code Block |
---|
<selection:mapengine id="selection">
<override>
<entity id="property">property.sld</entity>
</override>
</selection:mapengine>
|
The contents of property.sld
, which should be in the workspace
directory, should contain valid SLD XML to describe the renderer to use for the property entity.
...
Code Block |
---|
<selection:mapengine id="selection">
<override>
<entity id="property"><![CDATA[
<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>property</Name>
<UserStyle>
<!-- Rest of SLD content here -->
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
]]></entity>
</override>
</selection:mapengine>
|
There's an open source tool that can be used to create SLD files available at AtlasStyler SLD editor.
...
Code Block |
---|
<selection:mapengine id="selection">
<override>
<entity id="property">property.sld</entity>
</override>
</selection:mapengine>
|
Referencing a SLD file without override tag
Code Block |
---|
<selection:mapengine id="selection">
<entity id="property">property.sld</entity>
</selection:mapengine>
|
Drawing selections with a separate map engine on the client
Using the selection map engine requires that we add the selection map engine to the client configuration so that it is drawn on top of the existing layers.
...
Code Block |
---|
<client:config id="...">
...
<view id="com.cohga.html.client.map.mapView">
...
<mapEngine id="raster">
<options>
<selection>false</selection>
<alpha>false</alpha>
</options>
</mapEngine>
<mapEngine id="vector">
<options>
<selection>false</selection>
<alpha>true</alpha>
</options>
</mapEngine>
</mapEngine id="selection">
<options>
<!-- tell the client map engine that this layer is for handing selections -->
<selection>true</selection>
<!-- ensure the the client knows that this map engine supports transparency -->
<alpha>true</alpha>
</options>
</mapEngine>
</view>
</client:config>
|
The final step is to switch the toc model to use the new selection map engine for the selection related entries by adding a mapengine tag to the Selection entry.
Code Block |
---|
<toc:model id="toc.main">
<!-- set the default map engine for entries that don't have one set -->
<mapengine>vector</mapengine>
<entry label="Selection" exclusive="true">
<!-- change the map engine for every entry in this group to use the selection map engine-->
<mapengine>selection</mapengine>
<entry layer="_selection.active" label="Active" checked="true"/>
<entry layer="_selection.all" label="All" checked="false"/>
<entry label="Selected" checked="false">
<!-- individual selection layer here -->
...
</entry>
</entry>
<!-- regular layer entries here -->
...
<entry label="Raster" exclusive="true">
<!-- use the raster map engine for every entry in here -->
<mapengine>raster</mapengine>
...
</entry>
</toc:model>
|