· Selayer
1. Create a Layer
To create a layer, you must first create a common table, and then add a geometric field to the common table using a series of selayer methods, and then register it as a layer. However, this method should not be used in most cases, because the registered layer does not have Geodatabase information, so it cannot be accessed directly through other products of ArcGIS.
The following creates an ArcSDE Layer Based on the create_test table created above:
Seconnection conn = getconn ();
If (Conn! = NULL ){
Try {
Selayer layer = new selayer (conn );
Layer. settablename ("create_test ");
Layer. setspatialcolumnname ("shape ");
Layer. setshapetypes (selayer. type_point );
Layer. setstoragetypes (selayer. se_storage_spatial_type );
Layer. setgridsizes (selayer. se_spatialindex_dbtune,
Selayer. se_spatialindex_dbtune,
Selayer. se_spatialindex_dbtune );
Layer. Create (10,100 );
} Catch (seexception e ){
E. printstacktrace ();
} Finally {
Try {
Conn. Close ();
} Catch (seexception e ){
E. printstacktrace ();
}
}
}
2. Obtain layers and information
Generally, most applications access an existing ArcSDE layer. It is easy to connect to and obtain layer objects:
Selayer layer = new selayer (Conn, "sde_cities", "shape ");
After obtaining the layer, you can obtain some layer-related information:
Seconnection conn = getconn ();
If (Conn! = NULL ){
Try {
Selayer layer = new selayer (Conn, "sdo_cities", "shape ");
Secoordinatereference coordref = Layer. getcoordref (); // obtain the Layer Space reference.
Seextent fullextent = Layer. getextent (); // obtain the layer range.
Sesqlconstruct sqlc = new sesqlconstruct ();
Sqlc. setwhere ("objectid <30 ");
Seextent extent = Layer. calculateextent (false, sqlc); // obtain the layer (partial) Range
Boolean hasspatialindex = Layer. hasspatialindex (); // determines whether a spatial index exists.
Boolean isstoragesdo = Layer. isstoragespatial (); // whether sdo_geometry is stored
} Catch (seexception e ){
E. printstacktrace ();
} Finally {
Try {
Conn. Close ();
} Catch (seexception e ){
E. printstacktrace ();
}
}
}
3. Change Layers
After obtaining the layer, you can also perform some changes. For example, you can use the following code to change the grid size of the spatial index:
Seconnection conn = getconn ();
If (Conn! = NULL ){
Try {
Selayer layer = new selayer (Conn, "sde_cities", "shape ");
Layer. setgridsizes (5, 0, 0 );
Layer. Alter ();
Layer. getinfo (); // refresh layer information
Selayerspatialindexstats spatialindexstats = Layer. getspatialindexstats ();
Selayergridstats [] gridstats = spatialindexstats. getgrids ();
For (INT I = 0, numgrids = gridstats. length; I
Selayergridstats gridstat = gridstats [I];
Int maxp-4 = gridstat. getmaxv6 ();
System. Out. println (maxp-4 );
}
} Catch (seexception e ){
E. printstacktrace ();
} Finally {
Try {
Conn. Close ();
} Catch (seexception e ){
E. printstacktrace ();
}
}
}
As shown above, after changing the layer, you can view the grid statistics of the updated layer.