Maps > Predefined Readers > The Oracle Spatial Features > Relational Model Classes
 
Relational Model Classes
This section covers the following topics:
*Classes for Reading Data from an Oracle Spatial Database
*Class for Writing Data to an Oracle Spatial Database
Classes for Reading Data from an Oracle Spatial Database
The reader classes for the Oracle SDO relational model are:
*IlvSDOFeatureIterator for converting Oracle Spatial layer data into IlvMapFeature objects.
*IlvSDOLayer for implementing load-on-demand for relational Oracle Spatial data.
*IlvSDOTileLoader “abstract” class for defining Oracle queries for the IlvSDOLayer. A subclass, IlvDefaultSDOTileLoader (which is optimized) is used by IlvSDOLayer.
IlvSDOFeatureIterator
This class reads data from the result of an SQL query to a relational Oracle Spatial layer and converts it into IlvMapFeature objects. Rogue Wave Views Maps applications can handle Oracle Spatial data using this class in a transparent manner. The following example of C++ code performs a query (using Rogue Wave DB Link), loading data from an Oracle Spatial layer named ROADS_SDOGEOM:
IlString query = IlString("SELECT * FROM ROADS_SDOGEOM ORDER BY 1, 2, 4");
//keep always the ORDER BY statement
IldDbms* myDbms = IldNewDbms("oracle8", "scott/tiger@myDomain");
IldRequest* resultSet = myDbms->getFreeRequest();
resultSet->execute(query.getValue());
 
The query orders the result using the following three criteria, which must be given in the order indicated:
1. GID (Geometric ID)
2. ESEQ (Element Sequence)
3. SEQ (row sequence)
Note: This ordering is necessary for the IlvSDOFeatureIterator to work correctly.
The ResultSet of any query to an Oracle Spatial layer can be used to initialize an IlvSDOFeatureIterator, but all the SDO columns must be in the resultSet (columns defining the GID, ESEQ, ETYPE, SEQ, and the coordinates).
The features returned by this iterator have no attributes. However, the GID of the Oracle Spatial geometry is used as the identifier of each feature and the identifier of each feature can be used to retrieve additional attributes from the database. See the method getId().
IlvSDOLayer
This class implements load-on-demand for a relational Oracle Spatial data source. The default implementation takes an Oracle Spatial layer for which a spatial indexation has been performed and reads its content with a tiling equivalent to the Oracle Spatial tiling.
The following example creates an IlvSDOLayer on an Oracle Spatial layer named ROADS_SDOGEOM:
IldDbms* myDbms = IldNewDbms("oracle8", "scott/tiger@myDomain");
IlvMapAdapter* adapter = new IlvMapAdapter(0.5);
// Create an adapter that fits your data.
IlvSDOLayer* layer = new IlvSDOLayer(adapter, myDbms, "ROADS_SDOGEOM");
manager->addLayer(layer);
 
IlvSDOTileLoader
This class offers additional possibilities when retrieving data from an Oracle Spatial database. These possibilities are meant as a supplement to the default behavior of IlvSDOLayer. For example, you may want to have a tiling definition that is different from the Oracle tiling.
IlvDefaultSDOTileLoader
This class is a subclass of IlvSDOTileLoader and is used by the IlvSDOLayer. It has some optimizations. For example, the method setTileGroupingCount() allows you to set the number of tiles that will be grouped in one unique query to the database. In fact, each tile corresponds to a Spatial query. If you have an average of n tiles to load each time you want to load-on-demand, you should use setTileGroupingCount(n) where all the n queries will be grouped into one unique query that will be sent to the database.
Note: If you want to handle special operations on each IlvMapFeature retrieved in load-on-demand with the IlvSDOLayer layer, you have to subclass the IlvDefaultSDOTileLoader in order to override the getFeatureIterator method. In this method, you have to return an instance of a subclass of IlvSDOFeatureIterator where you have overridden the getNextFeature method (inside which you can perform your specific operations on each IlvMapFeature returned by the layer). Finally, you have to set your subclass of IlvDefaultSDOTileLoader as the tile loader of the layer.
Class for Writing Data to an Oracle Spatial Database
This section describes the IlvSDOWriter class that allows you to write map features into a relational Oracle Spatial database.
IlvSDOWriter
The IlvSDOWriter class can write any IlvMapFeatureIterator whose features have a geometry supported by the relational model of Oracle Spatial (vectorial geometries) and write them to the database as in the following example:
IldDbms* myDbms = IldNewDbms("oracle81", "scott/tiger@myDomain");
IlvSDOWriter* writer = new IlvSDOWriter(myDbms, "MyLayer", 135);
// Create a source feature iterator.
IlvShapeFileReader* reader = new IlvShapeFileReader("foo.shp", 0);
IlInt geomCount;
// Dump its content to the Oracle layer.
writer->writeFeatureIterator(reader, geomCount);
The write method of the IlvSDOWriter does not write the attributes of the features. If you want to write the attributes of the features, you can subtype the writeFeature method of the IlvSDOWriter after calling the writeFeature(feature) method of the mother class.
Note: The geometries supported by the Oracle Spatial writer are: IlvMapPoint, IlvMapLineString, IlvMapPolygon, IlvMapMultiPoint, and IlvMapMultiCurve for multiline strings and IlvMapMultiArea for multipolygons.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.