1. Environment Preparation 1.1 software preparation
To first install Oracle with support for spatial data, followed by an installation or a free-install version of GeoServer, when both are deployed, we will begin to discuss further environments that need to be configured.
Here I use the SHP2SDO provided by Oracle for SHP import, while using the plug-in provided by GeoServer to connect to the Oracle data source for data publishing.
The SHP2SDO is: http://down.51cto.com/data/223757.
The Oracle plug-in for GeoServer is: Http://sourceforge.net/projects/geoserver/files/GeoServer. Choose the plugin version that corresponds to your geoserver version to download, such as my: Geoserver-2.2-oracle-plugin.zip.
1.2 Running Environment Preparation 1.2.1 Database environment configuration
Copy the Shp2sdo.exe to the directory (bin) referred to by the Oracle environment variable. For example, my is in:
1.2.2 GeoServer Environment Configuration
After extracting geoserver-2.2-oracle-plugin.zip, you can get the following files:
A. In the case of the installation version, put the Gt-jdbc-oracle.jar into: [Geoserver_home]/server/geoserver/web-inf/lib; if it is a free installation version, put the Gt-jdbc-oracle.jar into: in a War install this is [container]/webapps/geoserver/web-inf/lib
B. If it is the installation version, put Ojdbc.jar into: [Geoserver_home]/lib; my own is put in: F:\tomcat4Geoserver\lib. If the file is placed in a wrong path, Oracle will not be able to connect.
2. Import shp into Oracle2.1 concrete steps 2.1.1 Command line point to SHP file to import
2.1.2 using SHP2SDO to convert SHP to an import file 184.108.40.206 command line
First, give the input command line: shp2sdo commhjt commhjttest–i id–s 4326–g geometry–d
220.127.116.11 Specific Analysis
-I id_colum specifies the ID sequence column, which by default is the ID, which is the uniqueness flag for generating data;
-s Specifies that the Srid is generated (that is, what coordinates are used), that the default is null (although default is null, the import value is 0, so be aware that the srid of this record of the inserted metadata table is updated to null, otherwise the 0 value is not recorded in the Mdsys.cs_srs table and will be faulted later); Here my shp is WGS84 coordinates, so write directly to 4326.
-G geometry column specifies Sdo_geometry, default is Geom;
-d means that the decomposed CTL file (control file) and data file (datastore file) are merged into a single file, and the data is stored and controlled in a CTL file. If this option is not available, a separate data file is generated, the CTL file (control file) and the data file (datastore file);
The above command line generates the following files in the SHP folder:
Open Commhjttest.sql to see that it is a SQL that creates a SHP table that is related to spatial metadata:
Opening Commhjttest.ctl, you can see that the insertion of the data is in it:
2.1.3 Create the corresponding SHP table and register to User_sdo_geom_metadata (using Commhjttest.sql)
First log in to the database: Sqlplus dlgis/[email protected]
Sql>@g:\shptest\commhjttest.sql--Create a table and register to User_sdo_geom_metadata
Sql>quit--Exit the database
2.1.4 importing data into the created table by Sqlldr (with Commhjttest.ctl)
Sqlldr Dlgis/[email protected] commhjttest--Import data (SQLLDR, SQL Loader tool)
2.1.5 upgrading data to a version that is compatible with Oracle
First connect to the database again, and then enter:
Sql> Execute sdo_migrate.to_current (' commhjttest ');
2.1.6 to increase query speed, add spatial index
Sql>create INDEX index_oper_data_spatial on Commhjttest (GEOMETRY) Indextype is Mdsys. Spatial_index PARAMETERS (' Layer_gtype=polygon ') noparallel;
If this behavior occurs, the index name may have been used before, for a name, such as the index name replaced by: Index_oper_data_spatial_comm
2.1.7 Viewing Import Results
When we use SHP2SDO to generate the import data for SHP, if the written statement is:
When the spatial reference is null by default, an error is generated when the index is last built, with the following errors:
The reason is that the srid in the metadata table User_sdo_geom_metadata at this time is 0 instead of NULL. When we turn this srid to NULL, the index is then built successfully.
3. Publishing data from Oracle via GeoServer
3.1 Building a store based on an Oracle data source
Go to GeoServer's Web page, click Stores, select Oracle NG:
3.2 Release Data
Select the data you want to publish, click Publish, and make the relevant configuration:
3.3 Browsing the published layer service
Although the SHP2SDO tools provided by Oracle can be used to import SHP data, it is still relatively complex for my operation, and it is difficult to train engineering staff. If you want to popularize widely, you should write a relevant import tool.
Thank Bo Friends of their hearts Sey remind, let me know there are shp2sdo such tools can be used, thanks again.
--Welcome reprint, but retain the copyright, please indicate the source in obvious place: http://www.cnblogs.com/naaoveGIS/
A brief analysis of importing SHP into Oracle and using GeoServer to publish the imported data