ArcSDE SDK Java quick practices 4

Source: Internet
Author: User
· 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.