MapViewer Concepts 2-57
In this table, the GEOM column contains spatial geometries, and the MERK column contains company names Shell, Esso, and so on.
The styling rules for the theme_gasstation theme specify that the marker style v.gasstations at a location specified by the content of the GEOM column is
determined by the value of the MERK column for that row. The style v.gasstations see
Example 2–40 specifies that if the column value is Shell, use the style m.shell
gasstation; if the column value is Esso, use the style m.esso gasstation; and so on, including if the column value is any one of Avia, Benzinex, Q8, Total, and
Witte Pomp, use the style m.generic gasstation; and if the column value is none of the preceding, use the style m.default gasstation.
2.3.10.1 Thematic Mapping Using External Attribute Data
Previous discussion of thematic mapping has assumed that both the attribute data such as population of sales totals and the geospatial data geometry objects
representing boundaries, locations, and so on are in the same database. However, the attribute data can come from a source outside the current database; for example, the
attribute data might reflect aggregated results of a business intelligence BI query performed on a different database, or the attribute data might come from a
comma-delimited list of sales values exported from a spreadsheet. Such attribute data, from outside the database that contains the geospatial data, is called external attribute
data
.
To use external attribute data with MapViewer, you must use the nonspatial data provider
plug-in mechanism, in which a custom data provider is associated with a MapViewer theme predefined or dynamic in the same map request. When
MapViewer process the theme, it calls the nonspatial data provider to join nonspatial attribute data with the spatial data that has been fetched for the theme.
To use a nonspatial data provider, follow these steps:
1.
Implement your Java nonspatial data provider by implementing the MapViewer defined interface oracle.mapviewer.share.ext.NSDataProvider.
2.
Register the nonspatial data provider implementation with MapViewer in its configuration file. There you can also specify a set of global parameters that your
Table 2–2 Table Used with Gasoline Stations Theme
Column Data Type
FID NOT NULL NUMBER
ID NUMBER
NAAM VARCHAR231
STRAAT_ VARCHAR230
NR NUMBER
TV VARCHAR21
AAND VARCHAR22
PCODE VARCHAR26
PLAATS VARCHAR210
GEOM SDO_GEOMETRY
MERK VARCHAR240
2-58 Oracle Fusion Middleware Users Guide for Oracle MapViewer
implementation may depend on. Note that each custom data provider implementation class must have a unique ID that you assign.
3.
Place a library containing the nonspatial data provider implementation classes in the library path of MapViewer, such as its webWEB-INFlib directory.
4.
Include the nonspatial data provider implementation in a map request by invoking the following method on the MapViewer Java client API class
MapViewer:
addNSDataProviderjava.lang.String providerId, java.lang.String forTheme,
java.lang.String spatialKeyColumn, java.lang.String customRenderingStyle,
java.util.Properties params, long timeout
For information about the addNSDataProvider parameters, see the Javadoc reference information for MapViewer, available at a URL in the form
http:host:portmapviewermapclient, where host and port indicate where OC4J or Oracle Fusion Middleware listens for incoming requests. For
example: http:www.mycorp.com:8888mapviewermapclient
Example 2–42 shows a simple nonspatial data provider implementation. This
implementation is also supplied with MapViewer as a default nonspatial data provider.
Example 2–42 Nonspatial External Data Provider Implementation
import java.io.BufferedReader; import java.io.FileReader;
import java.util.Properties; import java.util.Vector;
import oracle.mapviewer.share.ext.NSDataSet; import oracle.mapviewer.share.ext.NSDataProvider;
import oracle.mapviewer.share.ext.NSRow; import oracle.lbs.util.Logger;
import oracle.mapviewer.share.Field; A simple implementation of the NSDataProvider interface. When invoked, it
supplies tabular attribute data to MapViewer out of a file or URL. The data in the file must be orgazined as following: br
UL LI The first line contain a single character which is the delimiter
between columns in the subsequent lines. LI Each line after the first in the file represent one data row
LI Each field in the row must be separated by the delimiter char only LI The first field in each line must be a string key that serves as the
key; the rest of the fields must be numeric values UL
When incorporating this data provider in a map request, one of the following two parameters must be specified:
UL LI file if the custom data is stored in a local file; this parameter
specifies the full path to that file LI url if the custom data can be accessed from a web; this parameter
specifeis the full URL to the data file.
MapViewer Concepts 2-59
UL public class NSDataProviderDefault implements NSDataProvider
{ private static Logger log = Logger.getLoggeroracle.sdovis.nsdpDefault;
public boolean initProperties params {
return true; }
public NSDataSet buildDataSetProperties params {
String file = params.getPropertyfile; iffile=null
return readFromFilefile; String url = params.getPropertyurl;
ifurl=null return readFromUrlurl;
log.errorMust supply either file or url for default NS data provider.; return null;
} public void destroy
{ }
protected NSDataSet readFromFileString file {
BufferedReader in = null; try{
in = new BufferedReadernew FileReaderfile; String line = in.readLine;
String delimiter = line.substring0,1; Vector rows = new Vector;
while line=in.readLine = null {
NSRow row = buildRowline, delimiter; ifrow=null
rows.addrow; }
NSDataSet res = new NSDataSetrows; return res;
}catchException ex {
log.errorex; return null;
} finally {
try{ ifin=null
in.close; }catchException e{}
2-60 Oracle Fusion Middleware Users Guide for Oracle MapViewer
} }
protected NSDataSet readFromUrlString url {
log.errorurl not supported yet.; return null;
} protected NSRow buildRowString line, String delimiter
{ ifline==null || line.length1
return null; String[] fields = line.splitdelimiter;
iffields==null || fields.length==0 return null;
Field[] row = new Field[fields.length]; Field a = new Fieldfields[0];
a.setKeytrue; row[0] = a;
for int i = 1; i fields.length; i++ {
try{ double d = Double.parseDoublefields[i];
a = new Fieldd; row[i] = a;
}catchException e {
log.warninvalid row field key=+fields[0]+; return null;
} }
return new NSRowrow; }
}
2.3.11 Attributes Affecting Theme Appearance