Upload
dinhbao
View
219
Download
2
Embed Size (px)
Citation preview
DevSummit’06
Easy ArcObjects
Turbocharging Brian GoldinErik Hoel
Easy
DevSummit’06
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
DevSummit’06
IDEs
DevSummit’06
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…
DevSummit’06
JAVA IDE
• Lots of templates• Very slick help system• Code snippets• Lots of wizards
DevSummit’06
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
DevSummit’06
Geoprocessing
DevSummit’06
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
DevSummit’06
4 Ways to Leverage Geoprocessing
• Use Existing Tools• Build Models• Write Scripts• Create new tools
DevSummit’06
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….
DevSummit’06
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
DevSummit’06
Execute more than just tools
• Build workflow with model
DevSummit’06
Execute More than Tools cont.
• There’s Logic in using scripts
DevSummit’06
Create your own geoprocessing tools
• It’s easy to extend geoprocessing with your own tools– Script Tool– Model Tool– Custom Tool
DevSummit’06
How do you get started
• Read the desktop help for a conceptual understanding
• API Reference
DevSummit’06
Cursors
DevSummit’06
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
DevSummit’06
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
DevSummit’06
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
DevSummit’06
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
DevSummit’06
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
DevSummit’06
Component Burn
DevSummit’06
Component Burn
• Easy to consume the ArcObjects fine grained components in an unoptimizedmanner
• Many ways to do the same task• Unnecessarily cocreating small
components can whack performance• Use coarse grained components when
possible
DevSummit’06
Data Models
DevSummit’06
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
DevSummit’06
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
DevSummit’06
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
DevSummit’06
Prototyping
DevSummit’06
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
DevSummit’06
Extensibility and Customization
DevSummit’06
Levels of GDB Customization
Subtypes& defaults
Domains& validation
Connectivity& topo rules
Class & workspaceextensions
Built-in
Functionality
Custom
Applications
VBA
Programming
starts here
DevSummit’06
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
DevSummit’06
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
DevSummit’06
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
DevSummit’06
Class extension uses• Schema generation • Custom drawing• Custom property inspection and validation• Custom split policies• Related object creation notification• PlugIn Data Sources
DevSummit’06
Miscellaneous Stuff
DevSummit’06
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
DevSummit’06
Caching
• Spatial cache– Features– E.g., network editing
• Schema cache– GDB schema tables– E.g., creating a checkout version
programmatically
DevSummit’06
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
DevSummit’06
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
DevSummit’06
Questions?
DevSummit’06Best Villain?
Emilio Largo
Ernst Blofeld 1 Ernst Blofeld 2 Ernst Blofeld 3
Rosa Klebb Auric Goldfinger
DevSummit’06
Emilio Largo
Ernst Blofeld 1 Ernst Blofeld 2 Ernst Blofeld 3
Rosa Klebb
No, Mr. Bond. I expect you
to die.
Auric Goldfinger
Best Villain?
DevSummit’06
Emilio Largo
Ernst Blofeld 1 Ernst Blofeld 2 Ernst Blofeld 3
Best Villain
Rosa Klebb
Best Villain? Goldfinger
No, Mr. Bond. I expect you
to die.