1 Introduction to MapViewer

Oracle Mapviewer (MapViewer) is a programmable tool for rendering maps using spatial data managed by Oracle Spatial or Oracle Locator (also referred to as Locator). MapViewer provides tools that hide the complexity of spatial data queries and cartographic rendering, while providing customizable options for more advanced users. These tools can be deployed in a platform-independent manner and are designed to integrate with map-rendering applications.

This chapter contains the following major sections:

1.1 Overview of MapViewer

MapViewer is shipped as part of Oracle Fusion Middleware. Its main deliverable is a J2EE application that can be deployed to a J2EE container, such as that for Oracle Fusion Middleware. MapViewer includes the following main components:

  • A core rendering engine (Java library) named SDOVIS that performs cartographic rendering. A servlet is provided to expose the rendering functions to Web applications.

  • A suite of application programming interfaces (APIs) that allow programmable access to MapViewer features. These APIs include XML, Java, PL/SQL, and an AJAX-based JavaScript API.

  • A graphical Map builder tool that enables you to create map symbols, define spatial data rendering rules, and create and edit MapViewer objects.

  • Oracle Map, which includes map cache and FOI (feature of interest) servers that facilitate the development of interactive geospatial Web applications.

The core rendering engine connects to the Oracle database through Java Database Connectivity (JDBC). It also reads the map metadata (such as map definitions, styling rules, and symbologies created through the Map Builder tool) from the database, and applies the metadata to the retrieved spatial data during rendering operations.

The XML API provides application developers with a versatile interface for submitting a map request to MapViewer and retrieving the map response. The JavaBean-based API and the PL/SQL API provide access to MapViewer's rendering capabilities. The JavaScript API enables you to create highly interactive web applications that use the Oracle Maps feature of MapViewer.

The Map Builder tool simplifies the process of creating and managing map, theme, and symbology metadata in a spatial database. For information about this tool, see Chapter 9.

Oracle Maps, built on core MapViewer features, uses a map tile server that caches map image tiles, and a feature of interest (FOI) server that streams live data out of a database to be displayed as interactive features on a map. You can use the AJAX-based JavaScript API with Oracle Maps to provide sophisticated mapping solutions. Oracle Maps also allows for advanced customization and querying capabilities.

The primary benefit of MapViewer is its integration with Oracle Spatial, Oracle Locator, and Oracle Fusion Middleware. MapViewer supports two-dimensional vector geometries stored in Oracle Spatial, as well as GeoRaster data and data in the Oracle Spatial topology and network data models. Oracle MapViewer is also an Open Geospatial Consortium (OGC)-compliant Web Map Service (WMS) server.

1.1.1 Basic Flow of Action with MapViewer

With MapViewer, the basic flow of action follows a two-step request/response model, whether the client requests a map or some MapViewer administrative action.

For a map request:

  1. The client requests a map, passing in the map name, data source, center location, map size, and, optionally, other data to be plotted on top of a map.

  2. The server returns the map image (or a URL for the image) and the minimum bounding rectangle (MBR) of the map, and the status of the request.

For a MapViewer administrative request:

  1. The client requests a MapViewer administrative action, passing in the specific type of request and appropriate input values.

  2. The server returns the status of the request and the requested information.

Figure 1-1 shows the basic flow of action with MapViewer.

Figure 1-1 Basic Flow of Action with MapViewer

Description of Figure 1-1 follows
Description of "Figure 1-1 Basic Flow of Action with MapViewer"

1.1.2 MapViewer Architecture

Figure 1-2 illustrates the architecture of MapViewer.

Figure 1-2 MapViewer Architecture

Description of Figure 1-2 follows
Description of "Figure 1-2 MapViewer Architecture"

As shown in Figure 1-2:

  • MapViewer is part of the Oracle Fusion Middleware middle tier.

  • MapViewer includes a rendering engine.

  • MapViewer can communicate with a client Web browser or application using the HTTP protocol.

  • MapViewer performs spatial data access (reading and writing Oracle Spatial and Oracle Locator data) through JDBC calls to the database.

  • The database includes Oracle Spatial or Oracle Locator, as well as mapping metadata.

1.2 Getting Started with MapViewer

To get started using MapViewer, follow these steps:

  1. Either before or after you install and deploy MapViewer, read Chapter 2 to be sure you understand important terms and concepts.

  2. Ensure that you have the prerequisite software (see Section 1.3).

  3. Install (if necessary) and deploy MapViewer (see Section 1.4).

  4. Use MapViewer for some basic tasks. For example, create an Oracle Maps application (see Chapter 8.

  5. Optionally, use the Map Builder tool (described in Chapter 9) to familiarize yourself with styles, themes, and maps, and the options for each, and optionally to preview spatial data.

1.3 Prerequisite Software for MapViewer

To use MapViewer, you must have the following software:

  • A J2EE server supported by Oracle MapViewer (see http://www.oracle.com/technology/products/mapviewer/htdocs/j2ee_server_support.html)

  • Oracle Database with Spatial or Locator (Release 9i or later)

  • Oracle Client (Release 9i or later), if you need to use JDBC Oracle Call Interface (OCI) features. Note that in general, the JDBC thin driver is recommended for use with MapViewer, in which case Oracle Client is not required.

  • Java SDK 1.5 or later

MapViewer also supports the headless AWT mechanism in J2SE SDK, which enables MapViewer to run on Linux or UNIX systems without setting any X11 DISPLAY variable. To enable AWT headless mode on Linux or UNIX systems, specify the following in the command line to start MapViewer:

-Djava.awt.headless=true

1.4 Installing and Deploying MapViewer

This section describes how to install (if necessary) and deploy MapViewer to run in the middle tier. As mentioned previously, MapViewer runs as a J2EE Web application and listens for incoming map requests on the container's HTTP port.

You can deploy MapViewer either in a full Oracle Fusion Middleware environment or to a standalone installation of OC4J. Choose the procedure that applies to your needs:

  • If you have already installed WebLogic Server 10 or later and you want deploy MapViewer to it, follow the instructions in Section 1.4.1.

  • If you have already installed Oracle Fusion Middleware and you want to deploy MapViewer to that instance, follow the instructions in Section 1.4.2.

  • If you have not installed Oracle Fusion Middleware, but have installed the OC4J standalone kit and now want to install and deploy MapViewer, follow the instructions in Section 1.4.3. OC4J standalone is a small footprint J2EE container and Web server provided by Oracle.

  • Alternatively, you can download the latest MapViewer Quick Start kit from the MapViewer page on the Oracle Technology Network (OTN). This kit includes a standalone OC4J with MapViewer already deployed and configured. It takes only minutes to get MapViewer running, and is convenient for testing and basic development.

Regardless of where and how MapViewer is deployed, the application server (or standalone OC4J) will create a home directory for MapViewer during deployment. This directory is typically located under the following directory:

$ORACLE_HOME/j2ee/<oc4j_instance_name>/applications

$ORACLE_HOME is the top directory of either the Application Server or standalone OC4J install. The value for <oc4j_instance_name> is typically home if deployed to standalone OC4J, or the name of the target OC4J instance if deployed to a full Oracle Fusion Middleware installation. This MapViewer directory is typically named mapviewer (or the same as the context path under which MapViewer is deployed), and has many subdirectories. You may wish to familiarize yourself with some of the subdirectories in case you want to perform debugging, administration, or manual configuration.

The following are the main subdirectories of a MapViewer deployment:

/mapviewer
   sql/
   web/
       fsmc/
       WEB-INF/
            lib/
            conf/
            log/
            mapcache/
            classes/
            admin/

The /mapviewer/sql directory contains several SQL scripts that are necessary for installing the MapViewer PL/SQL API package into the database. The /mapviewer/web/fsmc directory contains the JavaScript API library and several tutorials for Oracle Maps. The /mapviewer/web/WEB-INF directory and its subdirectories contain libraries and MapViewer administration and configuration files.

If you want to use GeoRaster themes to view GeoRaster data, after successfully deploying MapViewer you may need to ensure that certain JAI (Java Advanced Imaging) library files are in the MapViewer Java classpath. The library files are jai_core.jar, jai_codec.jar, and jai_imageio.jar, and they can be found in a full Oracle Fusion Middleware or Oracle Database installation, usually under the directory for Oracle Multimedia (formerly called Oracle interMedia) files. You can copy them into the MapViewer WEB-INF/lib directory.

For annotation themes, MapViewer uses the JAXB 2.x libraries jsr173_api.jar, jaxb-api.jar, jaxb-impl.jar, and activation.jar. If you deploy MapViewer with a 10g OC4J instance, you must copy these files to a directory in the MapViewer CLASSPATH definition, such as the WEB-INF/lib directory.

1.4.1 Deploying MapViewer in a WebLogic Server Environment

This section explains how to deploy MapViewer to WebLogic Server Version 10 or 10.3. (Deployment to earlier WebLogic versions has not been tested.) For the deployment:

  • MapViewer must be deployed from an exploded directory.

  • The WebLogic console is used in this section, although you could also use the WLS command line instead.

  • A new WebLogic domain is created to host MapViewer. This approach is recommend because MapViewer is a resource-intensive application, and it is better to run it in a separate environment such as its own domain. However, it is also possible (although not recommended) to deploy MapViewer to an existing WebLogic domain.

The main steps for deploying MapViewer to WebLogic Server are the following:

  1. Unpack the MapViewer EAR Archive.

  2. Configure WebLogic Server.

  3. Deploy and Start MapViewer in WebLogic Server.

  4. As needed, use the MapViewer Administration Page.

1.4.1.1 Unpacking the MapViewer EAR Archive

You must deploy MapViewer from an exploded directory, that is, a directory where mapviewer.ear has already been unpacked. (If you instead, and incorrectly, deploy from the unpacked mapviewer.ear file, MapViewer will fail at run time.)

You can unpack the mapveiwer.ear archive to any directory on the server where WebLogic is running. This directory will become the working folder of your MapViewer installation, in that MapViewer will (by default) read the configuration file from this location, and will save generated map images to a folder under this directory. It is recommended that the directory be a permanent (not temporary) one. It can be a shared directory if you want the same MapViewer binaries to be deployed to multiple WebLogic servers running on multiple hosts.

In the following instructions, assume that you have created a directory named /ul/mapviewer as the top MapViewer directory. (If you create another directory, adapt the instructions accordingly.) Follow these steps:

  1. Copy mapviewer.ear into /ul/mapviewer.

  2. If /ul/mapviewer is not already your current directory, go there.

  3. Rename mapviewer.ear to mapviewer1.ear.

  4. Create a subdirectory named mapviewer.ear.

  5. Unpack mapviewer1.ear into mapviewer.ear (that is, into /ul/mapviewer/mapviewer.ear).

  6. Go to mapviewer.ear.

  7. Rename web.war to web1.war.

  8. Create a subdirectory named web.war.

  9. Unzip web1.war into web.war (that is, into /ul/mapviewer/mapviewer.ear/web.war).

  10. Modify the Mapviewer configuration file (/ul/mapviewer/mapviewer.ear/web.war/WEB-INF/conf/mapViewerConfig.xml) as needed, such as to change its logging level or to add permanent data source definitions. You can also modify this configuration file at any time later.

MapViewer is now unpacked and configured. You must next ensure that WebLogic Server is properly configured for MapViewer, so that you will be able to deploy and run MapViewer in WebLogic Server.

1.4.1.2 Configuring WebLogic Server

To configure WebLogic Server, follow these steps:

  1. Create a new WebLogic domain to host MapViewer by running the following script:

    $BEA_HOME/wlserver_10.0/common/bin/config.sh
    

    This script starts a configuration wizard. It is suggested that you name the administration user weblogic; although if you use a different name, you can specify it when you configure MapViewer. You will use the administration user to log in to the MapViewer Administration page.

  2. Start the domain by running the following script:

    $BEA_HOME/user_projects/domains/map-domain/startWebLogic.sh
    

    where map-domain is the name of the domain that you created in step 1.

1.4.1.3 Deploying and Starting MapViewer in WebLogic Server

After the new domain is running, you can log in to its console to start deploying MapViewer. Follow these steps.

  1. Log in to the console, which is typically accessed at:

    http://<host>:7001/console
    

    where <host> is the host name or IP address of the system running WebLogic server.

  2. In the Change Center, if a Lock & Edit button is visible, click it.

    If a Lock & Edit button is not visible, go to the next step. If this button is not visible, it probably means that the WebLogic server has been configured with the Automatically Acquire Lock and Activate Changes option enabled.

  3. Under Domain Structure, click Deployments.

    The administration console page will look similar to Figure 1-3.

    Figure 1-3 WebLogic Administration Console (Deployments)

    Description of Figure 1-3 follows
    Description of "Figure 1-3 WebLogic Administration Console (Deployments)"

  4. Under Deployments, click Install.

    The next page is displayed, as shown in Figure 1-4. Note that the location of the MapViewer directory (/ul/mapviewer/mapviewer.ear in this case) is the name of the directory, not the name of the .ear file.

    Figure 1-4 WebLogic Administration Console (Location)

    Description of Figure 1-4 follows
    Description of "Figure 1-4 WebLogic Administration Console (Location)"

  5. Click Next.

  6. Select Install this deployment as an application, and click Next.

    A page with the Source Accessibility section is displayed, as shown in Figure 1-5

    Figure 1-5 WebLogic Administration Console (Source Accessibility)

    Description of Figure 1-5 follows
    Description of "Figure 1-5 WebLogic Administration Console (Source Accessibility)"

  7. In the Source Accessibility section, select I will make the deployment accessible from the following location.

    This option causes the unpacked MapViewer location to becomes the "working" directory of MapViewer. It also makes it easier if you want to upgrade MapViewer in the future, in which case you simply unpack the new mapviewer.ear file to this directory and restart WebLogic Server.

  8. Click Finish, to start the deployment of MapViewer.

  9. If the WebLogic server has been configured with the Automatically Acquire Lock and Activate Changes option enabled, skip the rest of this step and go to the next step when the deployment is finished.

    If the WebLogic server has not been configured with the Automatically Acquire Lock and Activate Changes option enabled, when the deployment is finished, go to the Change Center, and click Activate Changes and then Release Configuration to complete the deployment process.

  10. Start MapViewer by selecting mapviewer from Deployments, clicking Start, and selecting Servicing all requests, as shown in Figure 1-6

    Figure 1-6 WebLogic Administration Console (Starting MapViewer)

    Description of Figure 1-6 follows
    Description of "Figure 1-6 WebLogic Administration Console (Starting MapViewer)"

  11. Go to the following location to access MapViewer.

    http://<host>:7001/mapviewer
    

    where <host> is the host name or IP address of the system running WebLogic server.

1.4.1.4 Using the MapViewer Administration Page

When you first click the Admin button on the MapViewer home page, you are prompted for login information. You can use the default WebLogic administration account user name of weblogic to log in; however, if your WebLogic domain administration account uses a different user name, you must change the MapViewer weblogic.xml file, located in $MAPVIEWER_HOME/mapviewer.ear/web.war/WEB-INF/.

To change the weblogic.xml file, open it is a text editor and replace the two occurrences of weblogic with the actual administration account name. The following except shows the lines with the name to be replaced:

<security-role-assignment>
    <role-name>map_admin_role</role-name>
    <principal-name>weblogic</principal-name>
</security-role-assignment>
 
<security-role-assignment>
    <role-name>secure_maps_role</role-name>
    <principal-name>weblogic</principal-name>
</security-role-assignment>

1.4.2 Deploying MapViewer in an Oracle Fusion Middleware 10gR3 Environment

If you have already successfully installed Oracle Fusion Middleware 10gR3, you can deploy the MapViewer using the Oracle Enterprise Manager Server Control web interface. The main steps are the following:

  1. Select an OC4J instance as the target for deploying MapViewer. You can select an existing OC4J instance, or create a new instance specifically for MapViewer. It is suggested that you create a new instance for MapViewer, but it is not required.

  2. Locate the mapviewer.ear file. This file is either shipped with the Oracle Fusion Middleware 10gR3 software or can be downloaded from OTN.

  3. Deploy the mapviewer.ear file to the selected OC4J instance using the Server Control web interface, or use Oracle Fusion Middleware 10gR3 command-line admin tool to deploy MapViewer (or any other J2EE application). For information about using the admin tool, see the Oracle Fusion Middleware Administration Guide.

To start deploying MapViewer, navigate to the Oracle Fusion Middleware 10gR3 Server Control page and select the desired OC4J instance, as shown in Figure 1-7, where the default home OC4J instance is selected.

Figure 1-7 Starting MapViewer Deployment

Description of Figure 1-7 follows
Description of "Figure 1-7 Starting MapViewer Deployment"

Click Deploy to display a page (shown in Figure 1-8) in which you enter the location of the mapviewer.ear file (a directory named tmp in this figure).

Figure 1-8 Specifying the mapviewer.ear Location

Description of Figure 1-8 follows
Description of "Figure 1-8 Specifying the mapviewer.ear Location"

Click Next to display a page (shown in Figure 1-9) in which you specify the name of the application.

Figure 1-9 Specifying the Application Name

Description of Figure 1-9 follows
Description of "Figure 1-9 Specifying the Application Name"

For Application Name, specify mapviewer. The Context Root will be set to /mapviewer by default. Do not use any other value for Context Root. Using any other value will prevent MapViewer from operating.

Click Next to display the Deployment Setting page. You usually do not need to change any of the settings on this page.

Click Deploy on the Deployment Setting page to start the deployment of MapViewer. If the deployment is successful, the Confirmation page is displayed indicating that deployment of the application was successful.

After you complete the deployment, see Section 1.4.4.

1.4.3 Installing MapViewer with a Standalone Installation of OC4J

To install and deploy MapViewer with a standalone installation of OC4J, you must have installed OC4J on your system. The standalone OC4J installation kit is a single zip file that you can download from OTN. It contains the Oracle Container for J2EE and also a lightweight Web server. After you unzip this file, you can start the OC4J instance up by entering the command java –jar oc4j.jar from the $OC4J_HOME/j2ee/home directory, where $OC4J_HOME is the top directory into which you unzipped the installation file.

Note that you must have the Java 1.5 SDK installation, not the JRE installation, in your environment path in order for OC4J to start up and function properly.

Because standalone OC4J version 10.1.3 (or later) comes with its own Server Control Web interface, the deployment of MapViewer is almost exactly as described in Section 1.4.2 once you log into its Server Control Web page. The only difference is that you will not be able to choose a different OC4J instance, because you are running in a single standalone OC4J instance.

After you complete the deployment, see Section 1.4.4.

1.4.4 After Deploying MapViewer

After successfully deploying MapViewer to Oracle Fusion Middleware 10gR3, standalone OC4J, or WebLogic Server, you may want to verify whether it is actually working, as described in Section 1.4.4.1. It is also a good idea to become familiar with its Web interface, particularly the administration pages.

You must also run at least one, and perhaps several, SQL scripts, as explained in Section 1.4.4.2.

1.4.4.1 Verifying That the Deployment Was Successful

To test if the MapViewer server has started correctly, point your browser to that OC4J instance. For example, if MapViewer is installed on a system named www.example.com and the HTTP port is 8888, enter the following URL to invoke the MapViewer server with a simple get-version request:

http://www.example.com:8888/mapviewer/omserver?getv=t

If MapViewer is running correctly, it should immediately send back a response text string indicating the version and build number, such as the following:

Ver10131_B060225

The actual version and build number will reflect the version that you installed.

If the server has not been started and initialized correctly, there will be no response, or the message 500 internal server error will be displayed.

If the response message includes wording like MapServer is not ready. Please try again later, it could mean that the MapViewer server is initializing, but the process will take some additional time (for example, because the system is slow or because multiple predefined data sources are specified in the configuration file and MapViewer is attempting to connect to these databases). In this case, you can wait at least a few seconds and try the preceding request again.

However, if you continue to get this response message, there may be a problem with the deployment. Check for any error messages, either in the OC4J console for a standalone OC4J deployment or in the redirected output/errors log file of the OC4J instance for a full Oracle Fusion Middleware 10gR3 deployment. The following are common causes of this problem:

  • On a UNIX or Linux operating system, the Java virtual machine (JVM) was not started with the –Djava.awt.headless=true option, and no DISPLAY environment variable is set. This causes the MapViewer server to fail because the server accesses the Java graphics library, which on UNIX and Linux systems relies on the X11 windowing system.

  • You deployed the mapviewer.ear file to an incompatible version of Oracle Fusion Middleware or standalone OC4J. Note that the MapViewer 10.1.3.1 must be deployed to Application Server 10gR3 (or standalone OC4J) 10.1.3 or later. It will not work properly with earlier versions of Oracle Application Server or OC4J.

1.4.4.2 Running SQL Scripts

This section describes SQL scripts, one or more of which you must run while connected as the MDSYS user. For each script that you run, you must run it on each target Oracle database from which MapViewer will render spatial data.

MapViewer uses a set of system views to store necessary mapping metadata in a target database. A target database is a database with Oracle Spatial or Oracle Locator (Release 8.1.6 or later) installed and from which you want MapViewer to be able to render maps. MapViewer requires following system views:

  • USER_SDO_MAPS

  • USER_SDO_THEMES

  • USER_SDO_STYLES

  • USER_SDO_CACHED_MAPS

The USER_SDO_CACHED_MAPS view is used by the Oracle Maps feature. It stores definitions of map tile cache instances. You must create this view manually by running the following script while connected as the SYS user:

$MV_HOME/web/WEB-INF/admin/mcsdefinition.sql

If the target database is release 9.2 or later, the other three views (USER_SDO_MAPS, USER_SDO_THEMES, and USER_SDO_STYLES) are created and populated automatically. However, if the target database has a release number lower than 9.2, you must manually create and populate these views by running the following scripts while connected as the MDSYS user:

$MV_HOME/web/WEB-INF/admin/mapdefinition.sql

$MV_HOME/web/WEB-INF/admin/defaultstyles.sql

1.4.4.3 Creating MapViewer Array Types, if Necessary

For each database schema that it connects to, MapViewer checks for the existence of the following SQL array types that support array-type binding variables that might exist in some predefined themes:

  • MV_STRINGLIST

  • MV_NUMBERLIST

  • MV_DATELIST

If these types do not exist, MapViewer attempts to create them in the database schema associated with the MapViewer data source. However, if the user associated with that schema does not have sufficient privileges to create new types, a privileged user must create the types by connecting to the data source schema and entering the following statements:

CREATE or REPLACE type MV_STRINGLIST as TABLE of VARCHAR2(1000);
CREATE or REPLACE type MV_NUMBERLIST as TABLE of NUMBER;
CREATE or REPLACE type MV_DATELIST as TABLE of DATE;

1.5 Administering MapViewer

This section introduces the MapViewer Administration page and some administrative and configuration tasks that you can perform, such as adding new data sources, managing map tile layers used by Oracle Maps, and setting logging levels.

1.5.1 Logging in to the MapViewer Administration Page

After you have verified that MapViewer is running properly, it is suggested that you log in to the MapViewer Administration page. To do this, go first to the MapViewer Welcome page, which is typically http://<host>:<port>/mapviewer, where <host> and <port> should be replaced by the correct value for your installation. Figure 1-10 shows the MapViewer Welcome page

Figure 1-10 MapViewer Welcome Page

Description of Figure 1-10 follows
Description of "Figure 1-10 MapViewer Welcome Page"

Click the Admin icon at the top right or text link at the bottom. A login prompt is displayed, asking for user name and password for the MapViewer administration page.

User Name: Enter oc4jadmin.

Password: Enter the password that you use to log into the Server Control page of the Oracle Fusion Middleware or OC4J standalone installation.

After you log in, the MapViewer administration page is displayed, as shown in Figure 1-11.

Figure 1-11 MapViewer Administration Page

Description of Figure 1-11 follows
Description of "Figure 1-11 MapViewer Administration Page"

You can use this page to perform administrative tasks, such as configuring MapViewer to your site's specific requirements, adding predefined data sources so that MapViewer will automatically connect to the specified target database whenever it is started, and managing map tile layers. For detailed about configuration tasks, see Section 1.5.2; for information about administrative tasks, see Section 1.5.3.

1.5.2 Configuring MapViewer

If the default configuration settings for running MapViewer are not adequate, you can configure MapViewer by editing the MapViewer configuration file, mapViewerConfig.xml, which is located in the $ORACLE_HOME/lbs/mapviewer/web/WEB-INF/conf directory. To modify this file, you can use a text editor, or you can use the MapViewer Administration page.

After you modify this file, you must restart OC4J to have the changes take effect; however, you can instead use the MapViewer Administration page to restart only the MapViewer servlet (instead of the entire OC4J instance, which may have other applications deployed and running) if either of the following applies:

  • You installed MapViewer with a standalone OC4J instance.

  • The MapViewer OC4J instance with Oracle Fusion Middleware is configured to have only one OC4J process running (the default) and not to be clustered (that is, not to be in an island).

    If you deployed MapViewer to an OC4J instance with multiple processes (thus with multiple physical JVMs on the same host), or if you deployed to an OC4J instance that is in a clustered island (with multiple OC4J instances running on multiple hosts), you must restart the OC4J instance itself for the changes to the MapViewer configuration file to take effect in all MapViewer servers. In the latter case (clustered OC4J instances), you may also need to modify the MapViewer configuration file in the MapViewer directory hierarchy for each host's OC4J instance in the cluster. For more information about repository-based middle-tier clustering, see Oracle Fusion Middleware High Availability Guide.

The MapViewer configuration file defines the following information in XML format:

  • Logging information, defined either through container-controlled logging (recommended) or in the <logging> element (see Section 1.5.2.1)

  • Map image file information, defined in the <save_images_at> element (see Section 1.5.2.2)

  • Administrative request restrictions, defined in the <ip_monitor> element (see Section 1.5.2.3)

  • Web proxy information for accessing external information across a firewall, defined in the <web_proxy> element (see Section 1.5.2.4)

  • Global map "look and feel" configuration, defined in the <global_map_config> element (see Section 1.5.2.5)

  • Internal spatial data cache settings, defined in the <spatial_data_cache> element (see Section 1.5.2.6)

  • Custom image renderer registration, defined in the <custom_image_renderer> element (see Appendix C)

  • Permanent map data sources, defined in the <map_data_source> element (see Section 1.5.2.14)

  • Security configurations, defined in the <security_config> element

  • WMS services configurations, defined in the <wms_config> element

  • External attribute data provider registration, defined in <ns_data_provider> elements

  • Map tile server configurations, defined in the <map_tile_server> element

All path names in the mapViewerConfig.xml file are relative to the directory in which the file is stored, unless otherwise specified.

Example 1-1 shows a sample mapViewerConfig.xml file.

Example 1-1 Sample MapViewer Configuration File

<?xml version="1.0" ?>
<!-- This is the configuration file for MapViewer. -->
<!-- Note: All paths are resolved relative to this directory (where 
           this config file is located), unless specified as an absolute 
           path name.
 -->
 
<MapperConfig>
 
  <!-- ****************************************************************** -->
  <!-- ************************ Logging Settings ************************ -->
  <!-- ****************************************************************** -->
 
  <!-- Uncomment the following to modify logging. Possible values are:
       log_level = "fatal"|"error"|"warn"|"info"|"debug"|"finest"  
                 default: info) ;
       log_thread_name = "true" | "false" ;
       log_time = "true" | "false" ;
       one or more log_output elements.
  -->
  <!--
    <logging log_level="info" log_thread_name="false"
             log_time="true">
       <log_output name="System.err" />
       <log_output name="../log/mapviewer.log" />
    </logging>
  -->
 
  <!-- ****************************************************************** -->
  <!-- ********************** Map Image Settings ************************ -->
  <!-- ****************************************************************** -->
 
  <!-- Uncomment the following only if you want generated images to 
       be stored in a different directory, or if you want to customize
       the life cycle of generated image files.
 
       By default, all maps are generated under 
       $ORACLE_HOME/lbs/mapviewer/web/images. 
 
       Images location-related attributes:
       file_prefix: image file prefix, default value is "omsmap"
       url:  the URL at which images can be accessed. It must match the 'path'
             attribute below. Its default value is "%HOST_URL%/mapviewer/images"
       path: the corresponding path in the server where the images are
             saved; default value is "%ORACLE_HOME%/lbs/mapviewer/web/images"
 
       Images life cycle-related attributes:
       life: the life period of generated images, specified in minutes. 
             If not specified or if the value is 0, images saved on disk will 
             never be deleted. 
       recycle_interval:  this attribute specifies how often the recycling 
             of generated map images will be performed. The unit is minute.
             The default interval (when not specified or if the value is 0) 
             is 8*60, or 8 hours.
             
   -->
  <!--
   <save_images_at  file_prefix="omsmap"
                   url="http://mypc.mycorp.com:8888/mapviewer/images"
                   path="../web/images"
   /> 
  -->
 
  <!-- ****************************************************************** -->
  <!-- ********************* IP Monitoring Settings ********************* -->
  <!-- ****************************************************************** -->
 
  <!-- Uncomment the following to enable IP filtering for administrative 
        requests.
    Note:
    - Use <ips> and <ip_range> to specify which IPs (and ranges) are allowed.
      Wildcard form such as 20.* is also accepted. Use a comma-delimited 
      list in <ips>.
 
    - Use <ips_exclude> and <ip_range_exclude> for IPs and IP ranges
      prohibited from accessing eLocation.
 
    - If an IP falls into both "allowed" and "prohibited" categories, it is
      prohibited.
 
    - If you put  "*" in an <ips> element, then all IPs are allowed, except
      those specified in <ips_exclude> and <ip_range_exclude>.
      On the other hand, if you put "*" in an <ips_exclude> element, no one
      will be able to access MapViewer (regardless of whether an IP is in
      <ips> or <ip_range>).
 
    - You can have multiple <ips>, <ip_range>, <ips_exclude>, and
      <ip_range_exclude> elements under <ip_monitor>.
 
    - If no <ip_monitor> element is present in the XML configuration
      file, then no IP filtering will be performed (all allowed).
 
    - The way MapViewer determines if an IP is allowed is:
 
          if(IP filtering is not enabled) then allow;
          if(IP is in exclude-list) then not allow;
          else if(IP is in allow-list) then allow;
          else not allow;  
   -->
 
  <!--
     <ip_monitor>
          <ips> 138.1.17.9, 138.1.17.21, 138.3.*, 20.* </ips>
          <ip_range> 24.17.1.3 - 24.17.1.20 </ip_range>
          <ips_exclude> 138.3.29.* </ips_exclude>
          <ip_range_exclude>20.22.34.1 - 20.22.34.255</ip_range_exclude>
     </ip_monitor>
   -->
 
  <!-- ****************************************************************** -->
  <!-- ********************** Web Proxy Setting  ************************ -->
  <!-- ****************************************************************** -->
  <!-- Uncomment and modify the following to specify the Web proxy setting.
       This is only needed for passing background image URLs to
       MapViewer in map requests or for setting a logo image URL, if
       such URLs cannot be accessed without the proxy.
   -->
 
  <!--
    <web_proxy host="www-proxy.my_corp.com"  port="80" />
  -->
 
  <!-- ****************************************************************** -->
  <!-- *********************** Security Configuration ******************* -->
  <!-- ****************************************************************** -->
  <!-- Here you can set various security related configurations of MapViewer.
  -->
 
  <security_config>
    <disable_direct_info_request> false </disable_direct_info_request>
  </security_config>
 
  <!-- ****************************************************************** -->
  <!-- *********************** Global Map Configuration ***************** -->
  <!-- ****************************************************************** -->
  <!-- Uncomment and modify the following to specify systemwide parameters
       for generated maps. You can specify your copyright note, map title, and
       an image to be used as a custom logo shown on maps. The logo image must 
       be accessible to this MapViewer and in either GIF or JPEG format.
       Notes:
         -  To disable a global note or title, specify an empty string ("") for
            the text attribute of <note> and <title> element.
         - position specifies a relative position on the map where the
                  logo, note, or title  will be displayed. Possible values are
                  NORTH, EAST, SOUTH, WEST, NORTH_EAST, SOUTH_EAST,
                  SOUTH_WEST, NORTH_WEST, and CENTER.
         - image_path specifies a file path or a URL (starts with "http://")
                    for the image.
 
       <rendering> element attributes:
       - Local geodetic data adjustment: If allow_local_adjustment="true",
         MapViewer automatically performs local data
         "flattening" with geodetic data if the data window is less than
         3 decimal degrees. Specifically, MapViewer performs a simple
         mathematical transformation of the coordinates using a tangential
         plane at the current map request center.
         If allow_local_adjustment="false" (default), no adjustment is
         performed.
       - Automatically applies a globular map projection (geodetic data only): 
         If use_globular_projection="true", MapViewer will 
         apply a globular projection on the fly to geometries being displayed. 
         If use_globular_projection="false" (the default), MapViewer does no map 
         projection to geodetic geometries. This option has no effect on 
         non-geodetic data.
   -->
 
  <!--
    <global_map_config>
        <note text="Copyright 2009, Oracle Corporation" 
              font="sans serif" 
              position="SOUTH_EAST"/>
        <title  text="MapViewer Demo" 
                font="Serif"
                position="NORTH" />
        <logo image_path="C:\\images\\a.gif"  
              position="SOUTH_WEST" />
 
        <rendering allow_local_adjustment="false" 
                   use_globular_projection="false" />
    </global_map_config>
  -->
 
  <!-- ****************************************************************** -->
  <!-- ****************** Spatial Data Cache Setting  ******************* -->
  <!-- ****************************************************************** -->
  <!-- Uncomment and modify the following to customize the spatial data cache
       used by MapViewer. The default is 64 MB for in-memory cache.
 
       To disable the cache, set max_cache_size to 0.
 
       max_cache_size:  Maximum size of in-memory spatial cache of MapViewer.
                        Size must be specified in megabytes (MB).
       report_stats:    If you would like to see periodic output of cache
                        statistics, set this attribute to true. The default
                        is false.
   -->
 
  <!--
    <spatial_data_cache   max_cache_size="64"
                          report_stats="false" 
    />
  -->
 
  <!-- ****************************************************************** -->
  <!-- ******************** Custom Image Renderers ********************** -->
  <!-- ****************************************************************** -->
  <!-- Uncomment and add as many custom image renderers as needed here, 
       each in its own  <custom_image_renderer> element. The "image_format"
       attribute specifies the format of images that are to be custom 
       rendered using the class with full name specified in "impl_class". 
       You are responsible for placing the implementation classes in the
       MapViewer's classpath.
  -->
  <!-- 
  <custom_image_renderer image_format="ECW" 
                         impl_class="com.my_corp.image.ECWRenderer" />
  -->
 
  <!-- ****************************************************************** -->
  <!-- ****************** Custom WMS Capabilities Info ****************** -->
  <!-- ****************************************************************** -->
  <!-- Uncomment and modify the following tag if you want MapViewer to
       use the following information in its getCapabilities response.
       Note: all attributes and elements of <wms_config> are optional.
  -->
  <!--
  <wms_config host="www.my_corp.com" port="80">
    <title>
        WMS 1.1 interface for Oracle Mapviewer
    </title>
    <abstract>
        This WMS service is provided through MapViewer.
    </abstract>
    <keyword_list>
       <keyword>bird</keyword>
       <keyword>roadrunner</keyword>
       <keyword>ambush</keyword>
    </keyword_list>    
    <sdo_epsg_mapfile>
      ../config/epsg_srids.properties
    </sdo_epsg_mapfile>
  </wms_config>
  -->
 
  <!-- ****************************************************************** -->
  <!-- **************** Custom Non-Spatial Data Provider **************** -->
  <!-- ****************************************************************** -->
  <!-- Uncomment and add as many custom non-spatial data provider as
       needed here, each in its own <ns_data_provider> element.
       You must provide the id and full class name here. Optionally you
       can also specify any number of global parameters, which MapViewer
       will pass to the data provider implementation during initialization. 
       The name and value of each parameter is interpreted only by the 
       implementation.
  -->
 
  <!-- this is the default data provider that comes with MapViewer; please
       refer to the MapViewer User's Guide for instructions on how to use it.
 
  <ns_data_provider
    id="defaultNSDP" 
    class="oracle.sdovis.NSDataProviderDefault" 
  />
  -->
 
  <!-- this is a sample NS data provider with prameters:
  <ns_data_provider
    id="myProvider1" class="com.mycorp.bi.NSDataProviderImpl" >
 
    <parameters>
      <parameter name="myparam1" value="value1" />
      <parameter name="p2"       value="v2"     />
    </parameters>
 
  </ns_data_provider>
  -->
 
  <!-- ****************************************************************** -->
  <!-- *******************  Map Tile Server Setting  ******************* -->
  <!-- ****************************************************************** -->
  <!-- Uncomment and modify the following to customize the map tile server. 
 
       <tile_storage> specifies the default root directory under which the 
       cached tile images are to be stored if the cache instance configuration
       does not specify the root directory for the cache instance. If the 
       default root directory is not set or not valid, the default root 
       direcotry will be set to be $MAPVIEWER_HOME/web/tilecache
       
          default_root_path:  The default root directory under which the cached 
                              tile images are stored. 
  -->
 
  <!--
     <map_tile_server>
       <tile_storage default_root_path="/scratch/tilecachetest/"/>
    </map_tile_server>
  -->
 
  <!-- ****************************************************************** -->
  <!-- ******************** Predefined Data Sources  ******************** -->
  <!-- ****************************************************************** -->
  <!-- Uncomment and modify the following to predefine one or more data 
       sources.
       Note: You must precede the jdbc_password value with a '!' 
             (exclamation point), so that when MapViewer starts the next
             time, it will encrypt and replace the clear text password. 
  -->
 
  <!-- 
  <map_data_source name="mvdemo"
                   jdbc_host="elocation.us.oracle.com"
                   jdbc_sid="orcl"
                   jdbc_port="1521"
                   jdbc_user="scott"
                   jdbc_password="!password" 
                   jdbc_mode="thin"
                   number_of_mappers="3"
   />
   -->
 
</MapperConfig>

1.5.2.1 Specifying Logging Information

MapViewer provides a flexible logging mechanism to record run-time information and events. You can configure the granularity, volume, format, and destination of the log output. You can also configure the maximum size of log files as well as automatic log file rotation.

There are two ways to configure MapViewer's logging, the container-controlled approach and legacy logging using the <logging> element in the configuration file:

  • Container-controlled logging: Use Oracle Fusion Middleware 10gR3 Control if MapViewer is deployed to an Oracle Fusion Middleware 10gR3 instance, or directly edit the $OC4J_HOME/j2ee/home/config/j2ee-logging.xml file if MapViewer is deployed to a standalone OC4J instance. This approach takes full advantage of the Fusion Middleware 10gR3 diagnostic logging mechanisms and allows such advanced features such as maximum log file size and log file rotation.

  • Legacy logging: Involves using the <logging> element in the mapViewerConfig.xml file. When MapViewer is deployed to WebLogic Server, legacy logging is the only supported way of configuring MapViewer logging behavior.

Container-Controlled Logging

Note:

For container-controlled logging to work, you must comment out or remove the <logging> element in the mapViewerConfig.xml file. By default that element is commented out (disabled), so that container-controlled logging settings will function properly. If you enable the <logging> element (even if you make no other changes to its attributes), then the container-controlled logging settings are ignored by MapViewer.

To configure MapViewer logging when it is deployed to an OC4J 11g standalone instance, edit the $OC4J_HOME/j2ee/home/config/j2ee-logging.xml file. For example, the following code in that file logs all messages from MapViewer at the FINEST level to the default OC4J log file (j2ee/home/log/oc4j/diagnostic.log):

<log_handler name='oc4j-handler' class='oracle.core.ojdl.logging.ODLHandlerFactory'>
      <property name='path' value='../log/oc4j'/>
      <property name='maxFileSize' value='10485700'/>
      <property name='maxLogSize' value='1048576'/>
      <property name='encoding' value='UTF-8'/>
      <property name='supplementalAttributes' value='J2EE_APP.name,J2EE_MODULE.name,WEBSERVICE.name,WEBSERVICE_PORT.name'/>
 </log_handler>

The preceding code defines the default OC4J log handler. It specifies where the log file will be saved, its maximum file size, and other information. A log handler like this can be associated with multiple actual loggers that are created by OC4J components and applications (such as MapViewer).

The following example associates a MapViewer logger, in this case one that is responsible for generating all internal log messages, with the preceding log handler:

<logger name="oracle.mapviewer.logger" level="FINEST" useParentHandlers='false'>
    <handler name='oc4j-handler'/>
</logger>

The preceding example tells OC4J that all log records produced by the logger named oracle.mapviewer.logger should be handled by the log handler named oc4j-handler. It sets the logging level to FINEST so that all messages generated by MapViewer will be visible in the log file. The possible logging levels supported here are the following standard Java logging levels: SEVERE, WARNING, INFO, CONFIG, FINE, FINER, and FINEST.

The following loggers are used by MapViewer for container-controlled logging:

  • oracle.mapviewer.logger is used by all server side components of MapViewer to generate diagnostic records.

  • oracle.mapviewer.access is used by MapViewer for logging only user access records.

The preceding example associated an existing log handler named oc4j-handler, which is already defined in the j2ee-logging.xml file. You can also define your own log handler in the j2ee-logging.xml file and specify a different log file location and name, as well as the maximum file size and the file rotation. The following example creates a new log handler to store only MapViewer access records:

<log_handler name='mv-handler' class='oracle.core.ojdl.logging.ODLHandlerFactory'>
      <property name='path' value='../log/mapaccess/access.log'/>
      <property name='maxFileSize' value='600000'/>
      <property name='maxLogSize' value='10000'/>
      <property name='format' value='ODL-TEXT'/>
      <property name='encoding' value='UTF-8'/>
      <property name='supplementalAttributes' value='J2EE_APP.name'/>
</log_handler>

The following example associates this new log handler to the MapViewer access logger named oracle.mapviewer.access:

<logger name='oracle.mapviewer.access' level='FINEST' useParentHandlers='false'>
    <handler name='mv-handler'/>
</logger>

Note that the level must be FINEST or FINER in order for the access log messages to appear in the log file. Now, if you restart OC4J and make map requests, you should see a new log file (access.log) in the OC4J log/mapaccess directory that contains records of users accessing MapViewer.

For more information about logging configuration, specifically how to configure logging using Fusion Middleware 10gR3 Control, see Oracle Containers for J2EE Configuration and Administration Guide

Legacy Logging

If you do not use container-controlled logging, you can use the legacy approach, which is to uncomment-out and modify the <logging> element in the MapViewer configuration file.

You can specify the following information as attributes or subelements of the <logging> element:

  • The log_level attribute controls the levels of information that are recorded in the log, which in turn affect the log output volume. Set the log_level attribute value to one of the following, listed from most restrictive logging to least restrictive logging: FATAL, ERROR, WARN, INFO, DEBUG, and FINEST. The FATAL level outputs the least log information (only unrecoverable events are logged), and the other levels are progressively more inclusive, with the FINEST level causing the most information to be logged. For production work, a level of WARN or more restrictive (ERROR or FATAL) is recommended; however, for debugging you may want to set a less restrictive level.

  • The log_thread_name attribute controls whether or not to include the name of the thread that encountered and logged the event.

  • The log_time attribute controls whether or not the current time is included when a logging event occurs.

  • The log_output subelement identifies output for the logging information. By default, log records are written to the system error console. You can change this to the system output console or to one or more files, or some combination. If you specify more than one device through multiple log_output subelements, the logging records are sent to all devices, using the same logging level and attributes.

1.5.2.2 Specifying Map File Storage and Life Cycle Information

Map image file information is specified in the <save_images_at> element. By default, images are stored in the $ORACLE_HOME /lbs/mapviewer/web/images directory. You do not need to modify the <save_images_at> element unless you want to specify a different directory for storing images.

A mapping client can request that MapViewer send back the URL for an image file instead of the actual map image data, by setting the format attribute of the <map_request> element (described in Section 3.2.1.1) to GIF_URL or PNG_URL. In this case, MapViewer saves the requested map image as a file on the host system where MapViewer is running and sends a response containing the URL of the image file back to the map client.

You can specify the following map image file information as attributes of the <save_images_at> element:

  • The file_prefix attribute identifies the map image file prefix. A map image file name will be a fixed file prefix followed by a serial number and the image type suffix. For example, if the map image file prefix is omsmap, a possible GIF map image file could be omsmap1.gif.

    Default value: file_prefix=omsmap

  • The url attribute identifies the map image base URL, which points to the directory under which all map image files are saved on the MapViewer host. The map image URL sent to the mapping client is the map image base URL plus the map image file name. For example, if the map image base URL is http://dev04.example.com:1521/mapviewer/images, the map image URL for omsmap1.gif will be http://dev04.example.com:1521/mapviewer/images/omsmap1.gif.

    Default value: url=$HOST_URL/mapviewer/images

  • The path attribute identifies the path of the directory where all map image files are saved on the MapViewer host system. This directory must be accessible by HTTP and must match the map image URL. Map image files saved in the directory specified by the path attribute should be accessible from the URL specified by the url attribute.

    However, if you are deploying MapViewer to WebLogic Server, the default value for the path attribute (../web/images) is not correct. The path attribute value in this case should be ../../images, because the physical "images" directory is mapviewer.ear/web.war/images; so using relative path, the value should be ../../images for the path attribute to resolve to the physical directory.

  • The life attribute specifies the number of minutes that a generated map image is guaranteed to stay on the file system before the image is deleted. If the life attribute is specified, the recycle_interval attribute controls how frequently MapViewer checks for possible files to delete.

    Default: MapViewer never deletes the generated map images.

  • The recycle_interval attribute specifies the number of minutes between times when MapViewer checks to see if it can delete any image files that have been on the file system longer than the number of minutes for the life attribute value.

    Default value: 480 (8 hours)

1.5.2.3 Restricting Administrative (Non-Map) Requests

In addition to map requests, MapViewer accepts administrative (non-map) requests, such as requests to list all data sources and to add and delete data sources. (Chapter 7 describes the administrative requests.) By default, all MapViewer users are permitted to make administrative requests.

However, if you want to restrict the ability to submit administrative requests, you can edit the MapViewer configuration file to allow administrative requests only from users with specified IP addresses.

To restrict administrative requests to users at specified IP addresses, add the <ip_monitor> element to the MapViewer configuration file (or uncomment and modify an existing element, if one is commented out). Example 1-2 shows a sample <ip_monitor> element excerpt from a configuration file.

Example 1-2 Restricting Administrative Requests

<MapperConfig>
   . . .
   <ip_monitor>
      <ips> 138.1.17.9, 138.1.17.21, 138.3.*, 20.* </ips>
      <ip_range> 24.17.1.3 - 24.17.1.20 </ip_range>
      <ips_exclude> 138.3.29.* </ips_exclude>
      <ip_range_exclude>20.22.34.1 - 20.22.34.255</ip_range_exclude>
   </ip_monitor>
   . . .
</MapperConfig>

In Example 1-2:

  • The following IP addresses are explicitly included as able to submit administrative requests (unless excluded by an <ips_exclude> element): 138.1.17.9, 138.1.17.21, all that start with 138.3., all that start with 20., and all in the range (inclusive) of 24.17.1.3 to 24.17.1.20.

  • The following IP addresses are explicitly excluded from submitting administrative requests: all starting with 138.3.29., and all in the range (inclusive) of 20.22.34.1 to 20.22.34.255.

  • All other IP addresses that are not explicitly included cannot submit administrative requests.

Syntax notes for the <ip_monitor> element:

  • Use <ips> and <ip_range> elements to specify which IP addresses (and ranges) are allowed. Asterisk wildcards (such as 20.*) are acceptable. Use a comma-delimited list for addresses.

  • Use <ips_exclude> and <ip_range_exclude> elements to exclude IP addresses and address ranges from submitting administrative requests. If an address falls into both the included and excluded category, it is excluded.

  • If you specify the asterisk wildcard in an <ips> element, all associated IP addresses are included except any specified in <ips_exclude> and <ip_range_exclude> elements.

1.5.2.4 Specifying a Web Proxy

Sometimes the MapViewer server needs to make HTTP connections to external Web servers, such as to obtain a background image through a URL or to contact an external WMS server to fetch its map images. In such cases, if there is a firewall between the MapViewer server and the target Web server, you may need to specify the HTTP proxy information to MapViewer so that it will not be blocked by the firewall. The following example specifies Web proxy information:

<web_proxy host="www-proxy.mycorp.com" port="80" />

1.5.2.5 Specifying Global Map Configuration Options

You can specify the following global "look and feel" options for the display of each map generated by MapViewer:

  • Title

  • Note (such as a copyright statement or a footnote)

  • Logo (custom symbol or corporate logo)

  • Local geodetic data adjustment

  • Splitting geometries along the 180 meridian

To specify any of these options, use the <global_map_config> element. For example:

<global_map_config>
    <note text="Copyright (c) 2009, Example Corporation"
              font="sans serif"
              position="SOUTH_EAST"/>
    <title  text="Map Courtesy of Example Corp."
              font="Serif"
              position="NORTH"/>
    <logo image_path="C:\\images\\a.gif"
              position="SOUTH_WEST"/>

    <rendering allow_local_adjustment="false"
               use_globular_projection="false"/>
</global_map_config>

Set the map title through the <title> element of the <global_map_config> element. You can also set the map title in an individual map request by specifying the title attribute with the <map_request> element, and in this case, the title in the map request is used instead of the global title in the MapViewer configuration file. Note the following information about the attributes of the <title> element:

  • The text attribute specifies the title string.

  • The font attribute specifies a font. The font must exist on the system where MapViewer is running.

  • The position attribute provides a positioning hint to MapViewer when determining where the map title will be drawn on a map. Possible values are: NORTH, EAST, SOUTH, WEST, NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST, and CENTER.

    Default value: NORTH

Set the map note through the <note> element of the <global_map_config> element. Note the following information about the attributes of the <note> element:

  • The text attribute specifies the note string.

  • The font attribute specifies a font. The font must exist on the system where MapViewer is running.

  • The position attribute provides a positioning hint to MapViewer when determining where the map note will be drawn on a map. Possible values are: NORTH, EAST, SOUTH, WEST, NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST, and CENTER.

    Default value: SOUTH_EAST

Set the map logo through the <logo> element of the <global_map_config> element. The map logo image must be in either JPEG or GIF format. The image can be stored in a local file system where the MapViewer instance will have access to it, or it can be obtained from the Web by specifying its URL. To specify a map logo, uncomment the <map_logo> element in the MapViewer configuration file and edit its attributes as needed.

Note the following information about the attributes of the <logo> element:

  • The image_path attribute must specify a valid file path name, or a URL starting with http://.

  • The position attribute provides a positioning hint to MapViewer when determining where the map logo will be drawn on a map. Possible values are: NORTH, EAST, SOUTH, WEST, NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST, and CENTER.

    Default value: SOUTH_WEST

If the logo image is obtained through a URL that is outside your firewall, you may need to set the Web proxy in order for MapViewer to retrieve the logo image. For information about specifying a Web proxy, see Section 1.5.2.4.

If you also specify a map legend, be sure that its position is not the same as any position for a map title, note, or logo. (Map legends are explained in Section 2.4.2 and Section 3.2.11. The default position for a map legend is SOUTH_WEST.)

To have MapViewer automatically project geodetic data to a local non-geodetic coordinate system before displaying it if the map data window is less than 3 decimal degrees, specify allow_local_adjustment="true" in the <rendering> element.

To have MapViewer automatically apply a globular map projection (that is, a map projection suitable for viewing the world, and specifically the azimuthal equidistant projection for MapViewer), specify use_globular_projection="true" in the <rendering> element. This option applies to geodetic data only.

1.5.2.6 Customizing the Spatial Data Cache

You can customize the in-memory cache that MapViewer uses for spatial data by using the <spatial_data_cache> element. For example:

<spatial_data_cache   max_cache_size="64"
                      report_stats="true"
/>

You can specify the following information as attributes of the <spatial_data_cache> element:

  • The max_cache_size attribute specifies the maximum number of megabytes (MB) of in-memory cache.

    Default value: 64

  • The report_stats attribute, if set to true, instructs the MapViewer server to periodically (every 5 minutes) output cache statistics, such as the number of objects cached, the total size of cache objects, and data relating to the efficiency of the internal cache structure. The statistics are provided for each data source and for each predefined theme. They can help you to determine the optimal setting of the in-memory cache. For example, if you want to pin all geometry data for certain themes in the memory cache, you need to specify a max_cache_size value that is large enough to accommodate these themes.

    Default value: false

The spatial data cache is always enabled by default, even if the element is commented out in the configuration file. To completely disable the caching of spatial data, you must specify the max_cache_size attribute value as 0 (zero).

Note:

The disk-based spatial cache, which was supported in the previous release, is no longer supported, because performance tests have shown that disk-based spatial caching was often less efficient than fetching spatial objects directly from the database when needed (that is, in cases where the cached objects frequently did not need to be retrieved again after caching).

For detailed information about the caching of predefined themes, see Section 2.3.1.5.

1.5.2.7 Specifying the Security Configuration

You can use the <security_config> element to specify whether MapViewer should reject <info_request> elements in requests. An <info_request> element is a type of request from a client that asks MapViewer to execute a simple SQL statement and return the result rows in plain text or XML format. This request is often used by MapViewer applications written in JSP to identify features displayed on a map, or to run simple spatial search queries.

However, if the MapViewer data source information is exposed, malicious attackers might be able to abuse this capability and obtain sensitive information. To prevent this from happening, you can make sure MapViewer always connects to a database schema that has very limited access rights and hosts only non-sensitive information, and you can also reject all <info_request> requests by specifying the <security_config> element as follows:

<security_config>
  <disable_direct_info_request> true </disable_direct_info_request>
</security_config>

Note, however, that this setting affects some Mapviewer features. For example, the identify() method of the MapViewer Java API will no longer work, and applications will need to implement their own identify() method through other means.

1.5.2.8 Registering a Custom Image Renderer

MapViewer can display images stored in a database BLOB through its image theme capability. When the image data stored in the BLOB is in a format unknown to MapViewer, such as ECW, you can register a custom image renderer so that MapViewer can use it to display such images. For information about creating and registering a custom image renderer, see Appendix C.

To specify a custom image renderer, use the <custom_image_renderer> element, as shown in the following example:

<custom_image_renderer image_format="ECW" 
                       impl_class="com.my_corp.image.ECWRenderer" />

The image_format attribute specifies the image format name with which this custom image renderer should be associated.

The impl_class attribute specifies the name of the class that implements the custom image renderer.

1.5.2.9 Registering a Custom Spatial Provider

MapViewer can render spatial data that is in an external (non-Oracle Spatial) native format, such as Shapefile, if there is a spatial provider implementation registered for the format. For information about implementing an external spatial data provider (in connection with custom geometry themes), see Section 2.3.8.

To register an external spatial data provider, use the <s_data_provider> element, as shown in the following example:

<s_data_provider
  id="shapefileSDP"
  class="oracle.sdovis.ShapefileDataProvider"
  >
  <parameters>
    <parameter name="datadir" value="/temp/data" />
  </parameters>
</s_data_provider>

The class attribute specifies the name of the class that implements the external spatial data provider.

The <parameters> element specifies a set of initialization parameters that are used by the data provider during its initialization process. In this example, the Shapefile provider has a data directory ("datadir") parameter that points to directory where MapViewer can look for the data.

1.5.2.10 Registering Custom Nonspatial Data Providers

When generating thematic map layers, MapViewer can dynamically join nonspatial attribute data (such as sales for each region) that originates from an external source with the base geometries (boundaries of all the regions) that are stored in the database. For information about thematic mapping using external attribute data from nonspatial data providers, see Section 2.3.10.1.

To register a nonspatial data provider, use the <ns_data_provider> element, as shown in the following example:

<ns_data_provider id="testProvider"
                  class="com.mycorp.GetSalesData" >
  <parameters>
    <parameter name="bi_database" value="stadb32.mycorp.com" />
    <parameter name="sid" value="bidata"  />
  </parameters>
</ns_data_provider>

The id attribute uniquely identifies a nonspatial data provider. Use this id value in any map request that involves the provider.

The class attribute specifies the name of the class that implements the nonspatial data provider.

The <parameters> element specifies a set of initialization parameters that are used by the nonspatial data provider during its initialization process.

1.5.2.11 Customizing SRS Mapping

You can use the <srs_mapping> element to specify an SDO to EPSG SRID mapping file, which define mappings between Oracle Spatial SDO_SRID values and EPSG codes. As explained in Section E.1.3, each line in the specified mapping file must contain an SDO_SRID value and the corresponding EPSG code. The <srs_mapping> element can be used with WMS and WFS themes.

The following example uses the <srs_mapping> element to specify an SDO to EPSG SRID mapping file:

<srs_mapping>
  <sdo_epsg_mapfile>
    ../config/epsg_srids.properties
  </sdo_epsg_mapfile>
</srs_mapping>

1.5.2.12 Customizing WMS GetCapabilities Responses

MapViewer can be used as an Open Geospatial Consortium WMS (Web Map Server) 1.1.1 compliant server. As such, a WMS client can send MapViewer the GetCapabilities request. In response, MapViewer will send back the list of themes that it hosts and other important information, such as the data provider's name and a list of keywords, that might of interest to the requesting client.

You can use the <wms_config> element to customize the descriptive information sent back to the client as part of the GetCapabilities response, as shown in the following example:

<wms_config host="www.my_corp.com" port="80"
            protocol="http" default_datasource="dsrc1"
            public_datasources="dsrc1,dsrc2">
  <title>
    WMS 1.1 interface for Oracle Application Server 10g MapViewer
  </title>
  <abstract>
    This WMS service is provided through Oracle MapViewer.
  </abstract>
  <keyword_list>
    <keyword>bird</keyword>
    <keyword>roadrunner</keyword>
    <keyword>ambush</keyword>
  </keyword_list>
  <sdo_epsg_mapfile>
    ../config/epsg_srids.properties
  </sdo_epsg_mapfile>
</wms_config>

The host attribute specifies the host part of the service request URL that the client should use for future WMS requests made to this MapViewer server.

The port attribute specifies the port part of the service request URL that the client should use for future WMS requests made to this MapViewer server.

The protocol attribute specifies the protocol part of the service request URL that the client should use for future WMS requests made to this MapViewer server.

The default_datasource attribute specifies the base data source used to retrieve the capabilities response. If this attribute is not defined, the data source WMS is used, and that data source must exist in this MapViewer server.

The public_datasources attribute specifies which data source contents are to be listed in the GetCapabilities response. If this attribute is not defined, all data source contents will be listed.

The <title> element specifies the service title to be included as part of the response.

The <abstract> element specifies the abstract to be included as part of the response.

The <keyword_list> element specifies a list of keywords that best describe the types of layers served by this MapViewer server.

The <sdo_epsg_mapfile> element specifies a text file that defines mappings from Oracle Spatial (SDO) SRID values to the corresponding EPSG SRID values that are typically used in most WMS requests and responses. For information about this mapping file, see Section E.1.3.

1.5.2.13 Configuring the Map Tile Server for Oracle Maps

The Oracle Maps feature of MapViewer can pre-generate base map image tiles and cache them through the map tile server. You can use the <map_tile_server> element to provide configuration information to the map tile server, such as default location for map tile file storage, and logging information, as shown in the following example:

<map_tile_server>
   <tile_storage default_root_path="/scratch/tilecache/" />
   <logging log_level="finest" log_thread_name="false" log_time="true">
      <log_output name="System.err"/>
   </logging>
</map_tile_server>

The <tile_storage> element specifies the default root directory where all map image tiles generated by this MapViewer server will be stored.

The <logging> element specifies logging information specific to the map tile server.

1.5.2.14 Defining Permanent Map Data Sources

Every map request must have a data source attribute that specifies a map data source, which is a database user with geospatial data. You can predefine available map data sources by using the <map_data_source> element. For example:

<map_data_source name="mvdemo"
                 jdbc_host="mapsrus.us.oracle.com"
                 jdbc_sid="orcl"
                 jdbc_port="1521"
                 jdbc_user="scott"
                 jdbc_password="!password"
                 jdbc_mode="thin"
                 number_of_mappers="5"
                 max_connections="100"
                 allow_jdbc_theme_based_foi="true"
                 plsql_package="web_user_info"
/>

You can specify the following information as attributes of the <map_data_source> element:

  • The name attribute specifies a unique data source name to MapViewer. You must specify the data source name in all map requests that identify a data source.

  • You must specify all necessary connection information, or a container data source name, or a net service name (TNS name). That is, you must specify only one of the following, which are described in this section: jdbc_host, jdbc_sid, jdbc_port, and jdbc_user; or container_ds; or jdbc_tns_name.

    Note that if the database on which you defined a data source on is restarted, and if the data source is created from jdbc_host/jdbc_sid/jdbc_port or jdbc_tns_name attributes, MapViewer will resume normal operation (for example responding to map requests with properly created maps) as soon as the database is back online.

  • The jdbc_host, jdbc_sid, jdbc_port, and jdbc_user attributes specify the database connection information and the database user name. (As an alternative to specifying these attributes and the jdbc_password and jdbc_mode attributes, you can specify the container_ds attribute, described later in this section.)

  • The jdbc_password attribute specifies the database user's login password. It must be prefixed with an exclamation point (!) when you specify the password for the first time. When MapViewer next restarts, it will automatically obfuscate and replace the clear text password.

    Note that MapViewer does not change this password string in any way; no conversion to upper or lower case is performed. If the database uses case-sensitive passwords, the specified password must exactly match the password in the database.

  • The jdbc_mode attribute tells MapViewer which Oracle JDBC driver to use when connecting to the database. The default is thin (for the "thin" driver). The other possible value is oci8, which requires that you also have the Oracle Database client installed on the same host on which MapViewer is running.

  • The container_ds attribute lets you specify the J2EE container name (from the ejb-location attribute value) instead of specifying the jdbc_host, jdbc_sid, jdbc_port, jdbc_user, jdbc_password, and jdbc_mode attributes. For example, assume that the <data_source> element in the data-source.xml file for the standalone OC4J instance contains ejb-location="jdbc/OracleDS". In this case, instead of using the example at the beginning of this section, you can define the permanent MapViewer data source as follows:

    <map_data_source name="mvdemo"
                     container_ds="jdbc/OracleDS"
                     number_of_mappers="5"
                     max_connections="100"
    />
    

    To use the container_ds attribute in the MapViewer configuration file, you must start the OC4J instance with the -userThreads option. MapViewer processes its configuration file in a separate user thread; if the -userThreads option is not specified, the container's context information is not available to user threads. However, if you are dynamically defining a data source through the MapViewer Administration page, you can use the container_ds attribute regardless of whether you started the OC4J instance with the -userThreads option.

    If you use the container_ds attribute, and if you want MapViewer to resume normal operation (for example responding to map requests with properly created maps) automatically after the database on which you defined a data source on is restarted, you must instruct the container data source to always validate a connection before it can be returned to the application. Check your middleware documentation for whether this option is supported and, if it is supported, how to enable it.

  • The jdbc_tns_name attribute identifies a net service name that is defined in the tnsnames.ora file.

  • The number_of_mappers attribute identifies the maximum number of map renderers available (and thus the maximum number of map requests that MapViewer can process in parallel for the data source) for this data source. Any unprocessed map requests are queued and eventually processed. For example, if the value is 3, MapViewer will be able to process at most three mapping requests concurrently. If a fourth map request comes while three requests are being processed, it will wait until MapViewer has finished processing one of the current requests.

    Specifying a large number_of_mappers value (such as 30 or 50) does not cause additional static memory to be used, and it does not affect the total number of database connections that will remain open. However, specifying a large value does cause some additional overhead operations, which might affect server performance at times of peak loads. The maximum number of mappers for a single data source is 64.

  • The max_connections attribute specifies the maximum number of database connections or sessions open for the data source at any given time. In most cases you should not specify this attribute, and accept the default value of 100.

    If you specify a value that is too small, the effect on performance can be significant. For example, if you specify max_connections="5" for a map request with 12 predefined themes, 12 connections will still be created temporarily to meet the demand, but 7 of them will be closed immediately upon the completion of the request (leaving only 5 open connections). MapViewer will then dynamically create database connections whenever it needs more than 5 to meet the demand when processing map requests, because the number of permanently open database connections will never exceed the specified max_connections attribute value. Specifying a value that is too small will almost certainly increase the time it takes to process a map request, because opening a new database connection involves significant processing overhead.

  • The allow_jdbc_theme_based_foi attribute lets you specify whether to allow JDBC theme-based FOI requests to be performed against this data source. A JDBC theme-based FOI request is based on a dynamic SQL query constructed by the JavaScript client application.

    By default, such FOI requests are not allowed unless you set this attribute to true. Due to the potential security threat, JDBC theme-based FOI requests should be used with caution. You should only allow JDBC theme-based FOI requests on database connections that are granted very low privilege and contain only data that you want to expose. See Section 8.3.1.3 for more information about JDBC theme-based FOI requests.

  • The plsql_package attribute lets you specify a PL/SQL package to be used for secure map rendering, as explained in Section 1.8.

  • The web_user_type attribute (not shown in the example in this section) lets you specify the source for the authenticated user's name. It is especially useful for getting the authenticated user's name from a cookie, in conjunction with specifying a PL/SQL package to be used for secure map rendering. For more information about the web_user_type attribute and an example of its use, see Section 1.8.2.

1.5.3 Performing MapViewer Administrative Tasks

Besides knowing how to configure MapViewer, you should also know how to perform other important administrative tasks using the MapViewer administration page. To log in to this page, see the instructions in Section 1.5.1.

The tasks you can do as a MapViewer administrator include the following:

  • Editing the configuration file

    Click Manage MapViewer, then Configuration.

  • Creating dynamic data sources

    Click Manage MapViewer, then Datasources. Enter the appropriate parameters, then click Submit.

  • Refreshing the list of data sources

    Click Manage MapViewer, then Datasources. Click Refresh.

  • Clearing cached definitions of MapViewer styles, themes, and base maps

    Click Manage MapViewer, then Datasources. Select the data source, then click Purge Cached Metadata.

  • Clearing cached geometry data for predefined themes

    Click Manage MapViewer, then Geometry Cache. Under Purge Cached Geometries, select the data source and theme, and click Submit.

  • Creating map tile layers for Oracle Maps

    Click Manage Map Caches, then Create. Select Internal or External for the map source type, and click Continue.

    Internal map source: Enter the map cache name, then select the data source and base map. Also define parameters for cache storage (where tiles will be stored), zoom levels, minimum and maximum scale, spatial reference ID (SRID), data bounding box (MBR), and tile size and format. Click Submit to create the map tile layer. You can also define the map cache properties in XML by clicking XML.

    External map source: Enter the map cache name, then select the data source. To provide access to the external source, define parameters such as the map service URL, the request method (GET or POST), the proxy information (if needed), the java adapter class name and its location on the server, and additional adapter properties. Also define parameters for cache storage (where tiles will be stored), zoom levels, minimum and maximum scale, spatial reference ID (SRID), data bounding box (MBR), and tile size and format. Click Submit to create the map tile layer. You can also define the map cache properties in XML by clicking XML.

  • Managing map tile layers for Oracle Maps

    Click Manage Map Caches, then Manage. Then do any of the following:

    To refresh map caches, click Refresh.

    To edit a map tile layer, under Existing Map Tile Layers, select the data source. At the cache level, you can delete the cache, view cache details, and place the cache offline or online. At the tile level, you can perform operations such as clearing, prefetching, and refreshing the tiles, specifying the zoom level, and specifying the bounding box.

    To check the status of a request, enter the request ID and click Submit.

1.6 Oracle Real Application Clusters and MapViewer

When the database is an Oracle Real Application Cluster (RAC), you cannot create MapViewer data sources that directly connect to it. Instead, MapViewer must connect to an Oracle RAC database through the data source of the J2EE container. To enable MapViewer to connect to an Oracle RAC database, you must do the following:

  1. Create a JDBC data source that connects to the Oracle RAC database at the OC4J level, as explained in Section 1.6.1. The data source can then be used by applications such as MapViewer through JNDI lookup.

  2. Configure the OC4J instance so that it publishes the JNDI location of the Oracle RAC data source so that MapViewer can access it, as explained in Section 1.6.2.

  3. Define a MapViewer data source that reuses the container data source through the JNDI location in its configuration file, as explained in Section 1.6.3.

  4. Restart MapViewer.

1.6.1 Creating a Container RAC Data Source

With either a full Oracle Fusion Middleware or standalone OC4J installation, use Oracle Enterprise Manager to create a data source that connects to the Oracle RAC database. For example, if using Oracle Application Server release 10.1.3 or later, you can log into Enterprise Manager, navigate to the OC4J instance that contains the MapViewer server, click the Administration tab, and click the JDBC Resources Go to Task link to start creating a new data source, as shown in Figure 1-12.

Figure 1-12 Administration Tab for Creating RAC Container Data Source

Description of Figure 1-12 follows
Description of "Figure 1-12 Administration Tab for Creating RAC Container Data Source"

For more information about creating a data source to connect to an Oracle RAC database, see Oracle Application Server Administrator's Guide.

After creating the data source, you should test the connection using Enterprise Manager, by clicking the Test Connection icon for the connection, as shown in Figure 1-13.

Figure 1-13 Testing the Connection for the Data Source

Description of Figure 1-13 follows
Description of "Figure 1-13 Testing the Connection for the Data Source"

Be sure to note the JNDI Location value (which is jdbc/mvdemods in Figure 1-13), because you will need this value when you create the MapViewer data source (explained in Section 1.6.3).

1.6.2 Adding the userThreads Option to the OC4J Container

You must specify the userThreads option to tell the OC4J instance to publish the JNDI locations, such as the one for the newly created data source, to all user threads. Without this option, MapViewer cannot access the JNDI location that references the data source, because by default OC4J makes such JNDI locations available only to the main thread within which OC4J itself is running. MapViewer, however, is started in a separate user thread.

The mechanism for specifying the userThreads option depends on whether you re using a standalone OC4J instance or a full Oracle Fusion Middleware installation.

1.6.2.1 Adding userThreads for a Standalone OC4J Instance

With a standalone OC4J instance, you must start the OC4J instance with the -userThreads option, as in the following example:

java –jar oc4j.jar –userThreads

1.6.2.2 Adding userThreads for a Full Oracle Fusion Middleware 10gR3 Installation

With a full Oracle Fusion Middleware 10gR3 installation, the Java startup parameters are defined in the $OAS_HOME/opmn/conf/opmn.xml configuration file. (opmn is the master process that starts and stops various Oracle Fusion Middleware 10gR3 components, such as OC4J instances.)

In this file you can specify Java JVM startup parameters for the OC4J instance running MapViewer. For example, if you deployed MapViewer to the home OC4J instance, add the text -Doc4j.userThreads=true, as shown in the following example:

          <ias-component id="OC4J">
             <process-type id="home" module-id="OC4J" status="enabled">
                <module-data>
                   <category id="start-parameters">
                      <data id="java-options" value="-server
 -Djava.security.policy=$ORACLE_HOME/j2ee/home/config/java2.policy
 -Djava.awt.headless=true -Dhttp.webdir.enable=false
 -Doc4j.userThreads=true"/>
                   </category>
                   ...

After editing and saving the opmn.xml file, you must restart the OC4J instance for the userThreads option to take effect; and if that does not work, restart Oracle Fusion Middleware 10gR3. For information about restarting the OC4J instance or Oracle Fusion Middleware 10gR3, see Oracle Application Server Administrator's Guide.

1.6.3 Creating a MapViewer Data Source

Create a new MapViewer data source that enables it to connect to the Oracle RAC database, by using the container_ds attribute of the MapViewer data source. Specifically, you must add an entry like the following in the mapViewerConfig.xml file:

<map_data_source  name="mvdemo"
                  container_ds="jdbc/mvdemods"
                  number_of_mappers="7" />

In the preceding example:

  • The name attribute specifies the MapViewer data source name, which is needed for map requests.

  • The value for the container_ds attribute must match the JNDI Location string that you noted when you created the container RAC data source (see Section 1.6.1).

  • The number_of_mappers attribute specifies the maximum number of supported concurrent map requests that can target this data source.

For more information about the name and number_of_mappers attributes, see Section 1.5.2.14.

After adding the data source definition, you must restart MapViewer to have the new data source created. After you do this, whenever you request a map from this data source, MapViewer obtains the necessary database connections from the container before proceeding.

1.7 High Availability and MapViewer

Note:

This section is intended for advanced users who want to take full advantage of the high availability features of Oracle Fusion Middleware with MapViewer. You must have a strong understanding of high availability features, which are described in Oracle Fusion Middleware High Availability Guide.

MapViewer users can benefit from the high availability features of Oracle Database and Oracle Fusion Middleware.

1.7.1 Deploying MapViewer on a Multiprocess OC4J Instance

You can safely deploy MapViewer in an OC4J instance of Oracle Fusion Middleware that has multiple processes. Oracle Fusion Middleware lets you configure the number of actual processes (JVMs) that can be started for each OC4J instance. On a multiprocessor host, starting multiple processes for a single OC4J can better utilize the system resources. (Releases of MapViewer before 10g Release 2 (10.1.2) could not take advantage of this feature and thus could not be deployed on such OC4J instances.)

When MapViewer is deployed to an OC4J instance with multiple processes, each process has a MapViewer server running inside it. These MapViewer servers all reside on the same host but in different Java processes. Map requests sent to this OC4J instance are automatically dispatched to the individual MapViewer servers. Each MapViewer server generates map image files according to a unique naming scheme, with the names coordinated when the different MapViewer servers are first started (that is, when the containing OC4J instance is started). This avoids the possibility of two MapViewer servers generating map files in the same sequence with the same file names.

1.7.2 Deploying MapViewer on a Middle-Tier Cluster

OC4J instances in different Oracle Fusion Middleware 10gR3 installations can be clustered into an island. This provides a middle-tier fail-safe option. MapViewer can be deployed to an OC4J island. You must take care, however, about how the generated image files on each host are named and referenced through URLs by client applications.

Consider the following sample scenario. When a map request is sent to the front Web server, it reaches the MapViewer server running on host A. MapViewer on host A then sends back the URL for the generated map image, and the client then sends a second request to fetch the actual image. This second request might be received by the OC4J container running on host B, which has no such image (or which will send back an incorrect image with the same name).

There is no single best solution for this problem in all environments. One option is to have the hosts share common networked storage, so that the map images are deposited in the same virtual (networked) file system by different MapViewer servers running on different hosts. You must configure the map file storage information (see Section 1.5.2.2) for each MapViewer instance so that the images are deposited in different subdirectories or so that they have different file prefixes. Otherwise, the image files generated by the multiple MapViewer servers might overwrite each other on the disk. By properly configuring the map file storage information, you ensure that each URL sent back to the client uniquely identifies the correct map on the network drive.

If you cannot use networked drives, consider using a load balancer. You may first need to configure the map file storage information for each MapViewer instance (as explained in the preceding paragraph), so that each MapViewer instance names its generated images using an appropriate scheme to ensure uniqueness. You can then specify rules in the load balancer to have it redirect image requests to a certain host if the URL matches a certain pattern, such as containing a specified map image file prefix.

1.8 Secure Map Rendering

This section describes how to implement secure map rendering based on a Web user's identity. Users with different roles or permissions will see different feature sets when viewing the same theme. The basic idea is that MapViewer will always invoke a specified PL/SQL package to set the Web user's identity in the database whenever accessing the database for any themes. This user information can be used by the database to enforce data access control.

Note:

In this section, the terms user and authenticated user refer to the application or Web user that logs into Oracle Fusion Middleware or Oracle Single Sign-On (SSO). It is not the same as the database user. MapViewer itself will connect directly to a database schema that stores all the geospatial data.

MapViewer will connect directly to a database schema that stores all the geospatial data. To enforce access control for MapViewer on the data in this schema, you must perform the following steps:

  1. Create a PL/SQL package in the database schema. The package must have at least two named procedures: set_user(username) and clear_user().

  2. Create views, set access rights on database objects, and perform other tasks, based on the user identity stored in the PL/SQL package (which is set by MapViewer through the set_user procedure for each database session).

  3. Create a MapViewer data source to the schema, providing the name of the PL/SQL package as part of the data source definition. This is considered a secured data source.

  4. Create MapViewer themes that are based on the views created in step 2.

  5. Establish Web authentication for users accessing your MapViewer application page or pages, so that when a map request reaches the MapViewer servlet, the Web session object should contain an authenticated user's identity.

  6. Issue map and FOI (feature of interest) requests that view the themes defined in step 4, either directly or through the use of base maps and Oracle Maps.

    MapViewer will automatically pass the user identity to the database using the PL/SQL package before it executes any query for these themes. Only those rows that are visible to the identified user will be returned from the database and rendered by MapViewer.

Section 1.8.1 explains how secure map rendering works and provides implementation details and examples. Section 1.8.3 describes some options for authenticating users and refers to a supplied demo.

1.8.1 How Secure Map Rendering Works

MapViewer, as a J2EE application, can obtain the identity of a web user that has been authenticated to Oracle Fusion Middleware or Oracle Single Sign-On (SSO). This user information can then be preserved and propagated to the database, where secure access to map layers and tables can be set up based on the user identity. For example, a database administrator (DBA) can create a view of a base table that selects only those spatial features visible to a specific user.

To pass the Web user identity from Oracle Fusion Middleware or Oracle Single Sign-On (SSO) to the database, use a secure PL/SQL package that sets the user identity in the database. This PL/SQL package is created by a DBA or application developer and installed in the data source schema. Such a package can have any number of procedures and functions, but it must contain at least the following two procedures:

  • set_user(username)

  • clear_user()

Whenever a theme is requested from a secured data source, MapViewer invokes the set_user procedure in the associated PL/SQL package before it executes any data query for the theme, and it invokes the clear_user procedure when the querying process is complete for the theme.

Example 1-3 shows a PL/SQL package that you can use for secure map rendering. You can create this package in the example MVDEMO schema.

Example 1-3 PL/SQL Package for Secure Map Rendering

CREATE OR REPLACE PACKAGE web_user_info
AS
    PROCEDURE set_user (p_name IN VARCHAR2);
    PROCEDURE clear_user;
    FUNCTION  get_user
        RETURN VARCHAR2;
END;
CREATE OR REPLACE PACKAGE BODY web_user_info
AS
    w_name VARCHAR2 (32767);
 
  PROCEDURE set_user (p_name IN VARCHAR2)
  AS
  BEGIN
     w_name := LOWER (p_name);
  END;
 
  PROCEDURE clear_user
  AS
  BEGIN
      w_name := null;
  END;
 
  FUNCTION get_user
    RETURN VARCHAR2
  AS
  BEGIN
    RETURN w_name;
  END;
END;
/

In Example 1-3, set_user and clear_user are two required methods, and get_user is a convenience function that can be used in creating views or for other data access control purposes

After you create the package (which essentially contains the user identity for the current database session), you can set up an elaborate virtual private database that uses this user information (see Oracle Database Security Guide for information about using Oracle Virtual Private Database, or VPD). For simplicity, however, this section does not discuss VPD creation, but shows that you can create views that use this user information to enforce data access control.

For example, in the example MVDEMO schema you can add a column named ACCOUNT_MGR to the existing CUSTOMERS table, and assign an account manager to each customer stored in this table. You can then create a view that returns only customer rows for a specific account manager, as shown in Example 1-4.

Example 1-4 View for Secure Map Rendering

CREATE OR REPLACE VIEW customers_view
AS
  SELECT * FROM customers
  WHERE account_mgr = web_user_info.get_user;

You can now define a MapViewer theme based on this view, so that whenever account managers log in and want to view customer data on a map, each will only see his or her own customers.

After you have installed the PL/SQL package, you can pass the name of this package to MapViewer as part of the definition of a data source by using the plsql_package attribute, as shown in Example 1-5.

Example 1-5 Data Source Definition for Secure Map Rendering

<map_data_source name="mvdemo"
                 jdbc_host="stadb32.us.oracle.com"
                 jdbc_sid="mv"
                 jdbc_port="15214"
                 jdbc_user="mvdemo"
                 jdbc_password="password"
                 jdbc_mode="thin"
                 number_of_mappers="3"
                 allow_jdbc_theme_based_foi="true"
                 plsql_package="web_user_info"
   />

When you specify a PL/SQL package name in a data source definition, MapViewer flags the data source as a secure data source, and it automatically invokes the package's set_user and clear_user procedures whenever performing any theme queries on the data source.

1.8.2 Getting the User Name from a Cookie

Sometimes the authenticated user's name is not passed to MapViewer through a J2EE or OSSO session. such as when you integrate MapViewer within Application Express (APEX), where authentication is carried out by APEX and the user name is not available through a J2EE or OSSO session. To enable you to work around this issue, MapViewer also supports getting the user name from a cookie. Note that it is your responsibility to set up the cookie within APEX to hold the authenticated user name.

To ensure that MapViewer picks up the user name from a named cookie, you must specify the web_user_type attribute in the data source definition (in addition to the mandatory plsql_package attribute). For example, if you want MapViewer to pick up the user name from a cookie named MON_USER, your secure data source definition should look like Example 1-6.

Example 1-6 Data Source Definition Specifying Cookie Name

<map_data_source name="mvdemo"
                  jdbc_host="stadb32.us.oracle.com"
                  jdbc_sid="mv"
                  jdbc_port="25650"
                  jdbc_user="mvdemo"
                  jdbc_password="LfCDQ6NH59nuV7zbeY5QY06sqN7XhiUQ"
                  jdbc_mode="thin"
                  number_of_mappers="3"
                  allow_jdbc_theme_based_foi="true"
                  plsql_package="web_user_info"
                  web_user_type="MON_USER"
  />

The possible values for the web_user_type attribute are:

  • J2EE_USER: tells MapViewer to get the authenticated user name from a J2EE session

  • OSSO_USER: tells MapViewer to get the authenticated user from an OSSO session.

  • <cookie-name>: tells MapViewer to get the authenticated user from a cookie with the specified name. The cookie name is not case sensitive.

If web_user_type is not specified, MapViewer first looks for the user name in the J2EE session; and if none is found, it looks for the user name in the OSSO session (if present).

1.8.3 Authenticating Users: Options and Demo

How, when, and where users are authenticated depend on the requirements of your application and the setup of your installation. For example, your options include the following:

  • Deploy MapViewer as part of an enterprise portal site, so that end users always first log onto the portal before performing any mapping functions through MapViewer.

  • Deploy MapViewer on a separate system, and have users authenticate to a central Oracle SSO server.

As long as the HTTP requests reaching MapViewer contain the authenticated user information, MapViewer will be able to pass the requests on to the database, and the secure data access approach will work as expected.

The demo files supplied with MapViewer (see Section 1.9) include an explanation, plus related files, for restricting a single mapping page to be accessible only by authenticated users. This demo involves making simple changes to MapViewer's own deployment files. In this case, this protected page is the entry point that causes users to be authenticated, and the authentication is performed by the OC4J instance running MapViewer.

1.9 MapViewer Demos and Tutorials

Several demos and tutorials are supplied with MapViewer. For information about them, go to:

http://host:port/mapviewer/fsmc/tutorial/demos.html