18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING A COMMAND-LINE JAVA APPLICATION<br />

import com.esri.arcgis.geodatabase.IFeatureCursor;<br />

import com.esri.arcgis.geodatabase.IFeatureWorkspace;<br />

import com.esri.arcgis.geodatabase.IFeatureWorkspaceProxy;<br />

import com.esri.arcgis.geodatabase.IFieldEdit;<br />

import com.esri.arcgis.geodatabase.IFields;<br />

import com.esri.arcgis.geodatabase.IFieldsEdit;<br />

import com.esri.arcgis.geodatabase.ITinAdvanced;<br />

import com.esri.arcgis.geodatabase.ITinNode;<br />

import com.esri.arcgis.geodatabase.IWorkspaceFactory;<br />

import com.esri.arcgis.geodatabase.Tin;<br />

import com.esri.arcgis.geodatabase.esriFeatureType;<br />

import com.esri.arcgis.geodatabase.esriFieldType;<br />

import com.esri.arcgis.geodatabase.esriTinQualification;<br />

import com.esri.arcgis.geometry.IPoint;<br />

import com.esri.arcgis.geometry.ISpatialReference;<br />

import com.esri.arcgis.geometry.Point;<br />

import com.esri.arcgis.geometry.esriGeometryType;<br />

import com.esri.arcgis.system.AoInitialize;<br />

import com.esri.arcgis.system.<strong>Engine</strong>Initializer;<br />

import com.esri.arcgis.system.esriLicenseExtensionCode;<br />

import com.esri.arcgis.system.esriLicenseProductCode;<br />

Now that the imports have all been made, you can add methods to your class.<br />

Adding the tinToPoint method<br />

This method performs most of the work for the application. It will take, as<br />

parameters, a path to your TIN file, the name of the TIN, a path to an output<br />

shapefile, and a name for the output shapefile.<br />

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

The ITinAdvanced interface requires an <strong>ArcGIS</strong><br />

<strong>Engine</strong> Runtime license with 3D extension or an<br />

<strong>ArcGIS</strong> 3D Analyst extension when deployed. You<br />

will add code for detecting for this license and<br />

checking it out later in this exercise.<br />

/**<br />

* @param tinPath – path to input tin data source<br />

* @param tinName – name of input tin data source<br />

* @param shapePath – path to output shapefile data source<br />

* @param shapeFile – name of output shapefile data source<br />

*/<br />

private static void tinToPoint(String tinPath, String tinName,<br />

String shapePath, String shapeFile){<br />

Initially, you need to open your TIN dataset from its file location, which is passed<br />

as a parameter to the method, by instantiating a new Tin class. The Tin class<br />

implements many interfaces; you will use methods provided by the ITinAdvanced<br />

and IGeoDataset interfaces. By calling the init() method, exposed by the<br />

ITinAdvanced interface, you can open the specified TIN.<br />

2. Instantiate the new Tin class by adding the following code below the signature<br />

for your method.<br />

try{<br />

// Get tin from tin file.<br />

ITinAdvanced tinAdv = new Tin();<br />

String path = tinPath + File.separator + tinName;<br />

System.out.println(" - Path to Tin: " + path);<br />

tinAdv.init(path);<br />

Chapter 6 • <strong>Developer</strong> scenarios • 417

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

Saved successfully!

Ooh no, something went wrong!