| 52 | This image shows the behavior for two intersecting features which are styled using a thick line and then a thin line. At left is the result if we draw with one pass: the thick line for the vertical feature is drawn on top of the thin line for the horizontal feature. At right is the result if we use two passes: we draw all the features once with the thick line, and then draw them all again using the thin line. |
| 53 | |
| 54 | The current symbol definition schema allows rendering passes (RP's) to be specified in a !CompoundSymbolDefinition. The example above could be done using a !CompoundSymbolDefinition containing thick and thin line style symbols, with the RP's for the thick / thin lines set to 0 / 1. |
| 55 | |
| 56 | The main benefit of this approach is that the RP pass information is stored with the symbol definition: there's no need to respecify it when referencing this symbol in a layer. |
| 57 | |
| 58 | The approach, however, does have some drawbacks: |
| 59 | |
| 60 | * Rendering passes can only be used by defining compound symbol definitions |
| 61 | * Mixing compound symbols that define RPs with other symbols is problemmatic |
| 62 | |
| 63 | Here's an example that clarifies the latter drawback. I want to create a layer which shows roads and pedestrian walkways. I have custom symbols already defined for the roads and walkways - both are compound symbols that have thick and thin line styles defined using RP 0 and 1. I set up my layer so that features of type "road" are styled using the Road symbol, while features of type "walkway" are styled using the Walkway symbol. I also have the requirement that walkways need to draw on top of roads. With the symbols defined as is this won't work. The first rendering pass - pass 0 - will iterate over all features and draw the thick Road lines and then the thick Walkway lines. The second rendering pass will then draw the thin Road lines and the thin Walkway lines. In places where walkway features intersect road features, the thin Road lines drawn in RP 1 will end up drawing on top of the thick Walkway lines drawn in RP 0. |
| 64 | |
| 65 | We could easily fix this by editing the Walkway symbol to use RP 2 and 3, but then this also affects other layers in other maps that use the Walkway symbol. I may then have to adjust RP values for yet other symbols. Or maybe the Walkway symbol is part of a symbol library that I purchased, and I don't want to change it. |
| 66 | |
| 67 | Another use case where the current schema's support for rendering passes is insufficient is when a user wants to build up a composite line style from predefined symbols. !MapGuide Studio, for example, provides UI to do this. If the user only works with !SimpleSymbolDefinitions, then this could be done by creating an inlined !CompoundSymbolDefinition that references all of the simple symbols and sets the appropriate RP values. This approach doesn't work, however, if the user wants to include a !CompoundSymbolDefinition in his composite style. That's because we can't add a reference to his !CompoundSymbolDefinition in the inlined !CompoundSymbolDefinition - by design compound symbols can only reference simple symbols. |
| 68 | |
| 69 | The proposed solution to this is simple: add a !RenderingPass element to !SymbolInstance, so that we now have two levels of rendering passes. The algorithm is straightforward. We start the layer stylization with symbol instance rendering pass 0, and only instances with their RP set to 0 are enabled for this pass. We then stylize / draw using the symbol definitions for this set of instances, making as many sub-rendering passes as necessary based on the RP values of these symbol definitions. We then move to the next symbol instance rendering pass. Again we only consider symbol instances / symbol definitions for this pass, and do sub-rendering passes as necessary. This is continued until all necessary symbol instance RPs have been made. |
| 70 | |
| 71 | With this approach, I would configure the layer for the road / walkway example like the following: |
| 72 | |
| 73 | * !SymbolInstance A |
| 74 | * reference to Road symbol |
| 75 | * intance RP set to 0 |
| 76 | |
| 77 | * !SymbolInstance B |
| 78 | * reference to Walkway symbol |
| 79 | * intance RP set to 1 |
| 80 | |
| 81 | At stylization time, this would result in the following sequence of passes: |
| 82 | |
| 83 | * Instance RP 0 |
| 84 | * Road symbol RP 0 |
| 85 | * Road symbol RP 1 |
| 86 | * Instance RP 1 |
| 87 | * Walkway symbol RP 0 |
| 88 | * Walkway symbol RP 1 |