Oracle® Application Server MapViewer User's Guide
10g Release 2 (10.1.2) B14036-02 |
|
Previous |
Next |
This chapter explains concepts that you should be familiar with before using OracleAS MapViewer.
Some fundamental concepts include style, theme, base map, mapping metadata, and map.
Styles define rendering properties for features that are associated with styles. For example, a text style determines how such a feature is labeled on a map, while a line style determines the rendition of a linear feature such as a road.
A theme is a collection of features (entities with spatial and nonspatial attributes) that are associated with styles through the use of styling rules.
A base map consists of one or more themes.
Mapping metadata consists of a repository of styles, themes, and base maps stored in a database.
A map is one of the components that OracleAS MapViewer creates in response to a map request. The map can be an image file, the object representation of an image file, or a URL referring to an image file.
This chapter contains the following major sections:
When an application uses OracleAS MapViewer, it applies specific styles (such as colors and patterns) to specific themes (that is, collections of spatial features, such as cities, rivers, and highways) to render a map (such as a GIF image for display on a Web page). For example, the application might display a map in which state parks appear in green and restaurants are marked by red stars. A map typically has several themes representing political or physical entities, or both. For example, a map might show national and state boundaries, cities, mountain ranges, rivers, and historic sites. When the map is rendered, each theme represents a layer in the complete image.
OracleAS MapViewer lets you define styles, themes, and base maps, including the rules for applying one or more styles to each theme. These styles, themes, base maps, and associated rules are stored in the database in map definition tables under the MDSYS schema, and they are visible to you through metadata views. All styles in a database instance are shared by all users. The mapping metadata (the set of styles, themes, and base maps) that you can access is determined by the OracleAS MapViewer metadata views described in Section 2.8 (for example, USER_SDO_STYLES, USER_SDO_THEMES, and USER_SDO_MAPS). The set of map definition objects that a given user can access is sometimes called that user's mapping profile. You can manage styles, themes, and base maps with the Map Definition Tool, described in Chapter 7.
A style is a visual attribute that can be used to represent a spatial feature. The basic map symbols and labels for representing point, line, and area features are defined and stored as individual styles. Each style has a unique name and defines one or more graphical elements in an XML syntax.
Each style is of one of the following types:
Color: a color for the fill or the stroke (border), or both.
Marker: a shape with a specified fill and stroke color, or an image. Markers are often icons for representing point features, such as airports, ski resorts, and historical attractions.
When a marker style is specified for a line feature, the rendering engine selects a suitable point on the line and applies the marker style (for example, a shield marker for a U.S. interstate highway) to that point.
Line: a line style (width, color, end style, join style) and optionally a center line, edges, and hash mark. Lines are often used for linear features such as highways, rivers, pipelines, and electrical transmission lines.
Area: a color or texture, and optionally a stroke color. Areas are often used for polygonal features such as counties and census tracts.
Text: a font specification (size and family) and optionally highlighting (bold, italic) and a foreground color. Text is often used for annotation and labeling (such as names of cities and rivers).
Advanced: a composite used primarily for thematic mapping, which is described in Section 2.3.3. The key advanced style is BucketStyle
, which defines the relationship between a set of simple rendering (and optionally labeling) styles and a set of buckets. For each feature to be plotted, a designated value or set of values from that feature is used to determine which bucket the feature falls into, and then the style associated with that bucket is used to plot the feature.
The AdvancedStyle
class is extended by BucketStyle
, which is in turn extended by ColorSchemeStyle
and VariableMarkerStyle
. (Additional advanced styles, such as for charts, are planned for a future release.)
Table 2-1 lists the applicable geometry types for each type of style.
Table 2-1 Style Types and Applicable Geometry Types
Style Type | Applicable Geometry Types |
---|---|
Color |
(any type) |
Marker |
point, line |
Line |
line |
Area |
polygon |
Text |
(any type) |
Advanced |
(any type) |
All styles for a database user are stored in that user's USER_SDO_STYLES view, which is described in Section 2.8 and Section 2.8.3.
You can also create dynamically defined styles (that is, temporary styles) of any style type as part of a map request. To create a dynamically defined style, define the style using its XML elements within the <map_request>
element. (You can also use the JavaBean API to add a dynamically defined style to a map request, as explained in Section 4.3.4.) OracleAS MapViewer creates dynamically defined styles from these definitions when it processes the map request, and it discards the dynamically defined styles when the request is completed.
For more detailed information about the types of styles, including information about the XML format for defining each type, see Appendix A.
For collection-based bucket styles and individual range-based bucket styles (described in Section A.6.1.1 and Section A.6.1.2, respectively), you can specify a labeling style by using the label_style
attribute in each bucket element. Example 2-1 creates an advanced style named V.RB1
in which each bucket is assigned a text label style (using the label_style
attribute), with some styles being used for several buckets.
Example 2-1 Advanced Style with Text Label Style for Each Bucket
<?xml version="1.0" ?> <AdvancedStyle> <BucketStyle> <Buckets> <RangedBucket seq="0" label="10k or less" high="10000" style="c.rb13_1" label_style="T.AIRPORT NAME"/> <RangedBucket seq="1" label="10k - 20k" low="10000" high="20000" style="c.rb13_2" label_style="T.CITY NAME"/> <RangedBucket seq="2" label="20k - 30k" low="20000" high="30000" style="c.rb13_3" label_style="T.CITY NAME"/> <RangedBucket seq="4" label="30k - 40k" low="30000" high="40000" style="c.rb13_4" label_style="T.CITY NAME"/> <RangedBucket seq="5" label="40k - 50k" low="40000" high="50000" style="c.rb13_5" label_style="T.CITY NAME"/> <RangedBucket seq="6" label="50k - 75k" low="50000" high="75000" style="c.rb13_6" label_style="T.ROAD NAME"/> <RangedBucket seq="7" label="75k - 100k" low="75000" high="100000" style="c.rb13_7" label_style="T.PARK NAME"/> <RangedBucket seq="8" label="100k - 125k" low="100000" high="125000" style="c.rb13_8" label_style="T.RED STREET"/> <RangedBucket seq="9" label="125k - 250k" low="125000" high="250000" style="c.rb13_9" label_style="T.ROAD NAME"/> <RangedBucket seq="10" label="250k - 450k" low="250000" high="450000" style="c.rb13_10" label_style="T.ROAD NAME"/> <RangedBucket seq="11" label="450k - 650k" low="450000" high="650000" style="c.rb13_11" label_style="T.ROAD NAME"/> <RangedBucket seq="12" label="650k up" low="650000" style="c.rb13_13"/> </Buckets> </BucketStyle> </AdvancedStyle>
For individual range-based buckets, the lower-bound value is inclusive, while the upper-bound value is exclusive (except for the range that has values greater than any value in the other ranges; its upper-bound value is inclusive). No range is allowed to have a range of values that overlaps values in other ranges.
If the V.RB1
style in Example 2-1 is used in a map request, it displays a map that might look like the display in Figure 2-1, where the county names are shown with labels that reflect various text styles (in this case depending on the county's total population).
Figure 2-1 Varying Label Styles for Different Buckets
In Example 2-1, all buckets except the last one specify a label style. For any features that fall into a bucket that has no specified label style, the label style (if any) applied to the feature depends on the following:
If the <label>
element of the theme's styling rules specifies a label style other than the advanced style itself, the specified label style is used to label the feature. In the following example, because the <label>
element's style specification (T.STATE_NAME
) is different from the <features>
element's style specification (V.RB1
), features that fall into a bucket with no specified label style are labeled using the T.STATE_NAME
style:
<?xml version="1.0" standalone="yes"?> <styling_rules> <rule column="TOTPOP"> <features style="V.RB1"> </features> <label column="county" style="T.STATE NAME"> 1 </label> </rule> </styling_rules>
If the <label>
element of the theme's styling rules specifies the advanced style as its label style, the feature is not labeled. (This is why some counties in Figure 2-1 are not labeled.) In the following example, because the <features>
and <label>
elements both specify the advanced style V.RB1
, features that fall into a bucket with no specified label style are not labeled:
<?xml version="1.0" standalone="yes"?> <styling_rules> <rule column="TOTPOP"> <features style="V.RB1"> </features> <label column="county" style="V.RB1"> 1 </label> </rule> </styling_rules>
You can control the orientation of text labels and markers on a map by using oriented points. The oriented point is a special type of point geometry introduced in Oracle Spatial for Oracle Database 10g Release 1 (10.1). In an oriented point, the coordinates represent both the location of the point and a virtual end point, to indicate an orientation vector. The text is aligned or the marker symbol is rotated according to the orientation vector, which is explained in Section 3.2.5 and illustrated in Figure 3-3 in that section. For more information about oriented points, see Oracle Spatial User's Guide and Reference.
To orient the text label of a point in the direction of an orientation vector, you can specify the point as an Oracle Spatial oriented point in the map request. When OracleAS MapViewer labels an oriented point, it automatically centers the text label on the point position, and aligns the label so that it points in the direction of the orientation vector.
For each feature to be so labeled, you must specify its location as an oriented point. You can group these oriented points in a single table and create a spatial index on the column containing the point geometries. You can then create a theme based on the table, specifying a desired text style as the labeling, and specifying transparent color style as the rendering style so that the points themselves are not displayed on the map.
Example 2-2 is a map request that labels a single oriented point with coordinates (12,14, 0.3,0.2), where (12,14) represents the X and Y coordinates of the point and (0.3,0.2) represents the orientation vector. It renders the point using a dynamically defined transparent color style (named transparent_color
) to ensure that the text is displayed but the underlying point is not displayed.
Example 2-2 Labeling an Oriented Point
<map_request title="Labeling Oriented Points" datasource="my_datasource" width="400" height="300" antialiase="true" format="PNG_STREAM"> <themes> <theme name="theme1"> <jdbc_query spatial_column="geom" jdbc_srid="8265" render_style="transparent_color" label_column="label" label_style="t.street name" datasource="tilsmenv"> SELECT MDSYS.SDO_GEOMETRY(2001, 8265, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1, 1, 3, 1, 0), MDSYS.SDO_ORDINATE_ARRAY(12, 14, .3, .2)) geom, 'Oriented Point' label FROM dual </jdbc_query> </theme> </themes> <styles> <style name="transparent_color"> <svg width="1in" height="1in"> <g class="color" style="stroke:#ff0000;stroke-opacity:0"> <rect width="50" height="50"/> </g> </svg> </style> </styles> </map_request>
Figure 2-2 shows part of the map generated by the request in Example 2-2. (The label is the phrase Oriented Point.)
Figure 2-2 Map Display of the Label for an Oriented Point
When a marker style is applied to an oriented point, OracleAS MapViewer automatically rotates the marker style so that it points to the orientation vector. Any necessary rotation of the marker style is around the center of the marker.
Figure 2-3 shows how you can use an oriented point to control the orientation of marker styles. In this figure, the original marker style is first shown without any rotation. However, when the marker is applied to the same oriented point shown in Example 2-2 in Section 2.2.2.1, the marker style is rotated accordingly (in this case about 34 degrees counterclockwise) to reflect the orientation vector.
A theme is a visual representation of a particular data layer. Typically, a theme is associated with a spatial geometry layer, that is, with a column of type SDO_GEOMETRY in a table or view. For example, a theme named US_STATES
might be associated with a column named GEOMETRY in a STATES table. Other types of themes include the following:
Image themes, which are associated with georeferenced images
GeoRaster themes, which are associated with Oracle Spatial GeoRaster data
Network themes, which are associated with networks in the Oracle Spatial network data model
Topology themes, which are associated with topologies in the Oracle Spatial topology data model
When you define a theme, you must specify a base table or view, a spatial data column in that table or view, and a set of styling rules. For a predefined theme (described in Section 2.3.1), the definition is permanently stored in the database. However, you can also dynamically define a theme (that is, create a JDBC theme, described in Section 2.3.2) by supplying the definition within a map request.
If a theme is associated with a spatial layer geometry in a view, the view can be based on one or more tables. However, if the view is based on two or more tables (that is, if it is a join view), you must specify the key_column
attribute (described in Section A.7) in the STYLING_RULES column definition in the USER_SDO_THEMES view. The following example specifies the column named GID in the join view named VIEW_THEME for the key_column
attribute:
UPDATE user_sdo_themes SET styling_rules= '<?xml version="1.0" standalone="yes"?> <styling_rules key_column="gid"> <rule> <features style="L.PH"/> <label column="label" style="M.FLASH_SHIELD1">1</label> </rule> </styling_rules>' WHERE name='VIEW_THEME';
A predefined theme is a theme whose definition is stored in a user's database schema. All predefined themes for a database user are stored in that user's USER_SDO_THEMES view (described in Section 2.8, especially Section 2.8.2). When you specify a predefined theme in a map request, you need to specify only the theme name. OracleAS MapViewer automatically finds the theme's definition, constructs a query based on it, retrieves the relevant spatial and attribute data, and renders the theme according to the styling rules for the theme.
Each predefined theme must have an associated base table or view. If you base a theme on a view, you must insert a row in the view owner's USER_SDO_GEOM_METADATA view (described in Oracle Spatial User's Guide and Reference) specifying the view and its spatial column. If the view is a join view (that is, if it is based on multiple tables), you must specify the key_column
attribute (described in Section A.7) in the theme's styling rules. The reason for this requirement is that OracleAS MapViewer by default caches geometries for a predefined theme based on the rowid in the base table; however, for a join view there is no ROWID pseudocolumn, so you must specify a key column.
For many themes (but not for GeoRaster, network, or topology themes), you can use the graphical Map Definition Tool predefined themes of varying complexity. For information about the Map Definition Tool, see Chapter 7.
Each predefined theme is associated with one or more styling rules, specifications in XML format that control aspects of how the theme is displayed. This section describes styling rules for predefined spatial geometry themes, such as the airport theme shown in Example 2-3. Other types of themes, such as image, GeoRaster, network, and topology themes, have their own distinct styling rules requirements, and these are discussed in sections that explain these themes. However, the styling rules for all types of themes are grouped under the <styling_rules>
element in an XML document, which is stored in the STYLING_RULES column for each predefined theme in the USER_SDO_THEMES view. (The <styling_rules>
DTD is described in Section A.7.)
Note: The following naming conventions are used for prefixes in style names in the examples in this chapter:v. indicates variable (advanced style), m. indicates marker, c. indicates color, l. indicates line, and t. indicates text. (If the style is not under the current user's schema, you must specify the owner's schema name followed by a colon. For example: mdsys:c.red .)
In the content (character data) of an XML document, |
Example 2-3 XML Definition of Styling Rules for an Airport Theme
<?xml version="1.0" standalone="yes"?> <styling_rules> <rule> <features style="c.black gray"> runway_number > 1 </features> <label column="name" style="t.airport name"> 1 </label> </rule> <rule> <features style="m.airplane"> runway_number = 1 </features> </rule> </styling_rules>
Each styling rule has a required <features>
element and an optional <label>
element. The <features>
element specifies which row or rows (features) in the table or view will be selected based on the attribute value, and the style to be used for the selected features. The <label>
element specifies whether or not to annotate the selected features, and if so, which column in the table or view to use for text labels.
In Example 2-3, there are two styling rules associated with the Airport
theme:
The first rule specifies that only those rows that satisfy the condition runway_number > 1
(that is, runway number greater than 1) will be selected, and these will be rendered using the style named c.black gray
. Any conditions that are valid in a SQL WHERE clause can be used as the value of a <features>
element. 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 > 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, is used to determine whether or not a feature will be annotated. If the 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.
If two or more rules are specified, 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.
If an advanced style is specified in a rule, the SELECT list of the query to fetch qualified features contains the spatial column, the attribute column or columns, the name of the feature style, the label information, the WHERE clause, and the feature query. Based on the value of the attribute column or columns and the definition of the specified feature style, each feature is associated with a style.
By default, OracleAS MapViewer automatically caches the spatial data for a predefined theme when it is fetched from the database for processing by the OracleAS MapViewer rendering engine. By contrast, data for dynamic (JDBC) themes is never cached in OracleAS MapViewer. If you do not want any data for a predefined theme to be cached (such as for a theme whose underlying base table is constantly being updated), you can set the caching
attribute to NONE
in the <styling_rules>
element for the theme. (The <styling_rules>
element, including the caching
attribute, is described in Section A.7.)
For frequently used themes whose base data is static or read-only, specify caching ALL
for the best performance. This causes OracleAS MapViewer, when it first accesses the theme definition, to fetch all the features (including spatial data, attribute data, and styling information associated with them) and cache them in the OracleAS MapViewer memory, creating an in-memory R-tree for the theme's spatial data. All subsequent requests requiring that theme occur locally instead of going to the database.
If the caching
attribute value is NORMAL
(the default), each time a map involving that theme is requested, OracleAS MapViewer queries the database to get the spatial data and any associated attribute data. However, if any of the spatial geometry data, as referenced by rowid or a user-specified key column, has already been cached, the unpickling process (the conversion from the raw database geometry format to a Java geometry object) is skipped. Still, if memory is not an issue and if a frequently used theme can completely fit in the cache, you should specify caching ALL
, to eliminate virtually all database access for that theme after the initial loading.
Because the OracleAS MapViewer spatial data cache is global, all predefined themes that are accessed by OracleAS MapViewer compete for a global fixed-sized memory cache. The cache resides completely in memory, and you can specify the maximum size of the cache as explained in Section 1.5.6. When the cache limit is reached, older cached data is removed from the cache to make room for the most recently accessed data, except that data for themes specified with caching ALL
is not removed from the cache, and OracleAS MapViewer does not requery the database for these themes.
A JDBC theme is a theme that is dynamically defined with a map request. JDBC themes are not stored permanently in the database, as is done with predefined themes.
For a JDBC theme, you must specify a valid SQL query that retrieves all the necessary spatial data (geometries or other types of data, such as image, GeoRaster, network, or topology). If attribute data is needed, such as for thematic mapping or spatial data analysis, the query must also select it. In other words, you must provide a correct and complete query for a JDBC theme. In addition to the query, you can also specify the rendering and labeling styles to be used for the theme.
For a JDBC theme based on spatial geometries, OracleAS MapViewer processed the columns specified in the query according to the following rules:
The column of type SDO_GEOMETRY is treated as the spatial data column.
Any column whose name or alias matches that specified in the JDBC theme's label_column
attribute is treated as the labeling column, whose values are used as text for labels.
Any other columns are treated as attribute data columns, which may or may not be used by OracleAS MapViewer. For example, if the rendering style is an advanced style, any attribute columns are processed by that style in the order in which they appear in the SELECT list in the query. Thus, if you are performing thematic mapping and using an advanced style, you must specify all attribute columns that are needed for the thematic mapping, in addition to the geometry column and optional labeling column. (A labeling column can also be an attribute column, in which case you do not need to specify that column in the SELECT list.)
Example 2-4 is a map request that includes a JDBC theme.
Example 2-4 JDBC Theme in a Map Request
<?xml version="1.0" standalone="yes"?> <map_request title="My MAP" datasource = "mvdemo"> <themes> <theme name="jdbc_theme_1"> <jdbc_query datasource="mvdemo" jdbc_srid="41052" spatial_column="geometry" render_style="C.RED"> SELECT geometry from states where name='MA' </jdbc_query> </theme> </themes> </map_request>
The full query that OracleAS MapViewer executes for the JDBC theme in Example 2-4 is:
SELECT geometry FROM states WHERE name='MA';
For this request, OracleAS MapViewer generates a map that contains only the selected geometry as a result of executing this JDBC theme's query. In a more typical case, however, the map request will need to use several JDBC themes to plot additional dynamic data on top of the base map. Furthermore, the map request may have a query window associated with it; that is, the user may want to see only a portion of the area included in the whole base map. In this case, the SQL queries in the JDBC themes will be subjected to a spatial window query, to eliminate any unwanted results.
For more information about JDBC themes, see the information about the <jdbc_query>
element in Section 3.2.9.
Sometimes the SQL query for a JDBC theme is so complex that you may want to save the query. In such cases, you can define a predefined theme (whose definition is stored in the database's USER_SDO_THEMES view), and then include the full SQL query as the content of the <features>
element in the styling rules for that theme.
The feature style specified in the <features>
element is then used to render the geometries retrieved using the full query. The base table as defined for such a theme is ignored because the full SQL query already includes a FROM clause. The geometry column defined in the USER_SDO_THEMES view is still needed, and it must be the same as the geometry column selected in the user-supplied SQL query. If you have a <label>
element for a styling rule, the label style specified is used to label the geometries, as long as the query selects a column that contains label text.
Example 2-5 is a sample <styling_rules>
element of a predefined theme with a complex SQL query.
Example 2-5 Complex Query in a Predefined Theme
<?xml version="1.0" standalone="yes"?> <styling_rules> <rule> <features style="L.POOR_ROADS" asis="true"> select sdo_lrs.clip_geom_segment(geometry,start_measure,end_measure) geometry from (select /*+ no_merge use_hash(a b) */ a.street_id, name, start_measure, end_measure, geometry from (select /*+ no_merge */ a.street_id, name, geometry from philly_roads a where sdo_filter(geometry,sdo_geometry(2002,41124,null, sdo_elem_info_array(1,2,1), sdo_ordinate_array(?,?,?,?)), 'querytype=window')='TRUE') a, philly_road_conditions b where condition='POOR' and a.street_id = b.street_id) </features> </rule> </styling_rules>
Even though Example 2-5 is defined as a predefined theme, OracleAS MapViewer still treats it as a JDBC theme at run time when a user requests a map that includes this theme. As with a normal JDBC theme, OracleAS MapViewer by default imposes a window filtering process (if a query window was included in the map request) on top of the SQL query. To override this default behavior and have the supplied query string executed without any modification, specify asis="true"
in the <features>
element, as shown in Example 2-5. (For information about the asis
attribute, see Section 3.2.9.)
Thematic mapping refers to the drawing of spatial features based on their attribute values. OracleAS MapViewer uses thematic mapping to create maps in which colors or symbols are applied to features to indicate their attributes. For example, a Counties
theme can be drawn using colors with different hues that map directly to the population density of each county, or an Earthquakes
theme can be plotted with filled circles whose sizes map to the scale or damage of each earthquake.
To achieve thematic mapping, you must first create an advanced style that is suitable for the type of thematic map, and then create a theme for the features specifying the advanced style as the rendering style. In the styling rules for the theme, you must also specify attribute columns in the table or view whose values will be used to determine exactly how a feature will be rendered thematically by the advanced style.
For example, assume that you wanted to display a map in which the color used for each region reflects the level of sales for a particular product. To do this, create an advanced style that defines a series of individual range-based buckets (see Section A.6.1.2), where each bucket contains a predefined range of sales values for a product, and each bucket has an associated rendering style. (Each region will be rendered using the style associated with the range in which that region's sales value falls.) Also specify the name of the column or columns that provide the attribute values to be checked against the ranges. In other words, the advanced style defines how to map regions based on their sales values, and the theme's styling rules tie together the advanced style and the attribute column containing the actual sales values.
Figure 2-4 shows the relationship between an advanced style and a theme, and how the style and the theme relate to the base table. In this figure, the advanced style named V.SALES
defines the series of buckets. The predefined theme named SALES_BY_REGION
specified the V.SALES
style in its styling rules. The theme also identifies the SALES column in the REGIONS table as the column whose value is to be compared with the bucket ranges in the style. (Each bucket could be associated with a labeling style in addition to or instead of a rendering style, as explained in Section 2.2.1.)
Figure 2-4 Thematic Mapping: Advanced Style and Theme Relationship
In addition to the individual range-based buckets shown in Figure 2-4, OracleAS MapViewer supports other bucket styles, as explained in Section A.6.1. You can also use more than one attribute column for thematic mapping, such as when drawing pie charts (explained in Section 3.1.9).
The rest of this section presents additional examples of thematic mapping.
Example 2-6 is the XML definition for an Earthquakes
theme.
Example 2-6 XML Definition of Styling Rules for an Earthquakes Theme
<?xml version="1.0" standalone="yes"?> <styling_rules theme_type="nature"> <rule column="RICHTER_SCALE"> <features style="v.earthquakes"> </features> </rule> </styling_rules>
The theme in Example 2-6 has only one rule. The <rule>
element includes an attribute named column
that does not appear in the Airport
theme in Example 2-3. The column
attribute specifies one or more columns (comma-delimited) that provide the attribute values needed for thematic mapping. The style specified for the <features>
element is named v.earthquakes
, and it is an advanced style.
Another part of the definition of the Earthquakes
theme specifies the table that contains the data to be rendered. This table must contain a column named RICHTER_SCALE in addition to a column (of type SDO_GEOMETRY) for the spatial data. (The table and the column of type SDO_GEOMETRY must be identified in the BASE_TABLE and GEOMETRY_COLUMN columns, respectively, of the USER_SDO_THEMES view, which is described in Section 2.8.2.) The RICHTER_SCALE column must be of type NUMBER. To understand why, look at the advanced style definition in Example 2-7.
Example 2-7 Advanced Style Definition for an Earthquakes Theme
<?xml version="1.0" ?> <AdvancedStyle> <VariableMarkerStyle basemarker="m.circle" startsize="7" increment="4"> <Buckets> <RangedBucket seq="0" label="less than 4" high="4"/> <RangedBucket seq="1" label="4 - 5" low="4" high="5"/> <RangedBucket seq="2" label="5 - 6" low="5" high="6"/> <RangedBucket seq="3" label="6 - 7" low="6" high="7"/> <RangedBucket seq="4" label="7 and up" low="7"/> </Buckets> </VariableMarkerStyle> </AdvancedStyle>
This style specifies that the marker named m.circle
is used to indicate the location of an earthquake. The size of the marker to be rendered for an earthquake depends on the numeric value of the RICHTER_SCALE column for that row. In this example there are five buckets, each covering a predetermined range of values. For example, if an earthquake is of magnitude 5.7 on the Richter scale, the marker size will be 15 pixels (7 + 4 + 4), because the value 5.7 falls in the third bucket (5 - 6) and the starting marker size is 7 pixels (startsize="7"
) with an increment of 4 for each range (increment="4"
).
Example 2-7 used the <VariableMarkerStyle>
tag. The following examples use the <ColorSchemeStyle>
tag in creating thematic maps of census blocks in California. Example 2-8 illustrates the use of a graduated color scale for a thematic mapping of population density. Example 2-9 is a thematic mapping of average household income using a graduated color scale. Example 2-10 is also a thematic mapping of average household income, but it uses a specific color style for each income range rather a graduated scale.
Example 2-8 Mapping Population Density Using a Graduated Color Scheme
# ca pop density usbg_hhinfo <?xml version="1.0" standalone="yes"?> <styling_rules theme_type="political"> <rule column="densitycy"> <features style="v.CA Pop density"> </features> </rule> </styling_rules>
The table named USBG_HHINFO includes a column named DENSITYCY (used in Example 2-8). The definition of the style (v.CA Pop density
) that corresponds to this population density theme is as follows:
<?xml version="1.0" ?> <AdvancedStyle> <ColorSchemeStyle basecolor="#ffff00" strokecolor="#00aaaa"> <Buckets low="0.0" high="20000.0" nbuckets="10"/> </ColorSchemeStyle> </AdvancedStyle>
The base color (basecolor
) and the stroke color (strokecolor
) are 24-bit RGB (red-green-blue) values specified using a hexadecimal notation. The base color value is used for the first bucket. The color value for each subsequent bucket is obtained by first converting the base color from the RGB to the HSB (hue-saturation-brightness) model and then reducing the brightness by a fixed increment for each bucket. Thus, the first bucket is the brightest and the last is the darkest.
As in Example 2-8, Example 2-9 illustrates the use of a base color and a graduated color scheme, this time to show household income.
Example 2-9 Mapping Average Household Income Using a Graduated Color Scheme
<?xml version="1.0" standalone="yes"?> <!-- # ca hh income theme table = usbg_hhinfo --> <styling_rules> <rule column="avghhicy"> <features style="v.ca income"> </features> </rule> </styling_rules>
The table named USBG_HHINFO includes a column named AVGHHICY (used in Example 2-9 and Example 2-10). The definition of the style (v.ca income
) that corresponds to this average household income theme is as follows:
<?xml version="1.0" ?> <AdvancedStyle> <ColorSchemeStyle basecolor="#ffff00" strokecolor="#00aaaa"> <!-- # income range with a color gradient --> <Buckets> <RangedBucket seq="0" label="less than 10k" high="10000"/> <RangedBucket seq="1" label="10-15k" low="10000" high="15000"/> <RangedBucket seq="2" label="15-20k" low="15000" high="20000"/> <RangedBucket seq="3" label="20-25k" low="20000" high="25000"/> <RangedBucket seq="4" label="25-35k" low="25000" high="35000"/> <RangedBucket seq="5" label="35-50k" low="35000" high="50000"/> <RangedBucket seq="6" label="50-75k" low="50000" high="75000"/> <RangedBucket seq="7" label="75-100k" low="75000" high="100000"/> <RangedBucket seq="8" label="100-125k" low="100000" high="125000"/> <RangedBucket seq="9" label="125-150k" low="125000" high="150000"/> <RangedBucket seq="10" label="150-250k" low="150000" high="250000"/> <RangedBucket seq="11" label="250-500k" low="250000" high="500000"/> <RangedBucket seq="12" label="500k and up" low="500000"/> </Buckets> </ColorSchemeStyle> </AdvancedStyle>
For individual range-based buckets, the lower-bound value is inclusive, while the upper-bound value is exclusive (except for the range that has values greater than any value in the other ranges; its upper-bound value is inclusive). No range is allowed to have a range of values that overlaps values in other ranges.
Example 2-10 uses specific color styles for each average household income range.
Example 2-10 Mapping Average Household Income Using a Color for Each Income Range
<?xml version="1.0" standalone="yes"?> <!-- # ca hh income theme table = usbg_hhinfo --> <styling_rules> <rule column="avghhicy"> <features style="v.ca income 2"> </features> </rule> </styling_rules>
The definition of the v.ca income 2
style is as follows:
<?xml version="1.0" ?> <AdvancedStyle> <BucketStyle> <Buckets> <!-- # income ranges with specific colors --> <RangedBucket seq="0" label="less than 10k" high="10000" style="c.rb13_1"/> <RangedBucket seq="1" label="10-15k" low="10000" high="15000" style="c.rb13_2"/> <RangedBucket seq="2" label="15-20k" low="15000" high="20000" style="c.rb13_3"/> <RangedBucket seq="3" label="20-25k" low="20000" high="25000" style="c.rb13_4"/> <RangedBucket seq="4" label="25-35k" low="25000" high="35000" style="c.rb13_5"/> <RangedBucket seq="5" label="35-50k" low="35000" high="50000" style="c.rb13_6"/> <RangedBucket seq="6" label="50-75k" low="50000" high="75000" style="c.rb13_7"/> <RangedBucket seq="7" label="75-100k" low="75000" high="100000" style="c.rb13_8"/> <RangedBucket seq="8" label="100-125k" low="100000" high="125000" style="c.rb13_9"/> <RangedBucket seq="9" label="125-150k" low="125000" high="150000" style="c.rb13_10"/> <RangedBucket seq="10" label="150-250k" low="150000" high="250000" style="c.rb13_11"/> <RangedBucket seq="11" label="250-350k" low="250000" high="350000" style="c.rb13_12"/> <RangedBucket seq="12" label="350k and up" low="350000" style="c.rb13_13"/> </Buckets> </BucketStyle> </AdvancedStyle>
Each <RangedBucket>
definition has a specified style.
The following examples create an advanced style to identify gasoline stations operated by different oil companies, and a theme that uses the style. A <CollectionBucket>
tag is used to associate a column value (Shell
; Esso
; Texaco
; BP
; any of Avia
, Benzinex
, Q8
, Total
, Witte Pomp
; and all others for a default category) with a style appropriate for that company's stations, as shown in Example 2-11.
Example 2-11 Advanced Style Definition for Gasoline Stations Theme
<?xml version="1.0" ?> <AdvancedStyle> <BucketStyle> <Buckets> <CollectionBucket seq="0" label="Shell" style="m.shell gasstation"> Shell </CollectionBucket> <CollectionBucket seq="1" label="Esso" style="m.esso gasstation"> Esso </CollectionBucket> <CollectionBucket seq="2" label="Texaco" style="m.texaco gasstation"> Texaco </CollectionBucket> <CollectionBucket seq="3" label="BP" style="m.bp gasstation"> BP </CollectionBucket> <CollectionBucket seq="4" label="Other" style="m.generic gasstation"> Avia,Benzinex,Q8,Total,Witte Pomp </CollectionBucket> <CollectionBucket seq="5" label="DEFAULT" style="m.default gasstation"> #DEFAULT# </CollectionBucket> </Buckets> </BucketStyle> </AdvancedStyle>
Notes on Example 2-11:
m.esso gasstation
, m.texaco gasstation
, and the other style names have a space between the words in their names.
The names are not case-sensitive. Therefore, be sure not to use case as a way of differentiating names. For example, m.esso gasstation
and M.ESSO GASSTATION
are considered the same name.
A default collection bucket can be specified by using #DEFAULT#
as its value. This bucket is used for any column values (gas station names) that are not specified in the other buckets.
A theme (theme_gasstation
) is then defined that specifies the column (MERK) in the table that contains company names. The styling rules of the theme are shown in Example 2-12.
Example 2-12 Styling Rules of Theme Definition for Gasoline Stations
<?xml version="1.0" standalone="yes"?> <styling_rules> <rule column="merk"> <features style="v.gasstations"> </features> <label column="merk" style="t.SansSerif red 10"> 1 </label> </rule> </styling_rules>
This theme depends on a table named NED_GASSTATIONS, which has the columns shown in Table 2-2 (with column names reflecting the fact that the developer's language is Dutch).
Table 2-2 Table Used with Gasoline Stations Theme
Column | Data Type |
---|---|
FID |
NOT NULL NUMBER |
ID |
NUMBER |
NAAM |
VARCHAR2(31) |
STRAAT_ |
VARCHAR2(30) |
NR |
NUMBER |
TV |
VARCHAR2(1) |
AAND |
VARCHAR2(2) |
PCODE |
VARCHAR2(6) |
PLAATS |
VARCHAR2(10) |
GEOM |
SDO_GEOMETRY |
MERK |
VARCHAR2(40) |
In this table, the GEOM column contains spatial geometries, and the MERK column contains company names (Shell
, Esso
, and so on).
The styling rules for the theme_gasstation
theme specify that the marker (style v.gasstations
) at a location specified by the content of the GEOM column is determined by the value of the MERK column for that row. The style v.gasstations
(see Example 2-11) specifies that if the column value is Shell
, use the style m.shell gasstation
; if the column value is Esso
, use the style m.esso gasstation
; and so on, including if the column value is any one of Avia
, Benzinex
, Q8
, Total
, and Witte Pomp
, use the style m.generic gasstation;
and if the column value is none of the preceding, use the style m.default gasstation
.
Some attributes of the <theme>
element affect only the appearance of the map display, rather than determining the data to be associated with the theme. These appearance-related attributes control whether and how the theme is processed and rendered when a map is generated. Examples include the following attributes:
min_scale
and max_scale
determine whether or not a theme is displayed at various map scales (levels of resolution). For example, if you are displaying a map of streets, there are certain map scales at which the streets would become too dense for a usable display, such as when viewing an entire state or province. In this case, you should create a theme for streets, and specify minimum and maximum scale values to ensure that individual streets affected by the theme are displayed when the scale is appropriate and otherwise are not displayed.
labels_always_on
determines whether or not labels for the theme will be displayed if they would overlap another label. By choosing appropriate labels_always_on
values and choosing an appropriate order of themes to be processed within a map request, you can control how cluttered the labels might become and which labels have priority in getting displayed.
fast_unpickle
determines the unpickling (unstreaming) method to be used, which can involve a trade-off between performance and precision in the display.
fixed_svglabel
, visible_in_svg
, selectable_in_svg
, onclick
, onmousemove
, onmouseover
, and onmouseout
affect the appearance of SVG maps.
To specify any appearance-related attributes, use the <theme>
element (described in Section 3.2.14) with the XML API or the JavaBean-based API (see especially Section 4.3).
An image theme is a special kind of OracleAS MapViewer theme useful for visualizing geographically referenced imagery (raster) data, such as from remote sensing and aerial photography.
You can define an image theme dynamically or permanently (as a predefined theme) in the database. You can use image themes with vector (nonimage) themes in a map. Figure 2-5 shows a map in which an image theme (showing an aerial photograph of part of the city of Boston) is overlaid with themes showing several kinds of roadways in the city.
Figure 2-5 Image Theme and Other Themes Showing Boston Roadways
Before you can define an image theme, you must follow these rules in organizing your image data:
Store image data in its original format (such as JPEG) in a BLOB column in a database table.
Add a geometry (SDO_GEOMETRY) column to the same table, and store the minimum bounding rectangle (MBR) for each image in that column.
Each geometry in the MBR column contains the geographic bounds for an image, not its size in the pixel space. For example, if an orthophoto image is 2000 by 2000 pixels in size, but covers a ground rectangle starting at the corner of (936000, 248000) and having a width and height of 8000 meters, the MBR for the geometry column should be populated with (936000, 248000, 944000, 256000).
Insert an entry for the geometry column in the USER_SDO_GEOM_METADATA view.
Create a spatial index on the geometry column.
To predefine an image theme, follow the guidelines in Section 2.3.5.1. To define a dynamic image theme in a map request, follow the guidelines for defining a JDBC theme, as explained in Section 2.3.2 and Section 3.2.9, but note the following additional considerations with dynamic image themes:
You must provide the original image resolution information when defining an image theme.
OracleAS MapViewer by default automatically scales the image data when generating a map with an image theme, so that it fits the current query window. To disable this automatic scaling, specify imagescaling="false"
in the map request.
For any image theme definition, note the following considerations:
You cannot use the Map Definition Tool to create an image theme. Instead, you must create an image theme and add it to the OracleAS MapViewer instance programmatically, or you must predefine the theme as explained in Section 2.3.5.1.
OracleAS MapViewer supports only GIF and JPEG image formats. To enable OracleAS MapViewer to visualize data in any other image format, you must implement a custom image renderer using the oracle.sdovis.CustomImageRenderer
interface in Java, and then register your implementation class in the mapViewerConfig.xml
file (to tell OracleAS MapViewer which custom image renderer to use for image data in a specific format). For detailed information about implementing and registering a custom image renderer, see Appendix C.
For an example of a map request specifying an image theme, including an explanation of how OracleAS MapViewer processes the request, see Example 3-6 in Section 3.1.6.
To create a predefined image theme, you must store the definition of the image theme in the database by inserting a row into the USER_SDO_THEMES view (described in Section 2.8.2). Example 2-13 stores the definition of an image theme.
Example 2-13 Creating a Predefined Image Theme
INSERT INTO user_sdo_themes VALUES ( 'IMAGE_LEVEL_2', 'Orthophotos at pyramid level 2', 'IMAGES', 'IMAGE_MBR', '<?xml version="1.0" standalone="yes"?> <styling_rules theme_type="image" image_column="image" image_format="JPEG" image_resolution="2" image_unit="M"> <rule > <features style="C.RED"> plevel=2 </features> </rule> </styling_rules>' );
Example 2-13 creates an image theme named IMAGE_LEVEL_2
. The base table (where all image data and associated MBRs are stored) is named IMAGES, and the minimum bounding rectangles (MBRs) for the images are stored in the column named IMAGE_MBR. In the STYLING_RULES column of the USER_SDO_THEMES view, an XML document with one <styling_rules>
element is inserted.
The <styling_rules>
element for an image theme has the following attributes:
theme_type
must be image
in order for this theme to be recognized as an image theme.
image_column
specifies the column in the base table or view that stores the actual image data.
image_format
is a string identifying the format of the image data. If you specify GIF
or JPEG
, OracleAS MapViewer can always render the image data. If you specify any other value, such as ECW
, you must have implemented a custom image renderer and registered it to OracleAS MapViewer in order for the image to be rendered properly. For information about implementing a custom image renderer, see Appendix C.
image_resolution
is an optional attribute that identifies the original image resolution (number of image_unit
units for each pixel).
image_unit
is an optional attribute, except it is required if you specify the image_resolution
attribute. The image_unit
attribute specifies the unit of the resolution, such as M
for meter. The value for this attribute must be one of the values in the SDO_UNIT column of the MDSYS.SDO_DIST_UNITS table. In Example 2-13, the image resolution is 2 meters per pixel.
The DTD for the <styling_rules>
element is presented in Section A.7.
A GeoRaster theme is a special kind of OracleAS MapViewer theme useful for visualizing GeoRaster objects. GeoRaster is a feature of Oracle Spatial that lets you store, index, query, analyze, and deliver raster image and gridded data and its associated metadata. GeoRaster objects are defined using the SDO_GEORASTER data type. For detailed information about GeoRaster, see Oracle Spatial GeoRaster.
Before you can use OracleAS MapViewer with GeoRaster themes, you must ensure that the Java Advanced Imaging (JAI) library files (jai_core.jar
and jai_codec.jar
) are in the OracleAS MapViewer library path, as explained in Section 1.4. You must also perform the following actions with the GeoRaster data:
Georeference the GeoRaster data to establish the relationship between cell coordinates of the GeoRaster data and real-world ground coordinates (or some other local coordinates).
If you are using Oracle Database Release 10.1, you must also set the spatial resolution values.
Generate or define the spatial extent (footprint) associated with the raster data.
Optionally, generate pyramid levels that represent the raster image or data at different sizes and degrees of resolution.
Insert a row into the USER_SDO_GEOM_METADATA view that specifies the name of the GeoRaster table and the SPATIALEXTENT attribute of the GeoRaster column (that is, the column of type SDO_GEORASTER). The following example inserts a row for a table named GEOR_TABLE with a GeoRaster column named GEOR_COLUMN:
INSERT INTO USER_SDO_GEOM_METADATA VALUES ( 'geor_table', 'geor_column.spatialextent', SDO_DIM_ARRAY( SDO_DIM_ELEMENT('X', 496602.844, 695562.844, 0.000005), SDO_DIM_ELEMENT('Y',8788409.499,8973749.499, 0.000005) ), 82279 -- SRID );
Create a spatial index on the spatial extent of the GeoRaster table. The following example creates a spatial index named GEOR_IDX on the spatial extent of the table named GEOR_TABLE:
CREATE INDEX geor_idx ON geor_table(geor_column.spatialextent) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
Example 2-17 in Section 2.3.6.1 prepares GeoRaster data for use and stores a GeoRaster theme in the database.
OracleAS MapViewer supports two types of map requests with objects from a GeoRaster table:
A request containing a SQL statement to select one or more GeoRaster objects
A request specifying a single GeoRaster object by the combination of its raster data table name and its rasterID
attribute value in the SDO_GEORASTER object. (The rasterID
attribute value in the SDO_GEORASTER object is distinct from and unrelated to any primary key or ID column in the GeoRaster table.)
The following elements and attributes apply to the definition of a GeoRaster theme:
<jdbc_georaster_query>
element: Specifies that this is a dynamically defined GeoRaster theme. For a theme that uses a SQL statement to select one or more GeoRaster objects, this element contains the SQL query statement (without a terminating semicolon). The complete DTD for this element is included in the map request DTD in Section 3.2.
georaster_table
attribute: Specifies the name of the GeoRaster table.
georaster_column
attribute: Specifies the name of the column of type SDO_GEORASTER in the GeoRaster table.
polygon_mask
attribute (optional): Specifies a set of two-dimensional coordinates representing a polygon, to be used as a mask to make transparent the part of the GeoRaster image that is outside the polygon mask. The coordinates are defined as x1,y1,x2,y2, . . . . The mask coordinates must be in the data coordinate space.
raster_bands
attribute (optional): Specifies the band composition to be assigned to the red, green, and blue channels. If you specify only one value, the resulting image uses one band (gray levels for monochromatic images). If you specify two values, they are used for the red and green channels, and the default blue band stored in the GeoRaster metadata is used for the blue channel. If you do not specify this attribute, OracleAS MapViewer uses the default values stored in the GeoRaster metadata.
raster_pyramid
attribute (optional): Specifies the pyramid level (level of resolution). If you do not specify this attribute, OracleAS MapViewer calculates the best pyramid level for the current window query and device area.
raster_id
attribute (only if the definition does not include a SQL statement): Specifies the rasterID
attribute value in the SDO_GEORASTER object definition of the single GeoRaster object for the map request.
raster_table
attribute (optional, and only if the definition does not include a SQL statement): Specifies the raster data table associated with the single GeoRaster object for the map request.
Example 2-14 defines a GeoRaster theme that contains a SQL statement that selects a single GeoRaster object. The theme assigns band 1 to the red channel, band 2 to the green channel, and band 3 to the blue channel. Because the raster_pyramid
attribute is not specified, OracleAS MapViewer calculates the best pyramid level by using the spatial resolution values set during or after the georeferencing process. (Note that in Example 2-14, georid=1
in the WHERE clause refers to a column named GEORID in the GeoRaster table named PCI_IMAGE.)
Example 2-14 GeoRaster Theme Containing a SQL Statement
<theme name="georaster_theme"> <jdbc_georaster_query georaster_table="pci_image" georaster_column="georaster" raster_bands="1,2,3" jdbc_srid="82301" datasource="mvdemo" asis="false"> SELECT georaster FROM pci_image WHERE georid =1 </jdbc_georaster_query> </theme>
Example 2-15 defines a GeoRaster theme that specifies the single GeoRaster object whose rasterID
attribute value in the SDO_GEORASTER object is 1 (raster_id="1"
) and associated with the raster data table named RDT_PCI. The theme specifies 2 as the pyramid level.
Example 2-15 GeoRaster Theme Specifying a Raster ID and Raster Data Table
<theme name="georaster_theme"> <jdbc_georaster_query georaster_table="pci_image" georaster_column="georaster" raster_id="1" raster_table="rdt_pci" raster_pyramid="2" raster_bands="1,2,3" jdbc_srid="82301" datasource="mvdemo" asis="false"> </jdbc_georaster_query> </theme>
To create a predefined GeoRaster theme, you must store the definition of the GeoRaster theme in the database by inserting a row into the USER_SDO_THEMES view (described in Section 2.8.2). Example 2-16 stores the definition of a GeoRaster theme.
Example 2-16 Creating a Predefined GeoRaster Theme
INSERT INTO user_sdo_themes VALUES ( 'GEOR_BANDS_012', 'Band 0 for red, 1 for green, 2 for blue', 'GEOR_TABLE', 'GEOR_COLUMN', '<?xml version="1.0" standalone="yes"?> <styling_rules theme_type="georaster" raster_table="RDT_PCI" raster_id="1" raster_bands="0,1,2"> </styling_rules>' );
Example 2-16 creates a GeoRaster theme named GEOR_BANDS_012
, in which band 0 is assigned to the red channel, band 1 to the green channel, and band 2 to the blue channel. The GeoRaster table name (GEOR_TABLE in this example) is inserted in the BASE_TABLE column of the USER_SDO_THEMES view, the GeoRaster column name (GEOR_COLUMN in this example) is inserted in the GEOMETRY_COLUMN column, and an XML document with one <styling_rules>
element is inserted in the STYLING_RULES column.
In the <styling_rules>
element for a GeoRaster theme, theme_type
must be georaster
in order for this theme to be recognized as a GeoRaster theme.
The <styling_rules>
element for a GeoRaster theme can contain the attributes described in Section 2.3.6, including raster_bands
, raster_pyramid
, raster_id
, and raster_table
, as shown in Example 2-16. Alternatively, the <styling_rules>
element for a GeoRaster theme can be a rule definition. For example, to create a GeoRaster theme that selects a GeoRaster object from the GeoRaster table satisfying the WHERE clause condition georid=1
, replace the <styling_rules>
element in Example 2-16 with the following:
<styling_rules theme_type="georaster"> <rule> <features> georid=1 </features> </rule> </styling_rules>
The DTD for the <styling_rules>
element is presented in Section A.7.
Example 2-17 prepares GeoRaster data for use with a GeoRaster theme that is stored in the database. Comments in the code example briefly describe the main steps. For detailed information about requirements and steps for using GeoRaster data, see Oracle Spatial GeoRaster.
Example 2-17 Preparing GeoRaster Data for Use with a GeoRaster Theme
connect scott/tiger SET ECHO ON SET FEEDBACK 1 SET NUMWIDTH 10 SET LINESIZE 100 SET PAGESIZE 10000 SET SERVEROUTPUT ON SIZE 5000 SET LONG 20000 SET TIMING ON call dbms_java.set_output(5000); ------------------------------------------------------------------- -- Create a GeoRaster table (a table that has a -- column of SDO_GEORASTER object type). ------------------------------------------------------------------- create table georaster_table (georid number primary key, type varchar2(32), georaster sdo_georaster); ------------------------------------------------------------------- -- Create the GeoRaster DML trigger on the GeoRaster table. -- -- This is REQUIRED for all GeoRaster tables. -- It is used to manage the GeoRaster sysdata table. ------------------------------------------------------------------- call sdo_geor_utl.createDMLTrigger('georaster_table', 'georaster'); ------------------------------------------------------------------- -- Create a raster data table (RDT). -- -- It is used to store cell data of GeoRaster objects. -- This step is not a requirement. If the RDT table does not -- exist, the GeoRaster procedures or functions will generate it -- automatically whenever needed. -- However, for huge GeoRaster objects, some tuning and setup on those -- tables can improve the scalability and performance significantly. -- In those cases, it is better for users to create the RDTs. -- The primary key must be added to the RDT if you create it. ------------------------------------------------------------------- create table rdt_geor of sdo_raster (primary key (rasterId, pyramidLevel, bandBlockNumber, rowBlockNumber, columnBlockNumber)) lob(rasterblock) store as (nocache nologging); commit; ---------------- -- Import the image. ---------------- connect system/manager; call dbms_java.grant_permission('MDSYS','SYS:java.io.FilePermission', 'lbs/demo/images/l7_ms.tif', 'read' ); call dbms_java.grant_permission('SCOTT','SYS:java.io.FilePermission', 'lbs/demo/images/l7_ms.tif', 'read' ); connect scott/tiger; declare geor SDO_GEORASTER; begin delete from georaster_table where georid = 1; insert into georaster_table values( 1, 'TIFF', sdo_geor.init('rdt_geor', 1) ); select georaster into geor from georaster_table where georid = 1 for update; sdo_geor.importFrom(geor, '', 'TIFF', 'file', 'lbs/demo/images/l7_ms.tif'); update georaster_table set georaster = geor where georid = 1; commit; end;/ connect system/manager; call dbms_java.revoke_permission('MDSYS','SYS:java.io.FilePermission', 'lbs/demo/images/l7_ms.tif', 'read' ); call dbms_java.revoke_permission('SCOTT','SYS:java.io.FilePermission', 'lbs/demo/images/l7_ms.tif', 'read' ); connect scott/tiger; -------------------------- -- Change the GeoRaster format (optional). -------------------------- declare gr1 sdo_georaster; begin -- -- Using changeFormat with a GeoRaster object: -- -- 1. Select the source GeoRaster object. select georaster into gr1 from georaster_table where georid = 1; -- 2. Make changes. (Interleaving is application-dependent. For TIFF images, -- the default interleaving is BSQ.) sdo_geor.changeFormat(gr1, 'blocksize=(512,512,3) interleaving=BIP'); -- 3. Update the GeoRaster object in the GeoRaster table. update georaster_table set georaster = gr1 where georid = 1; commit; end;/ --------------------------- -- Generate pyramid levels (strongly recommended, but optional). --------------------------- declare gr sdo_georaster; begin -- 1. Select the source GeoRaster object. select georaster into gr from georaster_table where georid = 1 for update; -- 2. Generate pyramids. sdo_geor.generatePyramid(gr, 'resampling=NN'); -- 3. Update the original GeoRaster object. update georaster_table set georaster = gr where georid = 1; commit; end;/ ----------------------------- -- Georeference the GeoRaster object. ----------------------------- DECLARE gr sdo_georaster; BEGIN SELECT georaster INTO gr FROM georaster_table WHERE georid = 1 FOR UPDATE; sdo_geor.georeference(gr, 82216, 1, sdo_number_array(30, 0, 410000.000000), sdo_number_array(0, -30,3759000.000000)); UPDATE georaster_table SET georaster = gr WHERE georid = 1; COMMIT; END;/ ----------------------------- -- Set the spatial resolutions (required for 10gR1 only) ----------------------------- -- If you are using Oracle Database Release 10.1, set spatial resolutions. (Not -- required if you are using Release 10.2.) The spatial resolution values of -- (30, 30) are from the ESRI world file or from the georeferencing information; -- however, you may have to compute these values if they are not part of -- the original georeferencing metadata. DECLARE gr sdo_georaster; BEGIN SELECT georaster INTO gr FROM georaster_table WHERE georid = 1 FOR UPDATE; sdo_geor.setSpatialResolutions(gr, sdo_number_array(30, 30)); UPDATE georaster_table SET georaster = gr WHERE georid = 1; COMMIT; END; / ------------------------ -- Update the spatial extent. ------------------------ DECLARE sptext sdo_geometry; BEGIN SELECT sdo_geor.generateSpatialExtent(a.georaster) INTO sptext FROM georaster_table a WHERE a.georid=1 FOR UPDATE; UPDATE georaster_table a SET a.georaster.spatialextent = sptext WHERE a.georid=1; COMMIT; END;/ commit; ------------------------------------------------------------------ -- Create metadata information for the GeoRaster spatial extent column. ------------------------------------------------------------------ INSERT INTO USER_SDO_GEOM_METADATA VALUES ( 'GEORASTER_TABLE', 'georaster.spatialextent', SDO_DIM_ARRAY( SDO_DIM_ELEMENT('X', 410000.0, 470000.0, 0.000005), SDO_DIM_ELEMENT('Y', 3699000.0,3759000., 0.000005) ), 82216 -- SRID ); ------------------------ -- Create a spatial index on the spatial extent. ------------------------ CREATE INDEX georaster_idx ON georaster_table(georaster.spatialextent) INDEXTYPE IS MDSYS.SPATIAL_INDEX; -------------------------------------------------------- -- Create a predefined GeoRaster theme for OracleAS MapViewer. -------------------------------------------------------- INSERT INTO user_sdo_themes VALUES ( 'GEORASTER_TABLE', 'GeoTiff image', 'GEORASTER_TABLE', 'GEORASTER', '<?xml version="1.0" standalone="yes"?> <styling_rules theme_type="georaster" raster_table="RDT_GEOR" raster_id="1" raster_bands="0,1,2"> </styling_rules>' ); commit;
A network theme is a special kind of OracleAS MapViewer theme useful for visualizing networks defined using the Oracle Spatial network data model. A network consists of a set of nodes and links. A network can be directed or undirected, although links and paths typically have direction. A network can be organized into different levels of abstraction, called a network hierarchy. OracleAS MapViewer assumes that network spatial tables in a network use the same coordinate system, and that these tables are indexed and registered as described in Oracle Spatial Topology and Network Data Models.
Network node, link, and path tables store geometries of type SDO_GEOMETRY. You can create JDBC themes that use these geometries. In addition, you can define dynamic themes that consider aspects of the network, such as the direction of links for a directed network.
The following elements and attributes apply to the definition of a network theme:
<jdbc_network_query>
element: Specifies that this is a dynamically defined network theme. The complete DTD for this element is included in the map request DTD in Section 3.2.
network_name
attribute: Specifies the name of the network.
network_level
attribute (optional): Specifies the network hierarchy level to which this theme applies. (For a nonhierarchical network, specify 1, which is the default value.)
link_style
attribute (optional): Specifies the style name to be used for links.
direction_style
attribute (optional): Specifies the style name to be used for a link direction marker (for example, a directional arrow image).
direction_position
attribute (optional): Specifies the position of the direction marker relative to the link start, as a number between 0 and 1. For example, 0.85 indicates 85 percent of the way between the link start and end points.
direction_markersize
attribute (optional): Specifies the size (number of pixels) of the direction marker.
link_labelstyle
attribute (optional): Specifies the style name to be used for link labels in the column specified in the link_labelcolumn
attribute.
link_labelcolumn
attribute (optional): Specifies the name of the column containing link labels to be rendered using the style specified in the link_labelstyle
attribute.
node_style
attribute (optional): Specifies the style name to be used for nodes.
node_markersize
attribute (optional): Specifies the size (number of pixels) of the node marker.
node_labelstyle
attribute (optional): Specifies the style name to be used for node labels in the column specified in the node_labelcolumn
attribute.
node_labelcolumn
attribute (optional): Specifies the name of the column containing node labels to be rendered using the style specified in the node_labelstyle
attribute.
path_ids
attribute (optional): Specifies one or more path ID values of stored paths to be rendered. For more than one path, use commas to delimit the path ID values. For example, path_ids="1,3,4"
specifies that the paths with path ID values 1, 3, and 4 are to be rendered.
path_styles
attribute (optional): Specifies one or more style names associated with the paths specified in the path_ids
attribute. For example, path_styles="C.RED,C.GREEN,C.BLUE"
specifies styles to be used to render the first, second, and third paths (respectively) specified in the path_ids
attribute.
path_labelstyle
attribute (optional): Specifies the style name to be used for path labels in the column specified in the path_labelcolumn
attribute.
path_labelcolumn
attribute (optional): Specifies the name of the column containing path labels to be rendered using the style specified in the path_labelstyle
attribute.
Additional network theme attributes related to network analysis are described in Section 2.3.7.2.
A network theme can combine attributes for links, nodes, and paths, or any combination. In such cases, OracleAS MapViewer first renders the links, then the paths, and then the nodes.
Example 2-18 defines a network theme that specifies attributes for the display of links and nodes in the network named NYC_NET
.
Example 2-18 Network Theme
<theme name="net_theme" user_clickable="false"> <jdbc_network_query network_name="NYC_NET" network_level="1" jdbc_srid="8307" datasource="mvdemo" link_style="C.RED" direction_style="M.IMAGE105_BW" direction_position="0.85" direction_markersize="8" node_style="M.STAR" node_markersize="5" asis="false"> </jdbc_network_query> </theme>
To create a predefined network theme, you must store the definition of the network theme in the database by inserting a row into the USER_SDO_THEMES view (described in Section 2.8.2). Example 2-19 stores the definition of a network theme.
Example 2-19 Creating a Predefined Network Theme
INSERT INTO user_sdo_themes VALUES ( 'NYC_NET_1', 'New York City network', 'NYC_NET_LINK_TABLE', 'GEOMETRY', '<?xml version="1.0" standalone="yes"?> <styling_rules theme_type="network" network_name="NYC_NET" network_level="1"> <rule> <features> <link style="C.RED" direction_style="M.IMAGE105_BW" direction_position="0.85" direction_markersize="8"> </link> <path ids="1,3" styles="C.BLUE,C.GREEN"> </path> <node style="M.CIRCLE" markersize="5"> </node> </features> <label> <link column="LINK_ID" style="T.STREET NAME"> 1 </link> </label> </rule> </styling_rules>' );
Example 2-19 creates a network theme named NYC_NET_1
for level 1 of the network named NYC_NET
. The network table name (NYC_NET_LINK_TABLE in this example) is inserted in the BASE_TABLE column of the USER_SDO_THEMES view, the link geometry column name (GEOMETRY in this example) is inserted in the GEOMETRY_COLUMN column, and an XML document with one <styling_rules>
element is inserted in the STYLING_RULES column.
In the <styling_rules>
element for a network theme, theme_type
must be network
in order for this theme to be recognized as a network theme. Elements for links, paths, and nodes can be specified in the same <features>
element, as is done in Example 2-19:
The link feature rule specifies the style C.RED
and direction marker attributes for all links.
The path feature rule specifies the style C.BLUE
for paths with the path ID value 1, and the style C.GREEN
for paths with the path ID value 3.
The node feature rule specifies the style M.CIRCLE
and a marker size of 5.
Example 2-19 also contains a <label>
element for links, specifying the link column LINK_ID
and the label style T.STREET NAME
.
The DTD for the <styling_rules>
element is presented in Section A.7.
The network model Java API provides several network analysis capabilities. You can define OracleAS MapViewer network themes that support the shortest-path and within-cost analysis capabilities. Some attributes apply to both capabilities, and some attributes apply only to the relevant associated capability.
For all network analysis capabilities, the <jdbc_network_query>
element and the network-related attributes described in Section 2.3.7 apply to the definition of the network theme.
For shortest-path analysis, the following attributes apply to the definition of the network theme:
analysis_algorithm
attribute: Specifies the shortest-path analysis algorithm to use. Must be either DIJKSTRA
or ASEARCH
.
shortestpath_style
attribute: Specifies the style name to be used for the shortest path.
shortestpath_startnode
attribute: Specifies the start node to be used for the analysis.
shortestpath_endnode
attribute: Specifies the end node to be used for the analysis.
shortestpath_startstyle
attribute (optional): Specifies the style name to be used for the start node.
shortestpath_endstyle
attribute (optional): Specifies the style name to be used for the end node.
Example 2-20 defines a network theme that can be used for shortest-path analysis.
Example 2-20 Network Theme for Shortest-Path Analysis
<theme name="shortest_path_theme" user_clickable="false"> <jdbc_network_query network_name="BI_TEST" network_level="1" jdbc_srid="0" datasource="mvdemo" analysis_algorithm="DIJKSTRA" shortestpath_style="L.PH" shortestpath_startnode="20" shortestpath_endnode="101" shortestpath_startstyle="M.STAR" shortestpath_endstyle="M.CIRCLE" asis="false"> </jdbc_network_query> </theme>
For within-cost analysis, the following attributes apply to the definition of the network theme:
analysis_algorithm
attribute: Must be WITHINCOST
.
withincost_startnode
attribute: Specifies the start node to be used for the analysis.
withincost_cost
attribute: Specifies the cost cutoff value for nodes to be included. All nodes that can be reached from the start node at a cost less than or equal to the specified value are included in the resulting display. Nodes that cannot be reached from the start node or that can be reached only at a cost greater than the specified value are not included.
withincost_startstyle
attribute (optional): Specifies the style name to be used for the start node.
withincost_style
attribute: Specifies the style name to be used for links in the displayed paths between the start node and each node that is within the specified cost cutoff value.
Example 2-21 defines a network theme that can be used for within-cost analysis.
Example 2-21 Network Theme for Within-Cost Analysis
<theme name="within_cost_theme" user_clickable="false"> <jdbc_network_query network_name="BI_TEST" network_level="1" jdbc_srid="0" datasource="mvdemo" analysis_algorithm="WITHINCOST" withincost_startnode="20" withincost_style="L.PH" withincost_cost="1" withincost_startstyle="M.STAR" asis="false"> </jdbc_network_query> </theme>
A topology theme is a special kind of OracleAS MapViewer theme useful for visualizing topologies defined using the Oracle Spatial topology data model. The topology data model lets you work with data about nodes, edges, and faces in a topology. The spatial representations of nodes, edges, and faces are spatial geometries of type SDO_GEOMETRY. For nodes and edges, the geometries are explicitly stored; for faces, the initial lines (exterior and interior) are stored, allowing the face geometry to be generated.
In addition to the spatial representation of nodes, edges, and faces, a topology can have features. A feature (also called a topology geometry) is a spatial representation of a real-world object. Each feature is defined as an object of type SDO_TOPO_GEOMETRY, which identifies the topology geometry type, topology geometry ID, topology geometry layer ID, and topology ID. For detailed information, see Oracle Spatial Topology and Network Data Models.
OracleAS MapViewer can render topology features. It can also render a theme in debug mode (explained later in this section) to show the nodes, edges, and faces of a topology. For each topology theme, OracleAS MapViewer uses the topology metadata information stored in the USER_SDO_TOPO_METADATA view.
The following elements and attributes apply to the definition of a topology theme:
<jdbc_topology_query>
element: Specifies that this is a dynamically defined topology theme. The element can specify a SQL query statement (without a terminating semicolon). The complete DTD for this element is included in the map request DTD in Section 3.2.
topology_name
attribute: Specifies the name of the topology.
feature_table
attribute: Specifies the name of the feature table.
spatial_column
attribute: Specifies the name of the spatial feature column of type SDO_TOPO_GEOMETRY.
label_column
attribute: Specifies the column in the feature table that contains the text label to be used with each feature.
label_style
attribute: Specifies the name of the text style to be used to render the labels in the label column.
render_style
attribute: Specifies the name of the style to be used to render the topology.
Example 2-22 defines a topology theme that specifies attributes for the display of features and labels from the LAND_PARCELS table in the CITY_DATA topology. The SQL statement specifies the spatial feature column and the label column, and it includes all rows in the feature table.
Example 2-22 Topology Theme
<theme name="topo_theme" user_clickable="false"> <jdbc_topology_query topology_name="CITY_DATA" feature_table="LAND_PARCELS" label_column="FEATURE_NAME" spatial_column="FEATURE" label_style="T.CITY NAME" render_style="C.COUNTIES" jdbc_srid="0" datasource="topology" asis="false">select feature, feature_name from land_parcels </jdbc_topology_query> </theme>
OracleAS MapViewer also supports a debug mode that renders the nodes, edges, and faces of a topology. To specify debug mode, include the mode="debug"
attribute in the <theme>
element. In addition to the <jdbc_topology_query>
attributes mentioned earlier in this section, the following attributes can be used in debug mode:
edge_style
attribute: Specifies the name of the style to be used to render edges.
edge_label_style
attribute: Specifies the name of the text style to be used to render edge labels.
edge_marker_style
attribute: Specifies the name of the marker style to be used for edge markers.
edge_marker_size
attribute: Specifies the size (number of pixels) of for edge markers.
node_style
attribute: Specifies the name of the style to be used to render nodes.
node_label_style
attribute: Specifies the name of the text style to be used to render node labels.
face_style
attribute: Specifies the name of the style to be used to render faces.
face_label_style
attribute: Specifies the name of the text style to be used to render face labels.
Example 2-23 defines a debug-mode topology theme for rendering features, edges, nodes, and faces from all feature tables in the CITY_DATA topology.
Example 2-23 Topology Theme Using Debug Mode
<theme name="topo_theme" mode="debug" user_clickable="false"> <jdbc_topology_query topology_name="CITY_DATA" edge_style="C.RED" edge_marker_style="M.IMAGE105_BW" edge_marker_size="8" edge_label_style="T.EDGE" node_style="M.CIRCLE" node_label_style="T.NODE" face_style="C.BLUE" face_label_style="T.FACE" jdbc_srid="0" datasource="topology" asis="false"> </jdbc_topology_query> </theme>
To create a predefined topology theme, you must store the definition of the topology theme in the database by inserting a row into the USER_SDO_THEMES view (described in Section 2.8.2). Example 2-24 stores the definition of a topology theme.
Example 2-24 Creating a Predefined Topology Theme
INSERT INTO user_sdo_themes VALUES ( 'LANDPARCELS', 'Topology theme for land parcels', 'LAND_PARCELS', 'FEATURE', '<?xml version="1.0" standalone="yes"?> <styling_rules theme_type="topology" topology_name="CITY_DATA"> <rule> <features style="C.RED"></features> <label column="FEATURE_NAME" style="T.TEXT STYLE"> </label> </rule> </styling_rules>' );
Example 2-24 creates a topology theme named LANDPARCELS
for the topology named CITY_DATA
. The feature table name (LAND_PARCELS in this example) is inserted in the BASE_TABLE column of the USER_SDO_THEMES view, the feature column name (FEATURE in this example) is inserted in the GEOMETRY_COLUMN column, and an XML document with one <styling_rules>
element is inserted in the STYLING_RULES column.
In the <styling_rules>
element for a topology theme, theme_type
must be topology
in order for this theme to be recognized as a topology theme. The theme in Example 2-24 defines one styling rule that renders all land parcel features from the CITY_DATA
topology using the C.RED
style and using the T.TEXT STYLE
label style for values in the FEATURE_NAME column of the feature table.
The DTD for the <styling_rules>
element is presented in Section A.7.
A map can consist of a combination of elements and attributes, such as the following:
Background image
Title
Legend
Query window
Footnote (such as for a copyright notice)
Base map
Predefined themes (in addition to any in the base map)
JDBC themes (with dynamic queries)
Dynamically defined (temporary) styles
These elements and attributes, when specified in a map request, define the content and appearance of the generated map. Chapter 3 contains detailed information about the available elements and attributes for a map request.
A map can have a base map and a stack of themes rendered on top of each other in a window. A map has an associated coordinate system that all themes in the map must share. For example, if the map coordinate system is 8307 (for Longitude / Latitude (WGS 84), the most common system used for GPS devices), all themes in the map must have geometries defined using that coordinate system.
You can add themes to a map by specifying a base map name or by using the programming interface to add themes. The order in which the themes are added determines the order in which they are rendered, with the last specified theme on top, so be sure you know which themes you want in the background and foreground.
All base map names and definitions for a database user are stored in that user's USER_SDO_MAPS view, which is described in Section 2.8 and Section 2.8.1. The DEFINITION column in the USER_SDO_MAPS view contains an XML definition of a base map.
Example 2-25 shows a base map definition.
Example 2-25 XML Definition of a Base Map
<?xml version="1.0" ?> <map_definition> <theme name="theme_us_states" min_scale="10" max_scale="0"/> <theme name="theme_us_parks" min_scale="5" max_scale="0"/> <theme name="theme_us_highways" min_scale="5" max_scale="0"/> <theme name="theme_us_streets" min_scale="0.05" max_scale="0"/> </map_definition>
Each theme in a base map can be associated with a visible scale range within which it is displayed. In Example 2-25, the theme named theme_us_streets
is not displayed unless the map request is for a map scale of 0.05 or less and greater than 0 (in this case, a scale showing a great deal of detail). If the min_scale
and max_scale
attributes are not specified, the theme is displayed whenever the base map is displayed. (For more information about map scale, see Section 2.4.1.)
The display order of themes in a base map is the same as their order in the base map definition. In Example 2-25, the theme_us_states
theme is rendered first, then theme_us_parks
, then theme_us_highways
, and finally (if the map scale is within all specified ranges) theme_us_streets
.
Map size is the height of the map in units of the map data space. For example, if the map data is in WGS 84 geographic coordinates, the map center is (-120.5, 36.5), and the size is 2, then the height of the map is 2 decimal degrees, the lower Y (latitude) value is 35.5 degrees, and the upper Y value is 37.5 decimal degrees.
Map scale is expressed as units in the user's data space that are represented by 1 inch on the screen or device. Map scale for OracleAS MapViewer is actually the denominator value in a popular method of representing map scale as 1/n, where:
1, the numerator, is 1 unit (1 inch for OracleAS MapViewer) on the displayed map.
n, the denominator, is the number of units of measurement (for example, decimal degrees, meters, or miles) represented by 1 unit (1 inch for OracleAS MapViewer) on the displayed map.
For example:
If 1 inch on a computer display represents 0.5 decimal degree of user data, the fraction is 1/0.5. The decimal value of the fraction is 2.0, but the scale value for OracleAS MapViewer is 0.5.
If 1 inch on a computer display represents 2 miles of user data, the fraction is 1/2. The decimal value of the fraction is 0.5, but the scale value for OracleAS MapViewer is 2.
If 1 inch on a computer display represents 10 miles of user data, the fraction is 1/10. The decimal value of the fraction is 0.1, but the scale value for OracleAS MapViewer is 10.
The min_scale
and max_scale
attributes in a <theme>
element describe the visible scale range of a theme. These attributes control whether or not a theme is displayed, depending on the current map scale. The default scale value for min_scale
is positive infinity, and the default value for max_scale
is negative infinity (or in other words, by default display the theme for all map scales, if possible given the display characteristics).
min_scale
is the value to which the display must be zoomed in for the theme to be displayed. For example, if parks have a min_scale
value of 5 and if the current map scale value is 5 or less but greater than the max_scale
value, parks will be included in the display; however, if the display is zoomed out so that the map scale value is greater than 5, parks will not be included in the display.
max_scale
is the value beyond which the display must be zoomed in for the theme not to be displayed. For example, if counties have a max_scale
value of 3 and if the current map scale value is 3 or less, counties will not be included in the display; however, if the display is zoomed out so that the map scale value is greater than 3, counties will be included in the display.
A high min_scale
value is associated with less map detail and a smaller scale in cartographic terms, while a high max_scale
value is associated with greater map detail and a larger scale in cartographic terms. (Note that the OracleAS MapViewer meaning of map scale is different from the popular meaning of cartographic map scale.) The min_scale
value for a theme should be larger than the max_scale
value. Example 2-25 in Section 2.4 includes min_scale
and max_scale
values.
To determine the current map scale for a map returned by OracleAS MapViewer, first find the map size, namely the height (vertical span) of the map in terms of the coordinate system associated with the map data. For example, assume that a map with a height of 10 (miles, meters, decimal degrees, or whatever unit of measurement is associated with the data) is requested, and that the map is drawn on a device with a size of 500 by 350 pixels, where 350 is the height. OracleAS MapViewer assumes a typical screen resolution of 72 dpi. Because 72 pixels equals 1 inch, the height of the returned map is 4.86 inches (350/72 = 4.86). In this example, the size of the map is 10, and therefore the map scale is approximately 2.057 (10/4.86 = 2.057).
A map legend is an inset illustration drawn on top of the map and describing what various colors, symbols, lines, patterns, and so on represent. You have flexibility in specifying the content and appearance of the legend. You can:
Customize the background, border style, and font
Have one or more columns in the legend
Add space to separate legend entries
Indent legend entries
Use any OracleAS MapViewer style, including advanced styles
Example 2-26 is an excerpt from a request that includes a legend.
Example 2-26 Legend Included in a Map Request
<?xml version="1.0" standalone="yes"?> <map_request basemap="density_map" datasource = "mvdemo"> <center size="1.5"> . . . </center> <legend bgstyle="fill:#ffffff;fill-opacity:128;stroke:#ff0000" position="NORTH_WEST" font="Dialog"> <column> <entry text="Map Legend" is_title="true"/> <entry style="M.STAR" text="center point"/> <entry style="M.CITY HALL 3" text="cities"/> <entry is_separator="true"/> <entry style="C.ROSY BROWN STROKE" text="state boundary"/> <entry style="L.PH" text="interstate highway"/> <entry text="County population:"/> <entry style="V.COUNTY_POP_DENSITY" tab="1"/> </column> </legend> <themes> . . . </themes> </map_request>
Figure 2-6 shows a map with the legend specified in Example 2-26.
Notes on Example 2-26 and Figure 2-6:
This example shows a legend with a single column, although you can create multiple columns in a legend.
Each entry in the column definition can identify label text and whether the text is the legend title (is_title="true"
), a style name and associated text, or a separator (is_separator="true"
) for vertical blank space to be added (after the cities entry in this example).
For detailed information about adding a legend to a map request, see Section 3.2.11.
If you also specify a map title, note, or logo (or any combination), be sure that the legend and the other features have different positions. (Map titles, notes, and logos are explained in Section 1.5.5.) The default position for a legend is SOUTH_WEST
.
A data source corresponds to a database schema or user. Before you can draw any spatial data in a database schema, you must first define (create) a data source for the schema, either permanently or dynamically:
You can define a data source permanently by specifying its connection information and user login credentials in the OracleAS MapViewer configuration file (mapViewerConfig.xml
).
You can define or modify a data source dynamically using the OracleAS MapViewer administration (Admin) page.
Each map request must specify a master data source. You can, however, specify a different data source for individual themes added to the map request. This makes it easy to aggregate data stored across different database schemas. If a theme has no specified data source, it is associated with the master data source. A base map (and thus the themes included in it) is always associated with the master data source. When a theme is processed, all of its underlying data, as well as the styles referenced in its definition, must be accessible from the data source or sources associated with the theme.
Each data source has associated renderers (sometimes called mappers or map makers), the number of which is determined by the number_of_mappers
attribute in the <map_data_source>
element. This attribute and the max_connections
attribute (both described in Section 1.5.7) affect the number of database connections created for each data source when map requests are processed. The number of renderers specified in a data source also is the maximum number of concurrent requests that can be processed for that data source. Each additional renderer requires only a small amount of memory, so the main potential disadvantage of specifying a large number of renderers (such as 100) is that the underlying CPU resource might be strained if too many map requests are allowed to come through, thus affecting the performance of the entire OracleAS MapViewer server.
Each data source has its own internal metadata cache. The metadata cache holds the definitions of all accessed styles, as well as of all predefined themes that originate from the data source. This eliminates the need to query the database repeatedly for the definition of a style or predefined theme whenever it is needed.
When a map request arrives at the OracleAS MapViewer server, the server picks a free renderer associated with the master data source in the request. This section describes the process that the OracleAS MapViewer server follows to generate a map. In brief, OracleAS MapViewer performs the following steps:
Parse and process the incoming XML map request.
Prepare the data for each theme (executed in parallel).
Render and label each theme.
Generate final images or files.
Each map generated by OracleAS MapViewer results from its receiving a valid XML map request. (If you use the JavaBean-based API, the request is automatically converted to an XML document and passed to the OracleAS MapViewer server.) The XML map request is parsed and its content is validated. OracleAS MapViewer 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 OracleAS MapViewer 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, OracleAS MapViewer 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. OracleAS MapViewer 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, OracleAS MapViewer 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 OracleAS MapViewer. 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, OracleAS MapViewer 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, OracleAS MapViewer plots any additional map features (such as a legend) on the internal map image. OracleAS MapViewer 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, OracleAS MapViewer 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.
Workspace Manager is an Oracle Database feature that lets you version-enable one or more tables in the database. After a table is version-enabled, users in a workspace automatically see the correct version of database rows in which they are interested. For detailed information about Workspace Manager, see Oracle Database Application Developer's Guide - Workspace Manager.
You can request a map from a specific workspace, at a specific savepoint in a workspace, or at a point close to a specific date in a workspace. The following attributes of the <theme>
element are related to support for Workspace Manager:
workspace_name
attribute: specifies the name of the workspace from which to get the map data.
workspace_savepoint
attribute: specifies the name of the savepoint to go to in the specified workspace.
workspace_date
attribute: specifies the date to go to (that is, a point at or near the specified date) in the specified workspace.
workspace_date_format
attribute: specifies the date format. The default is mmddyyyyhh24miss
. This attribute applies only if you specified the workspace_date
attribute.
workspace_date_nlsparam
attribute: specifies globalization support options. The options and default are the same as for the nlsparam
argument to the TO_CHAR
function for date conversion, which is described in Oracle Database SQL Reference.
workspace_date_tswtz
attribute: specifies a Boolean value. TRUE
means that the input date is in timestamp with time zone format; FALSE
(the default) means that the input date is a date string.
The workspace_name
attribute is required for the use of Workspace Manager support in OracleAS MapViewer.
If you specify neither the workspace_savepoint
nor workspace_date
attribute, OracleAS MapViewer goes to the latest version of the workspace defined. If you specify both the workspace_savepoint
and workspace_date
attributes, OracleAS MapViewer uses the specified date instead of the savepoint name.
Example 2-27 shows the definition of a dynamic theme that uses attributes (shown in bold) related to Workspace Manager support. In this example, OracleAS MapViewer will render the data related to workspace wsp_1
at the savepoint sp1
.
Example 2-27 Workspace Manager-Related Attributes in a Map Request
<?xml version="1.0" standalone="yes"?>
<map_request
. . .
<themes>
<theme name="wmtheme" user_clickable="false"
workspace_name="wsp_1" workspace_savepoint="sp1" >
<jdbc_query
spatial_column="GEOM"
render_style="stylename"
jdbc_srid="8307"
datasource="mvdemo"
asis="false"> select GEOM,ATTR from GEOM_TABLE
</jdbc_query>
</theme>
</themes>
. . .
</map_request>
The following considerations apply to OracleAS MapViewer caching of predefined themes (explained in Section 2.3.1.2) and the use of Workspace Manager-related OracleAS MapViewer attributes:
The Workspace Manager-related attributes are ignored for predefined themes if the caching
attribute is set to ALL
in the <styling_rules>
element for the theme.
No caching data is considered if you specify the workspace_name
attribute.
For OracleAS MapViewer administrative requests (discussed in Chapter 6), the following elements are related to Workspace Manager support:
<list_workspace_name>
<list_workspace_session>
The <list_workspace_name>
element returns the name of the current workspace, as specified with the workspace_name
attribute in the most recent map request. If no workspace has been specified (that is, if the workspace_name
attribute has not been specified in a map request in the current OracleAS MapViewer session), or if the LIVE
workspace has been specified, the LIVE
workspace is returned. If Workspace Manager is not currently installed in Oracle Database, the request fails.
Example 2-28 uses the <list_workspace_name>
element in an administrative request.
Example 2-28 <list_workspace_name> Element in an Administrative Request
<?xml version="1.0" standalone="yes"?>
<non_map_request>
<list_workspace_name data_source="mvdemo"/>
</non_map_request>
If wsp_1
is the current workspace, the response for Example 2-28 will be:
<?xml version="1.0" ?> <non_map_response> <workspace_name succeed="true" name="wsp_1"/> </non_map_response>
If no workspace has been specified or if the LIVE
workspace has been specified, the response for Example 2-28 will be:
<?xml version="1.0" ?> <non_map_response> <workspace_name succeed="true" name="LIVE"/> </non_map_response>
If Workspace Manager is not currently installed in Oracle Database, the response for Example 2-28 will be:
<?xml version="1.0" ?> <non_map_response> <workspace_name succeed="false"/> </non_map_response>
The <list_workspace_session>
element returns the names of the current workspace and current context. If no workspace has been specified (that is, if the workspace_name
attribute has not been specified in a map request in the current OracleAS MapViewer session), or if the LIVE
workspace has been specified, information for the LIVE
workspace is returned. If Workspace Manager is not currently installed in Oracle Database, the request fails.
Example 2-29 uses the <list_workspace_session>
element in an administrative request.
Example 2-29 <list_workspace_session> Element in an Administrative Request
<?xml version="1.0" standalone="yes"?>
<non_map_request>
<list_workspace_session data_source="mvdemo"/>
</non_map_request>
If wsp_1
is the current workspace and if the context is LATEST
, the response for Example 2-29 will be:
<?xml version="1.0" ?> <non_map_response> <workspace_session succeed="true" name="wsp_1" context="LATEST" context_type="LATEST"/> </non_map_response>
If no workspace has been specified or if the LIVE
workspace has been specified, and if the context is LATEST
, the response for Example 2-29 will be:
<?xml version="1.0" ?> <non_map_response> <workspace_session succeed="true" name="LIVE" context="LATEST" context_type="LATEST"/> </non_map_response>
If Workspace Manager is not currently installed in Oracle Database, the response for Example 2-29 will be:
<?xml version="1.0" ?> <non_map_response> <workspace_session succeed="false"/> </non_map_response>
The mapping metadata describing base maps, themes, and styles is stored in the global tables SDO_MAPS_TABLE, SDO_THEMES_TABLE, and SDO_STYLES_TABLE, which are owned by MDSYS. However, you should never directly update these tables. Each OracleAS MapViewer user has the following views available in the schema associated with that user:
USER_SDO_MAPS and ALL_SDO_MAPS contain information about base maps.
USER_SDO_THEMES and ALL_SDO_THEMES contain information about themes.
USER_SDO_STYLES and ALL_SDO_STYLES contain information about styles.
Note: You can use the Map Definition Tool (described in Chapter 7) to manage most mapping metadata. However, for some features you must use SQL statements to update the OracleAS MapViewer metadata views. |
The USER_SDO_xxx views contain metadata information about mapping elements (styles, themes, base maps) owned by the user (schema), and the ALL_SDO_xxx views contain metadata information about mapping elements on which the user has SELECT permission.
The ALL_SDO_xxx views include an OWNER column that identifies the schema of the owner of the object. The USER_SDO_xxx views do not include an OWNER column.
All styles defined in the database can be referenced by any user to define that user's themes, markers with a text style, or advanced styles. However, themes and base maps are not shared among users; so, for example, you cannot reference another user's themes in a base map that you create.
The following rules apply for accessing the mapping metadata:
If you need to add, delete, or modify any metadata, you must perform the operations using the USER_SDO_xxx views. The ALL_SDO_xxx views are automatically updated to reflect any changes that you make to USER_SDO_xxx views.
If you need only read access to the metadata for all styles, you should use the ALL_SDO_STYLES view. Both the OWNER and NAME columns make up the primary key; therefore, when you specify a style, be sure to include both the OWNER and NAME.
The OracleAS MapViewer metadata views are defined in the following file:
$ORACLE_HOME/lbs/admin/mapdefinition.sql
The following sections describe each set of views.
The USER_SDO_MAPS and ALL_SDO_MAPS views have the columns listed in Table 2-3.
Table 2-3 xxx_SDO_MAPS Views
Column Name | Data Type | Description |
---|---|---|
OWNER |
VARCHAR2 |
Schema that owns the base map (ALL_SDO_MAPS only) |
NAME |
VARCHAR2 |
Unique name to be associated with the base map |
DESCRIPTION |
VARCHAR2 |
Optional descriptive text about the base map |
DEFINITION |
CLOB |
XML definition of the list of themes and their scale value range information to be associated with the base map |
The USER_SDO_THEMES and ALL_SDO_THEMES views have the columns listed in Table 2-4.
Table 2-4 xxx_SDO_THEMES Views
Column Name | Data Type | Description |
---|---|---|
OWNER |
VARCHAR2 |
Schema that owns the theme (ALL_SDO_THEMES only) |
NAME |
VARCHAR2 |
Unique name to be associated with the theme |
DESCRIPTION |
VARCHAR2 |
Optional descriptive text about the theme |
BASE_TABLE |
VARCHAR2 |
Table or view containing the spatial geometry column |
GEOMETRY_COLUMN |
VARCHAR2 |
Name of the spatial geometry column (of type SDO_GEOMETRY) |
STYLING_RULES |
CLOB |
XML definition of the styling rules to be associated with the theme |
The USER_SDO_STYLES and ALL_SDO_STYLES views have the columns listed in Table 2-5.
Table 2-5 xxx_SDO_STYLES Views
Column Name | Data Type | Description |
---|---|---|
OWNER |
VARCHAR2 |
Schema that owns the style (ALL_SDO_STYLES only) |
NAME |
VARCHAR2 |
Unique name to be associated with the style |
TYPE |
VARCHAR2 |
One of the following values: COLOR, MARKER, LINE, AREA, TEXT, or ADVANCED |
DESCRIPTION |
VARCHAR2 |
Optional descriptive text about the style |
DEFINITION |
CLOB |
XML definition of the style |
IMAGE |
BLOB |
Image content (for example, |
GEOMETRY |
SDO_GEOMETRY |
(Reserved for future use) |
Depending on the Oracle Database release, the ALL_SDO_STYLES view may contain sample styles owned by the MDSYS schema. If these styles are defined on your system, you can specify them in theme definitions and map requests, and you can examine the XML definitions for ideas to use in defining your own styles.
To specify a style (or other type of OracleAS MapViewer object) that is owned by a schema other than the one for the current user, you must specify the schema name, and you must use a colon (:), not a period, between the schema name and the object name. The following excerpt from a <jdbc_query>
element refers to the style named C.RED
owned by the MDSYS schema:
<jdbc_query . . . render_style="MDSYS:C.RED"> . . . </jdbc_query>
Example 2-30 finds the names of all currently defined styles owned by the MDSYS schema, and it displays the type, description, and XML definition of one of the styles. (The example output is reformatted for readability.)
Example 2-30 Finding Styles Owned by the MDSYS Schema
SELECT owner, name FROM all_sdo_styles WHERE owner = 'MDSYS'; OWNER NAME -------------------------------- -------------------------------- MDSYS C.BLACK MDSYS C.BLACK GRAY MDSYS C.BLUE MDSYS C.COUNTIES MDSYS C.FACILITY . . . MDSYS L.MAJOR STREET MDSYS L.MAJOR TOLL ROAD MDSYS L.MQ_ROAD2 MDSYS L.PH MDSYS L.POOR_ROADS MDSYS L.PTH MDSYS L.RAILROAD MDSYS L.RAMP MDSYS L.SH MDSYS L.STATE BOUNDARY . . . MDSYS M.REDSQ MDSYS M.SMALL TRIANGLE MDSYS M.STAR MDSYS M.TOWN HALL MDSYS M.TRIANGLE MDSYS T.AIRPORT NAME MDSYS T.CITY NAME MDSYS T.MAP TITLE MDSYS T.PARK NAME MDSYS T.RED STREET MDSYS T.ROAD NAME MDSYS T.SHIELD1 MDSYS T.SHIELD2 MDSYS T.STATE NAME MDSYS T.STREET NAME . . . -- Display the type, description, and XML definition of one style. SET LONG 4000; SELECT owner, name, type, description, definition FROM all_sdo_styles WHERE name = 'L.PH'; OWNER NAME TYPE DESCRIPTION ------ ----- ------ ------------------ MDSYS L.PH LINE Primary highways DEFINITION --------------------------------------------------------------------------- <?xml version="1.0" standalone="yes"?> <svg width="1in" height="1in"> <desc></desc> <g class="line" style="fill:#33a9ff;stroke-width:4"> <line class="parallel" style="fill:#aa55cc;stroke-width:1.0"/> </g> </svg>