Create a point and line layer with the elevation Z value in arcengine

Source: Internet
Author: User

The coordinate data of the pipeline and its accessories carry the Z value.

In some cases, the X and Y values of the two endpoints of a pipe segment are the same (vertical pipe segment)

Such a line may cause problems when a shape layer is directly generated, especially

When you use the c api of ArcSDE to directly create a table, you will find that such data cannot be generated.

 

The solution is to add a Z value to the layer. If a layer has an elevation value, you can view it In ArcMap.

The Attribute Table of the layer knows that elements with Z values will have a ZM character after the type in the shape field.

For example, point ZM and polyline ZM

. "Alt = metashape field with elevation values display state src =" http://hi.csdn.net/attachment/201007/21/4846_12796944235aA5.png "width = 393 Height = 223 real_src =" http://hi.csdn.net/attachment/201007/21/4846_12796944235aA5.png ">

It is useless to set only the point Z attribute when creating a layer with the elevation Z value. By default

Arcengine ignores the Z value,

Take two steps to solve the problem:

Step 1: Create a shape layer and use ifeatureworkspace. createfeatureclass

The second parameter of this function is ifields, which defines the field and the type of the Shape field in the field definition.

Use igeometrydefedit. hasz_2 = true to specify the Z value,

View plaincopy to clipboardprint?
  1. IgeometrydefPgeometrydef=NewGeometrydef ();//Create Geometric definitions for fields of the esrifieldtypegeometry type, including type and space references. 
  2.                     IgeometrydefeditPgeometrydefedit=PgeometrydefAsIgeometrydefedit; 
  3.                     Pgeometrydefedit. geometrytype_2=Geometrytype; 
  4.                     Pgeometrydefedit. hasz_2=True; // The layer has an elevation value. 
  5.                     Pgeometrydefedit. spatialreference_2=Axmapcontrol. spatialreference;                     
  6.                     Pfieldedit. geometrydef_2=Pgeometrydef; 

Igeometrydef pgeometrydef = new geometrydef (); // create a geometric definition for the struct type field, including the type and space reference <br/> igeometrydefedit pgeometrydefedit = pgeometrydef as igeometrydefedit; <br/> pgeometrydefedit. geometrytype_2 = geometrytype; <br/> pgeometrydefedit. hasz_2 = true; // The layer has an elevation value <br/> pgeometrydefedit. spatialreference_2 = axmapcontrol. spatialreference; <br/> pfieldedit. geometrydef_2 = pgeometrydef; <br/>

 

Step 2: add an element. You must use the izaware interface to specify its zaware as true.

View plaincopy to clipboardprint?
  1. IpointPfrompoint=NewPointclass (); 
  2. Pfrompoint. putcoords (fromx,Fromy );                                                            
  3.                                 Pfrompoint. Z=Formz; 
  4.                                 IzawareFromzaware=PfrompointAsIzaware; 
  5.                                 Fromzaware. zaware=True; 
  6.                                 // IzIfromz=(IZ) pfrompoint; 
  7.                                 IpointPtopoint=NewPointclass (); 
  8.                                 Ptopoint. putcoords (Tox,Toy );                                 
  9.                                 Ptopoint. Z=Toz; 
  10.                                 IzawareTozaware=PtopointAsIzaware; 
  11.                                 Tozaware. zaware=True; 
  12.                                 // IzItoz=(IZ) ptopoint; 
  13.                                   
  14.                                   
  15.                                 IpolylinePpolyline=NewPolylineclass (); 
  16.                                 IzawareIpolylineaware=(Izaware) ppolyline; 
  17.                                 Ipolylineaware. zaware=True; 
  18.                                 Ppolyline. frompoint=Pfrompoint; 
  19.                                 Ppolyline. topoint=Ptopoint; 

Ipoint pfrompoint = new pointclass (); <br/> pfrompoint. putcoords (fromx, fromy); <br/> pfrompoint. z = formz; <br/> izaware fromzaware = pfrompoint as izaware; <br/> fromzaware. zaware = true; <br/> // iz ifromz = (IZ) pfrompoint; <br/> ipoint ptopoint = new pointclass (); <br/> ptopoint. putcoords (Tox, toy); <br/> ptopoint. z = toz; <br/> izaware tozaware = ptopoint as izaware; <br/> tozaware. zaware = true; <br/> // iz itoz = (IZ) ptopoint; </P> <p> ipolympus ppolyline = new polylineclass (); <br/> izaware ipolympus lineaware = (izaware) ppolyline; <br/> ipolympus lineaware. zaware = true; <br/> ppolyline. frompoint = pfrompoint; <br/> ppolyline. topoint = ptopoint; <br/>

 

By the way, this problem occurs in the ArcSDE c api,

At first, I thought it was relatively simple. Using se_layerinfo_set_3d can solve the problem,

However, there are several records that cannot be imported. You can use field calculator to view the Z value of one dollar,

The elevation is changed to an integer. I can confirm that the input data is of the double type,

After se_shape_generate_point and se_shape_generate_line, the generated data is that the elevation is an integer.

According to the Code on the internet, se_coordref_set_precision is used to set coordinates to high precision,

I set both layerinfo and insert shape, but it has no effect ..

 

20100723 update:

The above elevation precision loss problem is solved,

We thought it was very simple to directly generate a shape and then import it to ArcSDE using arccatalog,

When used, it was found that there were several layers that could not be imported,

Error message:ORA-01426:Numeric Overflow,

So I still have to write the code for direct import. Today I have been tossing for nearly a day. The idea is to use C ++ to directly call the C API of SDE and try to see if the value is passed in,

In the afternoon, when I had a hard time, I suddenly found this function se_coordref_set_z_by_range.

Use the maximum and minimum values of the elevation to add 0.001 and then input this function. The effect is immediate,

Sorry, I haven't eaten lunch for this problem.

 

From: http://blog.sina.com.cn/s/blog_78b94aa30100ugd3.html

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.