IlString query = IlString("SELECT * FROM ROADS"); IldDbms* myDbms = IldNewDbms("oracle81", "scott/tiger@myDomain"); IlvObjectSDOFeatureIterator* iterator = new IlvObjectSDOFeatureIterator(myDbms, "SELECT * FROM ROADS", // the name of the geometries column "Geometry", // no Key ID 0, // the name of the x ordinates column "X", // the name of the y ordinates column "Y" ); |
IldDbms* myDbms = IldNewDbms("oracle81", "scott/tiger@myDomain"); // You should create an adapter that fits your data. IlvMapAdapter* adapter = new IlvMapAdapter(0.5); IlvObjectSDOLayer* layer = new IlvObjectSDOLayer(adapter, myDbms, // The name of the SDO layer "ROADS". // Assume that the layer has only one // geometry column. 0, // Width of a tile in the database // coordinate system. 1500, // height of a tile in the database // coordinate system. 1500, // The name of the x-ordinates column "X". // The name of the y-ordinates column "Y". ); manager->addLayer(layer); |
IlvObjectSDOLayer* layer = new IlvObjectSDOLayer(adapter, myDbms, "ROADS", 0, 1500, 1500); |
Note: If you want to handle some special operations on each IlvMapFeature retrieved in load-on-demand with the IlvObjectSDOLayer layer, you have to subclass the IlvDefaultObjectSDOTileLoader in order to override the getFeatureIterator method. In this method, you have to return an instance of a subclass of IlvObjectSDOFeatureIterator 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 IlvDefaultObjectSDOTileLoader as the tile loader of the layer. |
IldDbms* myDbms = IldNewDbms(“oracle8”, “scott/tiger@myDomain”); IlvObjectSDOWriter* writer = new IlvObjectSDOWriter(myDbms, “MyLayer”, “GEOMETRY”, “X”, “Y”, IlTrue); // Create a source feature iterator. IlvShapeFileReader* reader = new IlvShapeFileReader(“foo.shp”, 0); // Dump its content to the Oracle layer. IlInt count; writer->writeFeatureIterator(reader, count); // calls close() |
Note: In the case of the Oracle Spatial Object model, some auxiliary tables, like the user metadata table, need to be updated. It is very important to call the method IlvObjectSDOWriter::close() once the data has been written through the write() method, so that the database is kept up-to-date. |
Name | Null? | Type |
GEOMETRY | MDSYS.SDO_GEOMETRY | |
TYPE_DESC | VARCHAR2(512) |
IldDbms* myDbms = IldNewDbms("oracle81", "scott/tiger@myDomain"); IlvObjectSDOWriter* myWriter = new IlvObjectSDOWriter(myDbms, "ROADS", "GEOMETRY", "X", "Y", IlTrue); IlvMapFeature* feature = new IlvMapFeature(); // Construction of the IlvFeatureAttributeInfo: it can be done just once. IlvMapClassInfo** attributeClasses = new IlvMapClassInfo*[1]; IlvBoolean* nullable = new IlvBoolean[1]; nullable[0] = IlTrueIlTrue; attributeClasses[0] = IlvStringAttribute::ClassInfo(); char** names = new char*[1]; names[0] = new char[10]; //Exactly the same name as the layer column name. strcpy(names[0], "TYPE_DESC"); IlvFeatureAttributeInfo* info = new IlvFeatureAttributeInfo(1, names, attributeClasses, nullable); // The writing itself. IlvFeatureAttribute** attributes = new IlvFeatureAttribute*[1]; attributes[0] = new IlvStringAttribute("MY FOO TYPE"); IlvMapsError error; IlvFeatureAttributeProperty* prop = new IlvFeatureAttributeProperty(info, attributes, error); feature->setAttributeInfo(info); feature->setAttributes(prop); if (error == IlvMaps::NoError()) error = myWriter->writeFeature(feature, IlTrue); |
Note: All the subclasses of IlvMapGeometry except IlvMapText, IlvMapImage, and IlvMapRaster are supported by the object writer. |