// Bucket object
Number srid_null;
Sdopointtype * point_null = new sdopointtype ();
Point_null-> setnull ();
Sdogeometry * spatial_obj = new sdogeometry (); // create an object
Spatial_obj-> setsdo_gtype (sdo_gtype_2dpolygon );
Spatial_obj-> setsdo_srid (srid_null); // do not set the Coordinate System
Spatial_obj-> setsdo_point (point_null); // set the vertex object to null.
Vector elem_info, ordinates;
Elem_info.clear (); // clear elem_info
Ordinates. Clear (); // clear ordinates
// Store the elem_info object
Elem_info.push_back (1); elem_info.push_back (sdo_etype_polygon );
Elem_info.push_back (sdo_interpretation_rectangle );
Spatial_obj-> setsdo_elem_info (elem_info );
// Store the rectangle. ordinates can store parameters with more than 4000 characters, while ADO can store parameters with less than 4000 characters.
Ordinates. push_back (1); ordinates. push_back (1); // (1, 1)
Ordinates. push_back (5); ordinates. push_back (7); // (5, 7)
Spatial_obj-> setsdo_ordinates (ordinates );
Stmt-> setobject (1, spatial_obj );
Stmt-> executeupdate ();
Delete spatial_obj; // release the object
Conn-> terminatestatement (stmt );}
Catch (sqlexception & Ex)
{Env-> terminateconnection (conn );
Environment: terminateenvironment (ENV );
Throw ;}
Env-> terminateconnection (conn );
Environment: terminateenvironment (ENV );}
Catch (sqlexception & Ex)
{Cout <"error running Demo:" <ex. getmessage () <Endl ;}}
After compilation, the project stores a rectangle in the spatial table of Oracle Spatial. You can expand the project to store the public format of GIS software in ASCII code format to the database, such as * of MapInfo *. MIF /*. mid format, MAPGIS vertices, lines, areas, and network file plaintext data.
3.1.1.3 upload using VB and ADO
There are also differences between various application interfaces. If ADO is used, there may be situations where parameter passing does not meet the requirements. For example, the following uses ADO statements in VB6.0,
Set adocommand = nothing
Adocommand. commandtype = ad1_text
Adocommand. commandtext = "insert into spatialtable_name (spatial_column) values" & spatialdata
Adocommand. activeconnection = adoconnection
Adocommand. Execute
The commandtext attribute of the ADO command object cannot be passed if it contains more than 4000 characters. Therefore, objects in a long space need to be truncated. Therefore, using the ADO interface for upload is not the best choice. If you select the application programming interface provided by Oracle (in addition to the previously mentioned oo4o and OCI), this problem will not occur. Therefore, we recommend that you use the application programming interface provided by Oracle to develop the upload program.
3.1.2 upload using tools
Currently, many GIS software companies provide tools for uploading spatial data to Oracle Spatial, such as easyloader, ArcSDE, and MAPGIS.
3.1.2.1 easyloader
Easyloader is an upload tool provided by MapInfo. However, this tool only supports uploading *. Tab data in MapInfo format. This tool provides command line upload and window upload methods. The tool writes data to the database by calling the OCI (Oracle call interface) at the underlying layer. The biggest advantage of using easyloader to upload spatial data to Oracle Spatial is that the uploaded spatial data is stored in object-relational mode, which fully utilizes the advantages of Oracle Spatial's object-relational mode. After MapInfo Professional is installed, this tool is installed by default. You can find this tool in the % MapInfo % "Tools directory. In addition, this free tool is also available on the official website of MapInfo.
3.1.2.2 SQL * loader and shp2sdo
SQL * loader reads ASCII code data based on commands received from the control file and puts the data into the Oracle database. The control file notifies SQL * Where the loader data should be stored and describes all types of data loaded into the Oracle database. SQL * loader can also filter data (that is, do not load unsuitable data) and load data into multiple tables, A unique keyword or operation data is generated before data is placed into an oracle table.
Shp2sdo is a command line tool provided by Oracle to convert ESRI *. SHP files into control files and data files that can use SQL * loader. This tool can not only convert *. SHP to object-link format, but also to link format. This tool can be downloaded free of charge from the Oracle website.
With SQL * loader and shp2sdo, you can upload the ESRI shape file to Oracle spatial.
3.1.2.3 tools provided by ArcSDE and MAPGIS
If you have purchased an ESRI ArcSDE, you can use the arctoolbox tool to upload ESRI data through the ArcSDE spatial database engine. Like ArcMap or arccatalog, arctoolbox is an important member of the ArcGIS family and is responsible for data import and export. In addition to ESRI format data (such as shapefile and covage files), arctoolbox also provides data conversion for common file formats such as e00 and DWG. During data conversion, you can set conversion parameters based on actual needs, such as the field name of the spatial data table and the maximum value of the spatial index coordinate. Arctoolbox provides us with a good data conversion tool. Similarly, if MAPGIS is 6.5 or later, you can use the attributes library management subsystem of MapGIS and the tools provided by the editing subsystem to upload spatial data of MAPGIS. Although ArcSDE is logically oriented to object storage, it physically uses a pure relational table of oracle. Therefore, the current versions of these two tools only support the relational mode, that is, the spatial cartridge mode.
3.2 how to upload Raster Data
Since Oracle 10 Gb, Oracle Spatial has added a module for storing raster data. It also provides Java APIs for uploading raster data, PL/SQL APIs, And the upload tool georasterloader. The following describes how to use georasterloader to upload raster data:
1) Create Table S (jpg mdsys. sdo_georaster );
2) Call sdo_geor_utl.createdmltrigger ('s S', 'jpg ');
3) Create Table rdt1 of MDSYS. sdo_raster (primary key (rasterid, pyramidlevel, bandblocknumber, rowblocknumber, columnblocknumber ));
4) insert into S values (MDSYS. sdo_geor.init ('rdt1 '));
5) Select JPG from S;
Return Value: sdo_georaster (null, null, 'rdt1', 22, null)
6) commit;
7) use the following command in the command line tool of the operating system to upload the Raster image "C:" test.jpg ",
Java georasterloader gis01 GIS 1521 Scott tiger thin 32 t JPEGs jpg "blocking = true, blocksize = (256,256, 1)" "C:" test.jpg, 22, rdt1 ";
8) after the upload is successful, you can also use georasterviewer to browse the Raster image and enter the following command in the command line tool of the operating system,
Java georasterloader gis01 GIS 1521 Scott tiger thin 32 t;
When uploading raster data, because the current oracle10.1.2 version uses the raster data model does not support Chinese characters, you must select English when installing Oracle 10 Gb, you cannot use Chinese by default.
4 Conclusion
(1) Use Oracle Spatial to store and manage spatial data, it is easy to solve problems in data sharing, distributed processing, network communication, open development, concurrency control, network integration, cross-platform operation, and data security recovery mechanisms, therefore, it has become an application trend. How to import the spatial data generated in the existing GIS software into the database becomes the primary key aspect of this technology application.
(2) to upload GIS Spatial Data to Oracle Spatial, the essence is to write the graphic data of spatial data (including vector data and grid data) and the corresponding attribute data into the database table. Fully understand the storage method of imported GIS data and the data type of Oracle Spatial and its object attributes and methods are the basis for the implementation of the upload program.
(3) You can use the tools provided by GIS or manually write programs to upload data. In the selection of specific methods: If the GIS software provides the corresponding upload tools, we recommend that you use these tools for upload, in this way, you can use the corresponding secondary development component to develop applications based on Oracle Spatial (for example, you have uploaded * using easyloader *. after the tab file, you can use the Oracle Spatial Data Source in MapX of MapInfo and mapxtreme for Java). If there is no corresponding upload tool, you can develop upload tools by using interfaces such as ADO, OCI, occi, oo4o, and Java APIs.
(4) in the implementation of the Java API, occi, and ADO interfaces described in this article, the command object of the ADO interface cannot pass the value when the commandtext attribute has more than 4000 characters. Therefore, a long space object will be truncated. Therefore, we recommend that you use the Java API and occi interface provided by Oracle to develop the upload program.
(5) The Oracle Spatial option of Oracle10g adds a module for storing raster data, and provides Java APIs, PL/SQL APIs, And the upload tool georasterloader for uploading raster data. You can use georasterloader to upload raster data. However, the Raster Data Model in oracle10.1.2 does not support Chinese characters, therefore, we recommend that you choose to use English instead of the default Chinese language.