Custom Geometry Themes Themes

MapViewer Concepts 2-43 ?xml version=1.0 standalone=yes? styling_rules theme_type=wfs service_ url=http:localhost:1979geoserverwfsGetCapabilities? srs=EPSG:4326 hidden_info field column=NAME name=name field column=MAINPAGE name=mainpage hidden_info rule features style=M.STAR features label column=NAME style=T.STREET NAME 1 label rule styling_rules ; In Example 2–27 , the WFS feature POI is used as the base table, and the attribute THE_ GEOM is the spatial column. The styling rule information contains the service_url and srs information; and although not shown in Example 2–27 , it can also specify a key_column value. The features and label elements of the styling rules are similar to the rules used in geometry themes. Hidden information hidden_info element can also be defined and used in Oracle Maps applications. Example 2–28 shows a map request that uses the predefined theme created in Example 2–27 . Example 2–28 Map Request with Predefined WFS Theme ?xml version=1.0 standalone=yes? map_request title=Predefined WFS MAP datasource = mvdemo width=640 height=480 bgcolor=a6cae0 antialiase=true format=PNG_STREAM themes theme name=wfs_theme1 themes map_request See also the WFS map request examples in Section 3.1.14 . In some cases, proxy information may affect the access to WFS servers. If this occurs, specify the appropriate proxy parameters in the MapViewer configuration file.

2.3.8 Custom Geometry Themes

Custom geometry themes are associated with external spatial data spatial data in a native format other than Oracle Spatial, such as Shapefile. A custom geometry theme uses a spatial provider class to retrieve the native data, and the external provider must use the spatial data provider plug-in mechanism. MapViewer provides a spatial provider interface class that the external provider must implement. The interface implementation has the following methods: public interface SDataProvider { Returns the initialization parameter names for the provider. These names can be used by applications to populate user interface 2-44 Oracle Fusion Middleware Users Guide for Oracle MapViewer components. return public String[] getInitParameterNames; Returns runtime parameter names. Runtime parameters are additional parameters that the provider may use when retrieving the data objects. These names can be used by applications to populate user interface components. return public String[] getRuntimeParameterNames; This method is used to set the initialization parameters for the specific data provider. In mapViewer these parameters are defined on the configuration file, when registering the spatial provider. param params to be used by the initialization method. return true if success; false otherwise public boolean initProperties params; This method creates and returns an instance of SDataSet which contains the feature spatial data and attributes produced by this provider, based on the given parameters for a specific incoming map request. br MapViewer calls this method on the custom theme producer implementation. The SDataSet class stores for each feature its spatial representation and and the attribute values that are requested. param queryWin the search area to retrieve spatial objects. The window is assumed to be already on data provider spatial reference system. param nonSpatialColumns the list of attributes that will return with objects. param params parameters that the provider may use to retrieve the data. return an instance of SDataSet; null if failed. public SDataSet buildDataSetRectangle2D queryWin,String []nonSpatialColumns, Properties params; Returns the list of existing attributes for this data provider. param params parameters that the provider may use to get the attribute list. return public Field[] getAttributeListProperties params; Returns the data set spatial extent MBR. param params parameters that the provider may use to get the data extents return public Rectangle2D getDataExtentsProperties params; Builds a spatial index on the data set. param params parameters that the provider may use to build the spatial MapViewer Concepts 2-45 index. return public boolean buildSpatialIndexProperties params; } The init and buildDataSet methods must be implemented. The other method implementations can be empty; however applications such as the Oracle Map Builder Tool can make use of these methods to handle the information about spatial data providers. A provider can implement its own spatial indexing mechanism; MapViewer offers an implementation for the Shapefile provider, and the buildSpatialIndex method creates an indexing file with the .oix extension in the shapefile directory. Appendix D contains an example of how to implement and register a sample spatial provider with MapViewer. To render native data in MapViewer with custom geometry themes, follow these steps: 1. Implement a spatial provider class based on the plug-in interface, and generate a jar file with the provider implementation. Copy the jar file to a directory that is part of the MapViewer CLASSPATH definition. 2. Register the provider in the MapViewer configuration file. MapViewer already offers a spatial provider implementation for the Shapefile format, and its registration section in the configuration file looks like this: s_data_provider id=shapefileSDP class=oracle.sdovis.ShapefileDataProvider parameters parameter name=datadir value=tempdata parameters s_data_provider Each provider must have id and class names defined: id is a unique name that identifies the provider, and class corresponds to the Java class implementation. The parameters element defines the initialization parameters of the provider. For the Shapefile provider, the initialization parameter datadir defines where MapViewer will look for the data files, and thus it should be a directory that is accessible to MapViewer. MapViewer first looks for data files based on the theme definition information; and if the data path defined in the theme definition is not accessible, MapViewer looks for the data path defined in the configuration file. 3. Create custom geometry themes associated with the external spatial data provider. Although the external spatial data is outside the Oracle database, you still need to have a database connection to render this data. The database is used to store the metadata information related with the theme, as well as the styling information used to render and to label the data. Example 2–29 shows the definition for a dynamic custom geometry theme. The XML element custom_geom_theme identifies a custom geometry theme. The parameters element defines the runtime parameters to be used by the provider. In this case filename is a runtime parameter, and lbsdemoshapefileparcel.shp defines the file path. MapViewer first attempts to use this file path definition; but if it is not accessible, it uses the data directory value defined in the configuration file for the Shapefile spatial provider. 2-46 Oracle Fusion Middleware Users Guide for Oracle MapViewer Example 2–29 Defining a Dynamic Custom Geometry Theme theme name=custom_geom_theme_1 custom_geom_theme provider_id=shapefileSDP srid=26986 render_style=C.RED label_column=parcel_id label_style=T.CITY NAME datasource=mvdemo parameters parameter name=filename value=lbsdemoshapefileparcel.shp parameters custom_geom_theme theme The available attributes for a dynamic custom geometry theme are: ■ provider_id specifies the spatial provider. ■ datasource specifies the Oracle database connection. This connection is used to retrieve the styles to render the spatial data. ■ srid specifies the spatial reference system Oracle Spatial coordinate system. ■ render_style specifies the style to be used when rendering the features. ■ label_column specifies the name of the column containing label text to be used with the theme. ■ label_style specifies the style to be used when labeling the features. ■ feature_attributes specifies additional attributes that can be used with advanced styles. ■ key_column specifies a key attribute that can be used in Oracle Maps applications. Example 2–30 shows how to store a predefined custom geometry theme definition. Use GEOMETRY as the geometry column name, and you can specify any name for the base table name. The theme_type=geom_custom attribute identifies the theme as a custom theme. The rule element has the same function as for an Oracle Spatial geometry theme. The parameters element defines the runtime parameters that the provider accepts. For the Shapefile provider, the runtime parameter filename defines the path to the Shapefile data. Example 2–30 Storing a Predefined Custom Geometry Theme insert into user_sdo_themes values SHAPE_THEME, Shapefile theme, CUSTOM_TABLE, GEOMETRY, ?xml version=1.0 standalone=yes? styling_rules theme_type=geom_custom srid=26986 provider_id=shapefileSDP rule features style=C.RED features label column=PARCEL_ID style=T.CITY NAME 1 label rule parameters parameter name=filename value=lbsdemoshapefileparcel.shp parameters styling_rules MapViewer Concepts 2-47 ; You can override the runtime parameters section of a predefined custom geometry theme by the specifying the parameters in a map_request. For example, you can include the following in a map_request element: theme name=CUSTOM_THEME parameters parameter name=filename value=lbsdemoshapefilecounties.shp parameters theme

2.3.9 Annotation Text Themes