How MapViewer Formulates a SQL Query for a Styling Rule

2-12 Oracle Fusion Middleware Users Guide for Oracle MapViewer In Example 2–6 , there are two styling rules associated with the Airport theme: ■ The first rule specifies that only those rows that satisfy the condition runway_ number gt; 1 that is, runway number greater than 1 will be selected, and these will be rendered using the style named c.black gray. If no value is supplied, no WHERE clause condition is applied. For example, assume that the definition had been the following that is, omitting the runway_number gt; 1 condition: ?xml version=1.0 standalone=yes? styling_rules rule features style=c.black gray label column=name style=t.airport name 1 label rule styling_rules In this case, all airport features would be selected and would be rendered using the color style named c.black gray. The first rule also has a label element, which specifies that the NAME column in the table or view will be used to annotate each airport, using the text style t.airport name. The value of the label element, which can be any SQL expression that evaluates to a numeric value, is used to determine whether or not a feature will be annotated. If the numeric value is greater than zero, the feature will be annotated. In this case, because the value is the constant 1, all features specified by the features element will be annotated, using the values in the NAME column. If the value is less than or equal to zero for a feature, that feature will not be annotated. ■ The second rule, which applies to those airports with only one runway, does not have a label element, thus preventing all such airports from being annotated. In addition, the features that satisfy the second rule will be rendered using a different style m.airplane, as specified in its features element. You can think of each styling rule as a filter into the base table or view of the theme, because it selects only a subset of the rows and applies the rendering and labeling styles of that rule. In fact, MapViewer formulates a complete SQL query for each styling rule. This query string follows a fixed format, as described in Section 2.3.1.2 .

2.3.1.2 How MapViewer Formulates a SQL Query for a Styling Rule

To see how MapViewer formulates a SQL query for a styling rule, consider the first styling rule from the airport theme example Example 2–6 in Section 2.3.1.1 : styling_rules rule features style=c.black gray runway_number gt; 1 features label column=name style=t.airport name 1 label rule . . . styling_rules MapViewer Concepts 2-13 When MapViewer processes this theme, it formulates a query string for this styling rule that looks like this: SELECT ROWID, GEOMETRY, C.BLACK GRAY, NAME, T.AIRPORT NAME, 1, rule0’ FROM AIRPORT_POINT WHERE MDSYS.SDO_FILTERGEOMETRY, MDSYS.SDO_GEOMETRY2003, 8265, NULL, MDSYS.SDO_ELEM_INFO_ARRAY1, 1003, 3, MDSYS.SDO_ORDINATE_ARRAY:mvqboxxl, :mvqboxyl, :mvqboxxh, :mvqboxyh, querytype=WINDOW = TRUE In the preceding query string: ■ The base table name of the theme, AIRPORT_POINT, appears in the FROM clause ■ The SELECT list includes ROWID as the first column. ROWID is the default key_ column attribute of a predefined theme. ■ The next column in the SELECT list is GEOMETRY. This is the geometry column of this theme. ■ The next column in the SELECT list is the literal string ‘C.BLACK GRAY’, which is the rendering style name for this rule. ■ The next column in the SELECT list is the column NAME, which will provide the label text. It is specified in the label element of this styling rule. ■ The next column in the SELECT list is the literal string ‘T.AIRPORT NAME’, which is the labeling style name specified in the label element. ■ The next column in the SELECT list is the literal value 1, which is the value of the label element itself. ■ The next column in the SELECT list is the literal string ‘rule0’. This is used internally by MapViewer only. ■ The large WHERE clause is essentially an Oracle Spatial filtering operator, SDO_ FILTER. This WHERE clause is automatically added by MapViewer and is not something you need to specify when defining a theme. It ensures that only those geographic features that are in contact with the current map viewing window will be fetched from the base table. The four binding variables, mvqboxxl, mvqboxyl, mvqboxxh and mvqboxyh, will be automatically filled in with the coordinates for the current map viewing window. MapViewer always uses the preceding format when constructing SQL queries for the styling rules of a predefined geometry theme’s styling rules. It uses different formats for the queries for other types of themes, such as a topology or GeoRaster theme. The formats for these other queries are not described here; however, if you are interested, you can set the logging level of your MapViewer instance to FINEST, submit a map request containing a particular type of theme, and check the MapViewer log file to see the exact query that MapViewer constructs. Each row or feature in the query’s result set now contains all the information MapViewer needs: the spatial data, the rendering and labeling style names, the label text, and the labeling conditions. MapViewer then constructs an in-memory feature object for each row and sends them to the rendering pipeline to be displayed on the map. If two or more styling rules are specified for a theme, a UNION ALL operation is performed on the SQL queries for the rules from first to last to fetch the qualified features from the table or view. 2-14 Oracle Fusion Middleware Users Guide for Oracle MapViewer If an advanced style is specified in a rule, the SELECT list of the query for that rule will include the additional attribute column or columns that are required by the advanced style.

2.3.1.3 Styling Rules with Binding Parameters