Easy ArcObjects Turbocharging Brian Goldin Erik Hoel
Purpose of this talk How to get things done quick while your boss thinks it s hard agonizing work Save time Be efficient Write less code Separate the model builders from the coders
IDEs
Visual Studio IDE Visual Studio IDE integration makes life easy Implements that boiler plate code for you Licensing Implement common interfaces Base classes Adding references over and over again Preconfigured templates All applications start in the same place use this as your foundation Prototype code not typing boiler plate code If you like to hack things the framework is very extensible check it out
JAVA IDE Lots of templates Very slick help system Code snippets Lots of wizards
Configure your app with ArcMap Author maps its fun and easy Use layer files Create a FeatureLayer or use a layer file Some layers can be excessively complicated Work with symbols Roll your own use one that you ve configured
Geoprocessing
Geoprocessing Geoprocessing has many benefits Lots of functionality is encapsulated into a single tool Tool implementation is robust and efficient Great opportunity to delete code and simplify implementation
4 Ways to Leverage Geoprocessing Use Existing Tools Build Models Write Scripts Create new tools
Execute, Execute, Execute Tools are grouped into logical collections Analysis - extract, overlay, proximity etc. Data Management - create and manage data Conversion - load data Network Analysis Spatial Analysis Cartography And the list goes on.
Geoprocessing Example Buffer Fine grain ArcObjects call to Buffer Features Huge learning curve Painful Error Prone Appropriate when you need to fine control but not unnecessary Using Geoprocessing to Buffer Features Simpler Easier to debug and understand Bullet proof code
Execute more than just tools Build workflow with model
Execute More than Tools cont. There s Logic in using scripts
Create your own geoprocessing tools It s easy to extend geoprocessing with your own tools Script Tool Model Tool Custom Tool
How do you get started Read the desktop help for a conceptual understanding API Reference
Cursors
Cursors Used when searching a table Cursor is returned as result of applying a QueryFilter to a Table Client then iterates through the returned rows in the cursor Cursors come in different flavors Search, update, and insert Update cursors take an argument Recycling or non-recycling
Cursors Search cursors return rows as specified by the QueryFilter Update cursors used to update or delete rows specified in the QueryFilter Insert cursors used to insert new rows into a table Good for bulk loading simple data Slower for non-simple data Consider object loader
Recycling vs. Non-recycling Recycling Allocate a single row object (re-load on each fetch) Should only be used for reading data Performance advantages Recycling Update Cursor can be faster then calling Store() on rows from a Search Cursor Non-Recycling Different row object on each fetch Always has full set of fields
Cursors vs. get_feature In ArcObjects, there are often several ways to accomplish the same task some are much faster than others Retrieving features given a set of ObjectIDs Significant performance differences
QueryDefs vs. OpenTable IFW::OpenTable() Acquires schema lock on data source costly serialized process; many SQL statements Serialization kills scalability, can create queues with many (e.g., 100s) users QueryDefs No schema locks Fast creation of rowset Pabst vs. Heineken
Component Burn
Component Burn Easy to consume the ArcObjects fine grained components in an unoptimized manner Many ways to do the same task Unnecessarily cocreating small components can whack performance Use coarse grained components when possible
Data Models
Data Models Data model structure is critical Minimize the number of feature classes Cursors are expensive Utilize subtypes Subtypes not for you? Consider fat classes handle unpopulated attributes Avoid classes containing small number of large features Nation or state polygon
Data Models Model only those relationships that are important Event notification can have impact relationship classes feature linked annotation workspace and class extensions editor events
Data Models Dense features (high vertex count) impact E.g., 8 million vertex polygons Display pipeline, geoprocessing, updating, etc. Extremely large features (extent) impact Nation or state polygon Topology, networks
Prototyping
Prototyping Largest mistake made with the geodatabase Structure is critical data quantity is not Prototype as soon as a first pass model is available general structure; small details unimportant load a modest amount of data (on versioned SDE) empty classes are OK Try editing, observe system performance Repeat this process as necessary
Extensibility and Customization
Levels of GDB Customization Custom Applications Subtypes & defaults Built-in Functionality Domains & validation Connectivity & topo rules VBA Class & workspace extensions Programming starts here
Levels of GDB Customization Application level Pros Business Logic is stored within application Can access data without customization Cons Only available when application is running Users do not always interact with application customization
Levels of GDB Customization Database level Pros Business Logic is stored with data Always available, regardless of application Cons One class extension per feature class All users require dll to even view data Database is unusable if code fails Impacts on performance
GDB Extensibility Five mechanisms Workspace extensions Filtering, edit events, version events Class extensions Drawing, split policies, property inspector, related object creation notification Plug-in data sources OLE DB providers Custom features
Class extension uses Schema generation Custom drawing Custom property inspection and validation Custom split policies Related object creation notification PlugIn Data Sources
Miscellaneous Stuff
Workflows Workflow is critical with versioning Recommended workflow: Load data Define the dataset (e.g., topology, GN) Build or process the entire dataset (e.g., validate entire topology, build the GN) Register the dataset as versioned
Caching Spatial cache Features E.g., network editing Schema cache GDB schema tables E.g., creating a checkout version programmatically
GP Tools Consider periodic GP tools for QA/QC Not everything has to be in the data model or in code Avoidance of large polygons (e.g., nation or state Run Integrate to ensure data planarity and cluster your vertices Not necessary to create a topology
Is your PC worth > $10 on ebay? Would people buy it only to create a novelty fishtank? Run on a decent PC e.g., spend $500 at Walmart
Questions?
Emilio Largo Rosa Klebb Auric Goldfinger Ernst Blofeld 1 Ernst Blofeld 2 Ernst Blofeld 3 Best Villain?
No, Mr. Bond. I expect you to die. Emilio Largo Rosa Klebb Auric Goldfinger Ernst Blofeld 1 Ernst Blofeld 2 Ernst Blofeld 3 Best Villain?
No, Mr. Bond. I expect you to die. Emilio Largo Rosa Klebb Best Villain Ernst Blofeld 1 Ernst Blofeld 2 Ernst Blofeld 3 Best Villain? Goldfinger