Free Tools for GIS Developers
Navigation:
  What's New
 
GIS Tools:
 AVPython
 NTXShape
 SHPTRANS
 
Other Tools:
 SciTE
 Tomcat
 
About:
 The Author
 These Pages
 
 Best viewed with Mozilla / Firefox; or with IE and the Google Toolbar.
Powered by Blogger

Friday, September 16, 2005

  3:34 PM - Boo! Geoprocessing on .NET
I have been thinking about the geoprocessing framework under .NET. It is hard to access late-bound methods from C# and Java, so the Geoprocessing framework is a pain to use from these environments. I heard ESRI is solving this problem in the next version of the framework by adding wrappers for the standard toolboxes, so that .NET and Java can access geoprocessing functions without having to do introspection / reflection.

However, in the mean time consider this: there is a Python-inspired language for the .NET runtime that can make it very easy to develop geoprocessing models that compile as .NET assemblies. This language is named Boo, and although it isn't released yet, it has been coming along nicely.

Boo is not Python. Rather, it is a statically typed language like C#, designed and written specifically for the .NET runtime. Yet, it does have a very convenient, non-intrusive mechanism to access properties and methods that are not known at compile time, much like you can in Python. This mechanism is called duck typing. (The basis of the name: "If it walks like a duck, and talks like a duck, it may as well be a duck.") When we enable duck typing on a given object, we take responsibility for using valid properties and method calls for that object. This can fail at run time, in which case we get an exception, but in practice this is quite rare in well-written code. Usually we know what kind of object we should expect, and what we can do with it, based on the context.

Duck typing, late binding, or whatever you want to call it is the standard behavior in Python, Avenue, and most other scripting languages. In Boo, since it is a statically typed language, you do have to ask for it explicitly. You do this simply by declaring a variable as the special type "duck":

def Dispatch(progid):
  return System.Type.GetTypeFromProgID(progid)()

gp as duck = Dispatch("esriGeoprocessing.GPDispatch.1")
gp.OverwriteOutput = true
gp.CreateFeatureclass_management("d:\\temp", "test.shp", "POINT")

The compiler then takes care of generating all the introspection code for you, hiding the pain, and accessing the requested properties and methods just as easily as you can in Python.

Boo can be used as an embedded scripting language, or it can function as a compiler. In the latter mode, the output is a plain old .NET assembly that can be accessed from C#, NUnit, or wherever else. Even aside from its fit with the Geoprocessing framework, this is definitely a project that I am going to keep my eye on.
0 comments [post]  
 


|
Make your own free website on Tripod.com