18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING A COMMAND-LINE JAVA APPLICATION<br />

IFeatureClass outFC = new IFeatureClassProxy(<br />

featureWksp.createFeatureClass( shapeFile, fields, null, null,<br />

esriFeatureType.esriFTSimple, "Shape", "”));<br />

// Get tin node enum.<br />

IEnumTinNode enum = tin.makeNodeEnumerator(tin.getExtent(),<br />

esriTinQualification.esriTinInsideDataArea,<br />

null);<br />

// Store node to shapefile.<br />

IFeatureCursor outCursor = outFC.IFeatureClass_insert(true);<br />

IFeatureBuffer outBuffer = outFC.createFeatureBuffer();<br />

IPoint point = new Point();<br />

ITinNode node = enum.IEnumTinNode_next();<br />

while(node != null){<br />

node.queryAsPoint(point);<br />

outBuffer.setShapeByRef(point);<br />

outCursor.insertFeature(outBuffer);<br />

node = enum.IEnumTinNode_next();<br />

}<br />

outCursor.flush();<br />

tinAdv.setEmpty();<br />

System.out.println(" - Path to Generated Shapefile: " +<br />

shapePath +<br />

File.separator +<br />

shapeFile);<br />

}catch (Exception ex) {<br />

ex.printStackTrace();<br />

}<br />

}<br />

Creating the basic fields for the 3D shapefile<br />

Now that the method that performs the conversion from TIN to shapefile has<br />

been created, the next step is to define the schema structure for the output 3D<br />

shapefile. The tinToPoint() method defined above uses the createBasicFields method<br />

you create here to generate a fields object and sends it as a parameter to the<br />

createFeatureClass() method.<br />

1. Create the signature for this method as follows:<br />

/**<br />

* @param shapeType - a geometry object type<br />

* @param hasM - m-value precision defined<br />

* @param hasZ - z-value precision defined<br />

* @param spatialRef - Spatial Reference<br />

*<br />

* @return IFields - a collection of columns in a table<br />

*/<br />

private static IFields createBasicFields(int shapeType, boolean hasM,<br />

boolean hasZ, ISpatialReference spatialRef){<br />

2. Use a GeometryDef object to define spatial qualities of your feature class. The<br />

most fundamental spatial quality that the method will take as a parameter is<br />

420 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!