2.5 How a Map Is Generated

When a map request arrives at the map visualization component server, the server picks a free renderer associated with the data source in the request.

This topic describes the process that the map visualization component server follows to generate a map. In brief, the map visualization component performs the following steps:

  1. Parse and process the incoming XML map request.

  2. Prepare the data for each theme (executed in parallel).

  3. Render and label each theme.

  4. Generate final images or files.

Each map generated by the map visualization component results from its receiving a valid XML map request. The XML map request is parsed and its content is validated. The map visualization component then creates any dynamic styles specified in the XML request. It builds a theme list from all themes included in the base map (if a base map is specified), as well as any specified predefined or JDBC themes. All individual features in the request are grouped into a single temporary theme. In other words, after parsing the incoming request, all data that must be shown on the map is presented in a list of themes to the map visualization component rendering engine.

The ordering of the themes in the list is important, because it determines the order in which the themes are rendered. All themes included in the base map (when present) are added to the list first, followed by all specified themes (predefined or JDBC). The theme that contains all the individual features is added as the last theme on the list. Any other requested features of a map (such as legend, map title, or footnote), are created and saved for rendering later.

For each theme in the request, the map visualization component then creates a separate execution thread to prepare its data, so that preparation of the themes takes place in parallel. For a predefined theme, this means formulating a query based on the theme's definition and any other information, such as the current map request window. This query is sent to the database for execution, and the result set is returned. The map visualization component creates individual renderable objects based on the result set.

  • For predefined themes that are fully cached, no query is sent to the database, because all renderable objects are readily available.

  • For JDBC themes, the query supplied by the user is either executed as is (when the asis attribute value is TRUE in the JDBC theme definition) or with a spatial filter subquery automatically applied to it. The spatial filter part is used to limit the results of the user's query to those within the current requested window.

  • For themes that already have renderable features (such as the one containing all individual features in a request), there is no need to create renderable objects.

After all themes for the map request have been prepared and all necessary data has been collected, the map visualization component starts to render the map. It creates an empty new in-memory image to hold the result map, and paints the empty image with the necessary backgrounds (color or image). It then renders all of the themes in the theme list.

Note:

All image or GeoRaster themes are always rendered first, regardless of their position in the theme list. All other themes, however, are rendered in the order in which they appear in the theme list.

For each theme, features are rendered in an order determined internally by the map visualization component. The rendering of each feature involves invoking the drawing methods of its rendering style. After all themes have been rendered, the labeling process starts. For each theme whose features must be labeled with text, the map visualization component invokes algorithms to label each feature, with the specific algorithm depending on the type of feature (such as polygon or line).

After all themes have been rendered and (when needed) labeled, the map visualization component plots any additional map features (such as a legend) on the internal map image. The map visualization component then converts that image into the desired format (such as PNG or GIF) specified in the original map request; however, for SVG maps, instead of using an internal image, the map visualization component initially creates an empty SVG map object, then creates an SVG document as a result of the rendering process, and inserts it into the map object.