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 />

BUILD SUCCESSFUL<br />

Total time: 1 second<br />

Now that your build environment is prepared, you can proceed with writing the<br />

Java source code for the example application.<br />

Use your favorite text editor or IDE to write<br />

your source code.<br />

Creating the TintoPoint main class<br />

1. Begin your source code by adding the signature for the main class in this exercise:<br />

package engine.scenario.analyst3d;<br />

The datasourcesfile, geodatabase, geometry, and<br />

system Java packages are the equivalent of the<br />

DataSourcesFile, GeoDatabase, Geometry, and<br />

System libraries of <strong>ArcGIS</strong> <strong>Engine</strong>.<br />

public class TintoPoint{}<br />

The class will eventually have three private static methods and one public main<br />

entry point. For the sake of simplicity, private static methods are used to do the<br />

work for the application. While some Java developers believe that when a<br />

method can be either static or an instance, an instance method should be utilized,<br />

this scenario uses the simplest approach—static methods. Each of these methods<br />

will be covered in upcoming sections.<br />

Next, look at what imports are required by the class.<br />

As discussed earlier, this scenario uses the datasourcesfile, geodatabase, geometry,<br />

and system Java packages.<br />

• datasourcesfile—provides workspace factories and workspaces for vector data<br />

formats supported by the geodatabase API. You will use the<br />

ShapefileWorkspaceFactory class in this exercise to create your generated 3D<br />

shapefile.<br />

• geodatabase—provides all definitions relating to data access including TINs<br />

and feature classes. You will be using the GeometryDef class to define spatial<br />

qualities for your generated feature class.<br />

• geometry—contains the core geometry objects, as well as spatial reference<br />

information. In this scenario, you will use the Point class as a representation of<br />

all the TIN nodes in your input TIN dataset.<br />

• system—contains objects that expose services used by the other libraries<br />

within <strong>ArcGIS</strong> <strong>Engine</strong>. You will use the AoInitializer object to initialize and<br />

uninitialize your application.<br />

2. Below the package declaration you made above, import the classes as shown.<br />

Use fully qualified imports so you can see explicitly which classes from the<br />

<strong>ArcGIS</strong> <strong>Engine</strong>—Java API you are working with.<br />

import java.io.File;<br />

import java.io.IOException;<br />

import com.esri.arcgis.datasourcesfile.ShapefileWorkspaceFactory;<br />

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

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

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

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

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

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

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

416 • <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!