User Guide > Mapping with PV-WAVE > How to Optimize Your Mapping Application
  

How to Optimize Your Mapping Application
This section describes several methods for improving the performance of your mapping application. These methods will help you to design a mapping application that performs well at an acceptable resolution.
In general, map data is processed and displayed in four stages in PV‑WAVE. When considering how to improve the performance of a mapping application, it is helpful to keep in mind these four stages, illustrated in Stages to Generate Map.
 
Figure 12-8: Stages to Generate Map
This section focuses on performance improvements that can be gained in stages 1 and 2. Stage 3 cannot be substantially improved because it depends on array operations, which are already optimized by PV‑WAVE.
The performance of stage 4, plotting the data, depends largely on the size of the dataset being plotted. Reducing the size of the dataset is the primary focus of this section.
A summary of methods for improving the speed at which PV‑WAVE reads and displays map data is shown in Table 12-2: Methods for Optimizing Mapping Applications on page 325. More details are provided in this section.
 
Table 12-2: Methods for Optimizing Mapping Applications  
Optimization Method
Advantages
Disadvantages
Subsetting data with MAP keywords Select, Range, Center, and Zoom.
Keywords are easy to use and
accessible to all PV‑WAVE users.
Allow you to display only those portions of the map that are of
interest.
Reduces the overall amount of data to be plotted.
Subsetting can be a slow process for very large datasets.
May not be sufficient if a large portion of the map must be displayed at once.
Reduce the number of map data points plotted with the Resolution keyword.
Useful for wide-area maps where fine detail may not be necessary.
Reduces the overall amount of data to be plotted.
Cannot be used with the usgs_db dataset.
Use the File_Path
keyword to save a
subsetted dataset in a binary file that can be read and displayed quickly with the Read_Path keyword.
Subsequent calls to MAP can skip the steps of reading and subsetting the map data.
Provides excellent performance for applications that make calls to the MAP procedure to plot and replot the same dataset.
Reduces the
detail/accuracy of the original map.
Use DEVICE, /Copy or TVRD to create an image of a basemap that can be rapidly re-displayed.
Provides excellent performance.
Resolution is limited to the resolution of the window into which the data is copied.
Write a C or FORTRAN procedure to read and subset a large map dataset before placing the data in memory.
Useful for handling user-supplied datasets that are too large to read into memory in one chunk.
PV‑WAVE can access the C or FORTRAN procedure via LINKNLOAD.
Reduces the overall amount of data to be plotted.
Only useful for C or
FORTRAN programmers. Some knowledge of PV‑WAVE connectivity features is also required.
Reduces the
detail/accuracy of the original map.
Subsetting Data with MAP Procedure Keywords
Perhaps the easiest way to improve the performance of a mapping application is to subset the map dataset using keywords provided with the MAP procedure. These keywords are passed directly to the procedure that reads the map dataset, so that the data is subsetted before it is read into memory.
For additional information on the keywords described below, see the description of the MAP procedure in the PV‑WAVE Reference. See also "Subsetting the Map Dataset".
Subsetting with the Select Keyword
The Select keyword reduces the amount of data returned to the MAP procedure. It lets you specify only the map features that you want to plot from the dataset. Selecting a subset of the available map features can improve performance significantly.
The Select keyword can be used to subset the world_db and usgs_db datasets.
Subsetting with Range, Zoom, and Center Keywords
These keywords let you subset a map dataset by specifying a range of data to plot. In other words, only the data that falls within a selected area is returned by the MAP procedure. With the Range keyword, you specify an area to plot within a range of longitude and latitude values. The Zoom and Center keywords allow you display an area surrounding a specified point.
Subsetting with the Resolution Keyword
The Resolution keyword reduces (samples) the number of data points that are plotted, thereby reducing the map resolution. This keyword can be useful when plotting a wide area map where the full resolution of the database might not be discernible given the resolution of the output device.
This keyword can only be used with the world_db dataset.
Use File_Path and Read_Path Keywords to Avoid Re-reading Data
As noted previously, the procedure that reads the dataset (e.g., world_db or usgs_db) is responsible for performing most of the subsetting. However, each time the MAP procedure is called, the map-reading procedure is called, and the process of subsetting the data is repeated.
This ensures that the full resolution of these datasets can be accessed when needed, but can slow down performance when the same data subset must be plotted repeatedly.
The File_Path and Read_Path keywords to the MAP procedure store a subsetted dataset in a binary file and then read it for subsequent calls to MAP. The Read_Path keyword restores the data quickly without calling the dataset-reading procedure.
Thus the mapping process is reduced to reading a small dataset, projecting it, and plotting it. This method provides the optimal performance and the best resolution for large datasets. The demonstration routines for mapping use this technique to optimize their speed of execution, and the same technique can be used in your own applications. The demonstration routines are in:
(UNIX) $RW_DIR/mapping-2_0/demo
(WIN) %RW_DIR\mapping-2_0\demo
Where RW_DIR is the main Rogue Wave installation directory.
Creating a Basemap Image
There are other techniques, not strictly related to mapping, which can be used in some circumstances to further increase the performance of drawing a basemap. For instance, if a basemap needs to be redrawn quickly many times in an X Window System environment, the command:
DEVICE, Copy 
can be used to rapidly update a window from a copy held in another window. The following example demonstrates this, and can be used to update a map in a fraction of a second, but with the limitation that the resolution is limited to that of the window in which the map is created.
; Create an invisible pixmap window.
WINDOW, 1, Xsize = 600, Ysize = 400, /Pixmap
; Draw a map of Europe.
MAP, Center = [10, 50], Zoom = 7
; Create a visible window of the same size.
WINDOW, 0, Xsize = 600, Ysize = 400
; Copy the contents of the pixmap window to the visible window.
; (This can be repeated indefinitely.)
DEVICE, Copy = [0, 0, 600, 400, 0, 0, 1]
It is also possible to use the TVRD command to copy the contents of a window containing a basemap into a byte array variable. Saving this variable in a file allows the basemap to be restored by simply reading the variable and redisplaying the image, as in this example:
; Create a window.
WINDOW, Xsize = 600, Ysize = 400
; Draw a map of Europe.
MAP, Center = [10, 50], Zoom = 7
; Copy the contents of the window to the basemap variable.
basemap = TVRD(0,0, 600, 400)
; Save the basemap variable.
SAVE, basemap, File = 'mybasemap.dat'
Then to restore the basemap later:
; Restore the basemap image.
RESTORE, File = 'mybasemap.dat'
; Create a window.
WINDOW, 1, Xsize = 600, Ysize = 400
; Redisplay the basemap image.
TV, basemap
Optimized Data Reading
Two procedures designed to read map datasets are provided with PV‑WAVE. These procedures, world_db and usgs_db, read map data directly into memory whenever they are called.
If you supply your own dataset (that is, a dataset other than the World Databank II or USGS datasets) and write a procedure to read it, it is possible that it will be too large to read the entire dataset into memory at once.
In this case, a C or FORTRAN program can be written to read and subset the data prior to placing it in memory. Using connectivity features, such as LINKNLOAD, a PV‑WAVE procedure can be written to call the C or FORTRAN program in a mapping application. This method can provide the best access speed for large datasets, and can be useful when you need to perform a lot of testing to determine how to subset the data correctly.
See "Accessing Other Map Datasets" for information on writing a procedure to read a dataset.

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.