Extracting Information from the Current Map Response Obtaining Information About Data Sources Querying Nonspatial Attributes in the Current Map Window

MapViewer JavaBean-Based API 4-13 ■ zoomInint x, int y, double factor zooms in on the specified device point. ■ zoomInint x1, int y1, int x2, int y2 zooms in on the specified device rectangle. ■ zoomOutdouble factor zooms out on the current map without changing the other map request parameters. ■ zoomOutint x, int y, double factor zooms out and recenters the current map. Each of these methods assembles a single XML map request document based on all properties of the current map request, and then sends it to the MapViewer service. After the MapViewer bean receives the response from the MapViewer service, the bean does any necessary postprocessing and makes the response ready for your use. As an alternative to using these methods, you can formulate an XML request string outside the bean, and then use the sendXMLRequestjava.lang.String req method to send the request to the MapViewer service. However, if you use this method, you are responsible for receiving and unpacking the response using the getXMLResponse method, and for parsing and interpreting the response string yourself. The state of the bean remains unchanged, because the methods are only making use of the bean’s capability to open an HTTP connection to send and receive documents over the connection. All methods described in this section throw an exception if any unrecoverable error occurs during the transmission of the request or response, or in the MapViewer service during processing. You are responsible for taking care of such exceptions in any way you consider appropriate, such as by trying the request again or by reporting the problem directly to the user.

4.3.7 Extracting Information from the Current Map Response

You can extract information, such as the generated map image or the URL for the image, from the current map response. The methods for extracting information from the map response include the following: ■ getGeneratedMapImage returns the actual map image data contained in the response from the MapViewer service. You must have set the image format to FORMAT_RAW_COMPRESSED using the setImageFormat method. The getGeneratedMapImage method is primarily used in thick clients, although you may also use it in a JavaServer Page or a servlet for example, to save the image in a format that is not supported by MapViewer. ■ getGeneratedMapImageURL returns the URL to the currently generated map image in the application server. You must have set the image format to FORMAT_ PNG_URL or FORMAT_GIF_URL using the setImageFormat method. ■ getMapMBR returns the MBR minimum bounding rectangle for the currently generated map, in the users data space. ■ getMapResponseString returns the last map response in XML format.

4.3.8 Obtaining Information About Data Sources

The MapViewer bean has methods that you can use to obtain information about data sources. These methods include the following: ■ dataSourceExistsjava.lang.String dsrc checks if a given data source exists in that is, is known to the MapViewer service. 4-14 Oracle Fusion Middleware Users Guide for Oracle MapViewer ■ getDataSources lists the currently available data sources in the server. This method lists only the names and no other details about each data source such as database host or user login information.

4.3.9 Querying Nonspatial Attributes in the Current Map Window

It is often necessary to query nonspatial attributes that are associated with the spatial features being displayed in the current map image. For example, assume that you just issued a map request to draw a map of all customer locations within a certain county or postal code. The next logical step is to find more information about each customer being displayed in the resulting map image. In the JSP or HTML environment, because you get only an image back from the MapViewer service, you will need another round-trip to the service to fetch the nonspatial information requested by the user. This section describes a set of methods that can help you do just that. You can, however, obtain both the nonspatial attribute values of a certain theme and the resulting map image in a single request when the bean is used in a standalone Java application or applet environment, as described in Section 4.3.10 . A typical situation is that the user clicks on a feature on the displayed map and then wants to find out more nonspatial attributes about the feature. This action can be essentially implemented using a query with the desired nonspatial attributes in its SELECT list, and a spatial filter as its WHERE clause. The spatial filter is an Oracle Spatial SQL operator that checks if the geometries in a table column the column of type SDO_GEOMETRY in the customer table spatially interact with a given target geometry in this case, the user’s mouse-click point. The spatial filter in the WHERE clause of the query selects and returns only the nonspatial attributes associated with the geometries that are being clicked on by the user. You will need to call an Oracle Spatial operator to perform the filtering; however, you can use the MapViewer bean-based API to obtain information, and to preassemble the spatial filter string to be appended to the WHERE clause of your query. The identify method simplifies the task even further. The methods for querying nonspatial attributes in the current map window include the following: ■ doQuery and variants execute a supplied SQL query and return an array of strings representing the result set. These are convenient methods to issue your own query without manually opening a JDBC connection to the database from the bean. ■ doQueryInMapWindow and variants are extensions of doQuery and its variants. They automatically subject the user-supplied query to a spatial filtering process using the current map window. ■ getSpatialFilterjava.lang.String spatialColumn, int srid, boolean pre9i returns a spatial filter string that can be used as a WHERE clause condition in formulating your own queries in the current map window context. The spatial filter evaluates to TRUE for any geometries that are being displayed in the entire map window. You can use this method to obtain information about every spatial feature of a theme that is being displayed. ■ getSpatialFilterjava.lang.String spatialColumn, int srid, double xl, double yl, double xh, double yh, boolean pre9i returns a spatial filter string that can be used as a query condition in formulating your queries in the given window. This filter evaluates to TRUE for all geometries that interact with the supplied xl,yl, xh,yh data window. The window is not in device or screen coordinate space, but in the user’s data space; therefore, you must first call the getUserPoint method to convert the user’s mouse-click 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