Code Generation + Geodatabase = Goodness
Posted by Dave Bouwman | Posted in .NET, ArcGIS Devt, Software | Posted on 01-09-2006
2
Back in July I posted about an idea we had to generate a set of Geo-Objects from a Geodatabase. The idea was to effectively “hide” the ArcObjects details and allow us to work with the classes in our Geodatabase as though they were… well… classes. Real classes. We wanted to use code generation so we could skip a lot of tedious coding, and be more tolerant of changes in the model.
Anyhow, I’ve now got this working. It’s pretty slick so I thought I’d write up a quick post about it. I’ll be giving a talk about this at the September ArcDeveloper meeting in Fort Collins, and I’ll post the power point here and at ArcDeveloper.net
This is basically a set of screen caps that run through the process.
Step 1: Export geodatabase schema to Xml, using Xslt to simplify it. This is done via an ArcCatalog tool…
Generated files in Explorer…


What is this CodeSmith of which you speak. I assume that is what does the mapping from XML to .NET objects that know how to talk to ArcObjects. There is some magic happening in the middle that I am not clear on.
Either way though, this looks frickin shweet. Works for C# right?
Steve,
Not exactly - CodeSmith is a templating engine. Basically we (Jeff Germain) sat down and manually wrote out the code/model etc that we wanted to create. We then refactored out the common stuff into a an "ArcDAL" class library, and then created templates for the rest. CodeSmith reads the Xml file from the geodatabase, and uses the metadata to drive the templates that I created. Nothing as seamless as Hibernate - all the ugly ArcObjects code actually gets written, but it’s just generated.
Since we are vb.net-ers, we wrote the templates to spit out VB.NET. The upside is that you compile it into a class library, and you’re language independant.
Cheers,
Dave