Developing With Arc Objects APIs
Developing With Arc Objects APIs
--Based on ArcGIS 10
周岳昆
Esri中国(北京)培训中心
[email protected]
Extending
ArcObjects
Standalone
Application
Determine Which Application You Need
Don’t Forget Add-In
ArcObjects
Services ArcGIS Server
ArcGIS Online
OGC SOAP
KML REST
Desktop
ArcSDE
Data
(Geodatabase) File
Personal File Desktop Workgroup Enterprise
Esri中国(北京)培训中心
ArcObjects Core Library
esriCarto: Layer, Map, FeatureSelection, Annotation, Element
esriDisplay: Symbol, Color, Display, ScreenDisplay
esriGeoDatabase: Workspace,FeatureClass, Dataset, Feature,
Row, Field, Cursor, FeatureCursor
esriGeometry: Point, Polyline, Polygon, SpatialReference
esriOutput: Export, IPrinter
esriSystem: Array, Set
esriControls: MapControl, ToolbarControl, TOCControl,
LicenseControl e.g. ( only Supported by Engine )
esriSystemUI: ITool, ICommand ( Unique UI library in Engine)
ADF.BaseClasses: BaseTool, BaseCommand
More Libraries
esriDataSourceFile
esriDataSourceGDB
esriDataSourceRaster
esriGeoProcessing
What Is New In ArcGIS 10
A single SDK for ArcObjects, which combined Engine,
Desktop and Server.
Customize ArcGIS Desktop using more Add-Ins other
than VBA.
Map automation using python
Some libraries have enhanced
esriCarto add MosaicLayer class to show mosaic dataset.
esriDataSourceRaster add MosaicRasterDataset class
esriGeoDatabase add IQueryDef2 interface to support postfix
clause such as Order by or Group by.
esriDisplay add IStyleGalleryItem2 interface to access symbol
or element by Tag property
When Need Help
Developer Help Local
Documentation and Samples
Object Model Diagrams
Esri Developer Network, Go to: edn.esri.com,
resource.esri.com, surpport.esri.com
Documentation Library
Technical Articles and White Papers
Data Model
Samples and Solutions
Forums
www.gisall.com (Esri)
Also Need Some COM
Polymorphism
Query Interface (QI)
What do you think what Query Interface is ?
QI Once More, It’s more Important
One Dramatic Example is Enough
ICooker p2=p1; // QI
p2.cook( );
Think Why ?
Wrapper In .Net SDK
}
Add-In: More Convenient Customizing
DataSet
*
Map
* esriCarto
Layer esriGeoDatabase
Table
5-21
Review Controls in Engine SDK
Create a MapControlApplication
Automation to develop
Add map document to MapControl
Add items to ToolbarControl
Remember: SetBuddyControl
AxMapControl and
IMapControl
IMap.get_Layer(item)
IEnumLayer::Next returns ILayer
Table
AccessWorkspaceFactory
FeatureClass
FileGDBWorkspaceFactory
esriGeodatabase
Others SDEWorkspaceFactory
6-27
Accessing Workspace
IWorkspaceFactory to return Workspace object
OpenFromFile: Accesses an existing folder on disk
Open: Connects to existing database (e.g., ArcSDE)
Accessing Feature Workspace
QI to Feature Workspace
CreateFeatureClass: create new feature class
CreateTable: create new table
IFeatureWorkspace fws=workspace; // QI
IFeatureClass fclass=fws.openFeatureClass(“Lake”);
Add New FeatureLayer to Map
Row Table
esriGeoDatabase
esriGeoDatabase FeatureClass * FeatureDataset
Why Name Object
Name objects are placeholders for real objects
Use IName ::Open to instantiate object represented
Name is a lightweight object. When workspace
attributes( category ,type) only wanted, no need to load the
whole workspace object into stack.
Name is like signature. Sometime when see that
signature, it’s enough to fulfill the task. And sometime we
may see the leader by myself, that is Open Method.
Sample: Create New Workspace
Field object
Both IField and IFieldEdit are Filed
Get field properties with IField
Set field properties with IFieldEdit
Fields object
Use IFieldsEdit :AddField add field
IFeature feature=fclass.CreateFeature( );
feature.value(fclass.FindField(“name”))=“china”;
feature.store( );
Row Table
Feature FeatureClass
10-38
Cursor and FeatureCursor
8-39
Editing with a Cursor
Faster than using CreateRow or CreateFeature
Much more efficient for large operations
ICursor :: DeleteRow
ICursor :: UpdateRow
Feature classes
IFeatureCursor :: InsertFeature
IFeatureCursor :: DeleteFeature
IFeatureCursor :: UpdateFeature
10-40
Editing Cursors
Update cursor
// filter is a QueryFilter
// false the same as IFeatureLayer.Search Method
IFeatureCursor fCursor=fclass.Update(filter,false);
Insert cursor
// false means non-use Row Buffer, Insert one by one
// true means use Row Buffer, Insert after cursor completed
IFeatureCursor fCursor=fclass.Insert(true);
10-41
Sample: Update and Insert Cursor
IQueryFilter filter=new QueryFilter( );
Filter.WhereClause=“ StateName=‘Japan’ ”;
IFeatureCursor fCursor=fclass.Update(filter,false);
IFeature feature=fCursor.NextFeature( );
While (feature!=null)
{
feature.Value(fcalss.FindField(“StateName” ))=“China”;
fCursor.UpdateFeature(feature);
feature=fCursor.NextFeature( );
}
10-42
Exercise 02: Create New FeatureClass
esriGeometry
esriGeometry
Polycurve
9-45
Point, Multipoint and PointCollection
Points are zero dimensional
Define coordinates with X and Y properties
Point.Y=450;
IPointCollection points=new MultiPoint();
Multipoint
Multipoint with
with
Points.AddPoint ( point ); six
six points
points
9-46
Segments
Consist of two points and type line between them
Types of: Line, BezierCurve, CircularArc, EllipticalArc
pFromPoint pToPoint
pToPoint
pFromPoint pToPoint
pToPoint pFromPoint
pFromPoint
9-47
Polyline and Polygon
Polyline
Collections of connected or unconnected paths
Polygon
Composed of one or several rings
One
One polyline
polyline with
with many
many segments
segments
One
One polygon
polygon with
with many
many rings
rings
9-48
Area Property
Many geometries have Area property
Polygon, Envelope, Ring
9-49
Length Property
Geometry except point, multiPoints and envelope
all have Length property
ICurve :: Length
9-50
Envelope
Define a feature’s spatial extent
Minimum bounding rectangle
All geometry has an envelope
Get or set with IGeometry :: Envelope
9-51
Spatial Reference
Allgeometry has a spatial reference
Create new coordinate systems
ISpatialReferenceFactory contains methods for creation
SpatialReferenceEnvironment implement create method
ISpatialReference
SpatialReference
VerticalCoordinateSystem
9-52
Spatial Analysis
Remember operator below are all Geometry
ITopologicalOperator
IProximityOperator
IRelationalOperator
Use to:
Topological perform familiar spatial operations such
as buffer, cut, intersect, simplify, union and clip
Proximity measure distances between shapes and
return the nearest point.
Relational examine spatial relationships such as within
touches, contains, overlaps and crosses.
9-53
ITopologicalOperator
Provides methods for working with geometry
Construct new geometry based on others
Perform buffers, intersects, and clips on features
bufferPoly
bufferPoly topo
topo
9-54
IRelationalOperator
Methods for examining spatial relationships
Equals - Are input geometries structurally equivalent?
Touches - Do input geometry boundaries intersect?
polygon
polygon another_Polygon
another_Polygon
relation
relation
line
line another_Line
? another_Line
proximity
proximity
QueryFilter
SpatialFilter
FeatureCursor
Feature
FeatureClass
== ‘in
‘in conjunction
conjunction with’
with’
8-60
Cursor and FeatureCursor Again
Search cursor
Search method
Use for read-only analysis of a record subset
Update cursor
Update method
Use to update or delete records
Insert cursor
Insert method
Use to insert new records into the database
Using Selection
QueryFilter
QueryFilter
FeatureClass
Search FeatureCursor
MarkerSymbol
MarkerSymbol LineSymbol
LineSymbol FillSymbol
FillSymbol
RgbColor
CmykColor
RgbColor HlsColor
GrayColor
HlsColor
GrayColor
Properties for defining color
Red, Green, Blue values (0–255)
gc.AddElement ( element , 0 );
axMapControl1.ActiveView.Refresh( );
FeatureRenderers
Renderers define how a layer is displayed
Six types of Feature Renderer
SimpleRenderer: Simple Render
UniqueValueRenderer: Based on Unique Value
ClassBreaksRenderer: Divide into Classes to Render
ChartRender: Chart Render
DotDensityRenderer: Dot Density Render
ScaleDependentRenderer: Based on Scales Dependent
ScaleDependentRenderer
Render based on Scale Dependent
More detail at large scales, less detail at small scales
1:7,000,000
1:75,000,000
Properties
Break: cut-off points (scale ranges)
IFeatureDatasetExtensionContainer
Access Extension Dataset Container
fws.OpenFeatureDataset (featureDatasetName)
NetworkDataset Object
By IDatasetContainer.get_DatasetbyName method
NAContext Object
NAContext is the key Object in analysis.
Obtain references of NetworkDataset, NASolver,
NAClasses, NALocator
Create by INASolver.CreateContext method
INAContextEdit interface
Access editable properties of NAContext
Bind method prepares the context for analysis based
on Network Dataset Schema.
INASolver Interface
INASolver interface is common for all solvers.
NAClosestFacilitySolver
NARouteSolver
NAServiceAreaSolver
About Future
About Developer Career
ArcGIS Server
Dynamic Tracing
Developer Topics
GIS Future