Using Optimal Methods for Thick Clients

MapViewer JavaBean-Based API 4-15 point to a point in the user data space before using the getSpatialFilter method. ■ getUserPointint x, int y returns the user data space point corresponding to the mouse click. ■ getUserPointint x, int y, java.lang.String dataSource, int outSRID returns the user data space point corresponding to the mouse click, using the specified coordinate system SRID value. ■ getUserPointint x, int y, java.lang.String dataSource, java.lang.String themeName returns the user data space point corresponding to the mouse click, using the coordinate system SRID value associated with the specified theme. ■ getWhereClauseForAnyInteractjava.lang.String spatialColumn, int srid, double x, double y returns geometries that have any interaction with a specified point in the users data space. This provides a WHERE clause string that will use a more precise spatial filtering method than the one provided by the getSpatialFilter method. ■ getWhereClauseForAnyInteractjava.lang.String spatialColumn, int srid, double xl, double yl, double xh, double yh returns the WHERE clause that can be used to find geometries that have any interaction with the specified user space window. It is similar to the getSpatialFilter method, but uses a more precise version of the Oracle Spatial filtering method. ■ identify and variants provide a convenient method for identifying nonspatial attributes. This is desirable if you do not need more flexibility and control over how a nonspatial attribute query should be formulated. As with the doQuery methods, all identify methods return a double String array that contains the result set of the query.

4.3.10 Using Optimal Methods for Thick Clients

When you use the MapViewer bean in a JavaServer Page in an HTML file, a second round-trip to the MapViewer service is needed to obtain nonspatial attributes of features being displayed. It is also true that with a JavaServer Page in an HTML file, even if most themes remain unchanged from one map request to the next such as when zooming in to the center of a map, all themes must still be reprocessed each time the MapViewer service processes the page, which causes the data for each theme to be retrieved again from the database. This is mainly due to the stateless nature of the MapViewer service and the insufficient mechanism provided in the JSP context for handling user interaction, which must be based on the requestresponse model. However, when you are working in a thick client environment, such as with J2SE Java 2 Platform Standard Edition applications and applets, you can reduce the processing and bandwidth overhead when using the bean. This is primarily because in such environments you have greater control of how content including the map should be displayed, you can better respond to the user’s interaction, and you can devote more resources to maintaining the states on the client side. A key optimization available only to the thick client context is live features. Basically, a live feature is a spatial feature that originates from the MapViewer service but exists in the thick client. Each live feature contains the actual shape representing the geometry data, and a set of nonspatial attributes that the user might be interested in. To obtain live features, a thick client must set its parent theme to be clickable. When a map request is sent to the MapViewer service with a clickable theme, MapViewer does not attempt to render features for that theme in the resulting map. Rather, the set of 4-16 Oracle Fusion Middleware Users Guide for Oracle MapViewer features that would have been drawn as part of the map is returned to the requesting client as an array of live feature objects. The rest of the map is still rendered and transmitted as a single image to the client. After the client has received both the live features and the base image, it must render the live features on top of the accompanying map image, using one of the methods described later in this section. One benefit of using live features is that the thick client will not need to issue a request for the clickable theme every time a map request is sent. For example, if the request is to zoom in to the current map, the client can determine for each live feature if it should be displayed in the zoomed-in map image. Another, and probably more significant, advantage is that the nonspatial attributes for all features displayed in the map are now readily available to the user. For example, as the user moves the mouse over a range of features on the map, the thick client can immediately get the corresponding nonspatial attributes and display them in a pop-up window that follows the mouse trail. No round-trip to the MapViewer service is needed for this type of action, and the feedback to the user is more responsive. The methods that are optimal for thick clients include the following: ■ drawLiveFeaturesjava.awt.Graphics2D g2, java.awt.Color stroke, java.awt.Color fill, double pointRadius, double strokeWidth draws all live features that are returned to this client from MapViewer. ■ getLiveFeatureAttrsint x, int y, int tol gets the nonspatial attributes of the feature being clicked on by the user. ■ getNumLiveFeatures returns the number of live features currently available. ■ hasLiveFeatures checks if there are any live clickable features. ■ highlightFeatures and variants highlight all live features that are intersecting the user-specified rectangle. These methods also let you specify the style for highlighting features. ■ isClickablejava.lang.String themeName checks if the specified theme is clickable that is, if users can click on the theme to get its attributes. ■ setClickableboolean v, java.lang.String themeName sets the theme clickable so that its features will be available to the client as live features that users can click on and get attributes of. To obtain a set of features and keep them live at the thick client, you must first call setClickable to set the theme whose features you want to be live. Then, after you issue the current map request, the bean processes the response from the MapViewer service, which if it succeeded contains both a base map image and an array of LiveFeature instances. You can then call getGeneratedMapImage to get and draw the base image, and use drawLiveFeatures to render the set of live features on top of the base map. If the user clicks or moves the mouse over a certain position on the map, you can use the highlightFeatures method to highlight the touched features on the map. You can also use the getLiveFeatureAttrs method to obtain the associated nonspatial attributes of the features being highlighted. You do not have direct access to the LiveFeature instances themselves. The behavior of calling the methods described in this section in the context of JSP pages is not defined. 5 MapViewer JSP Tag Library 5-1 5 MapViewer JSP Tag Library This chapter explains how to submit requests to MapViewer using JavaServer Pages JSP tags in an HTML file. Through an XML-like syntax, the JSP tags provide a set of important but not complete MapViewer capabilities, such as setting up a map request, zooming, and panning, as well as identifying nonspatial attributes of user-clicked features. You can develop a location-based application by using any of the following approaches: ■ Using the XML API see Chapter 3 ■ Using the JavaBean-based API see Chapter 4 ■ Using JSP files that contain XML or HTML tags, or both, and that include custom Oracle-supplied JSP tags described in this chapter Creating JSP files is often easier and more convenient than using the XML or JavaBean-based API, although the latter two approaches give you greater flexibility and control over the program logic. However, you can include calls to the Java API methods within a JavaServer Page, as is done with the call to the getMapTitle method in Example 5–1 in Section 5.3 . All MapViewer JSP tags in the same session scope share access to a single MapViewer bean. This chapter contains the following major sections: ■ Section 5.1, Using MapViewer JSP Tags Deprecated Feature: MapViewer JSP Library: The MapViewer JSP library is deprecated, and will not be included in future releases of the documentation. Instead, you are encouraged to use the MapViewer Java API, which is more comprehensive and up to date. Moreover, if you prefer to use tags, consider using the GeoMap tags in the JDeveloper Application Development Framework ADF. Note: The MapViewer JSP tag library will not work with Oracle9iAS Release 9.0.2 or the standalone OC4J Release 9.0.2. The minimum version required is Oracle9iAS Release 9.0.3 or the standalone OC4J Release 9.0.3. 5-2 Oracle Fusion Middleware Users Guide for Oracle MapViewer ■ Section 5.2, MapViewer JSP Tag Reference Information ■ Section 5.3, JSP Example Several Tags for MapViewer

5.1 Using MapViewer JSP Tags