Archive for March, 2010

Analyzing projects dependencies using dot.exe and powershell

March 22, 2010 1 comment

When the code projects grow large it is easy to loose control over the dependencies between internal projects. I wrote a powershell script today that sucks out the projects from a solution file along with its references to other projects. This information is used as input to dot.exe (available from GraphViz) which is able to create a beautiful image that displays the dependency graph.

Usage: get-projects-dependencies mysolutionfile.sln dependencygraph.png

The result will look like below when applied to the bling projects solution file.


By the way, here is the source code.

Categories: Uncategorized

Compare files in powershell (and include line numbers)

compare $(gc .\file1) $(gc .\file2) -includeequal | 
% { $line=0; } { $line += 1; $_ | add-member noteproperty LineNumber $line; $_ } | 
? { $_.SideIndicator -ne "==" }

Categories: Uncategorized

GridLibrary update

I added a new mode to for the generalized grid generator. The new mode is activated by setting mode: #double in the configuration file. The effect is that both the grid that is best fit to the current scale and the grid that is the next best fit is generated, The two grids are tagged in such a way that a nice blending effect can be achieved. Download the updated library here.

Categories: Uncategorized

A generalized grid generator operator for Carmenta Engine

March 5, 2010 1 comment

Carmenta Engine is a tool box for map visualization. It provides a lot of building blocks that are useful when working with map data visualization and processing. One of the components is called GridGeneratorOp and it is used to generate a grid in any coordinate system. Very useful, indeed, since grids are common in maps. However, if you need the grid to be displayed nicely at a wide range of scale levels, one could say that it does not scale well (please excuse the pun). The reason is that you have to add one operator for each scale level. Luckily, Carmenta Engine has a powerful extension mechanism that, among other things, makes it possible to implement your own operator (this is called a custom operator). So, lets just stop talking and start working. A custom operator needs to implement the interface:

namespace Carmenta.SpatialAce.Interop.CustomObjects
    public interface ICustomOperator
        void InitNew(IOperatorContext context);
        ICustomOperator Clone();
        void Prepare(IGeoInfo info);
        void PrepareSpecific(IGeoInfo info, Identities ids);
        bool Get();

  • InitNew – initialization hook. Here you have a chance to retrieve values specified in the configuration (.p) file. Make sure you store the context parameter since you will need it later.
  • Clone – a custom operator must be a able to create a copy of itself.
  • Prepare/PrepareSpecific – called once per update. Prepare the operator for a new update cycle.
  • Get – called once per processed object, This is the iteration step where the operator actually performs its work.

So, here is the outline of my “improved” grid generator operator.

namespace GridLibrary
    public class ScaleIndependentGridOp : ICustomOperator
        public void InitNew(IOperatorContext context)
            this.context = context;
            refSys = Util.ResolveRefSystemById(Util.GetPropertyValueOrDefault<int>(context, "refSysId", 4326));
            valueAttribute = Util.GetPropertyValueOrDefault<string>(context, "valueAttribute", "value");
            valueAttributeFormat = ValueAttributeFormat.spaceValueFormatString0;
            lineDensity = (double)Util.GetPropertyValueOrDefault<float>(context, "lineDensity", 4.0f);

        public void Prepare(IGeoInfo info)
            var gridOpWrapper = GetOrCreateGridOpWrapper(info);
            objects = gridOpWrapper.Get(info);
            objectCounter = 0;

        public bool Get()
            if (objectCounter < objects.Count)
                return true;
                return false;

        private GridOpWrapper GetOrCreateGridOpWrapper(IGeoInfo info)
        { … }

In InitNew I simply retrieve the coordinate system (or reference system) that the grid is defined in and the name of the attribute that will hold the x/y coordinate. This is equivalent to the ordinary grid generator operator. I also retrieve a parameter called line density. This is, roughly, the number of grid lines (per axis) that will be displayed.

In prepare, I retrieve an instance of an ordinary grid generator operator, that is specifically configured for the current scale level. I use this operator to produce its grid lines and store them in the objects collection.

In get I simply return all the objects in the objects collection that was created in prepare.

This is the basic idea. Please, feel free to download the source code and dig into the gory details or just simply use it as it is. A sample configuration file (testconfig.p) is also provided along with the source code. It might also we worth noting that the generalized grid operator does not require any post processing by project operators and rectclip operators opposed to the original grid generator.


Categories: Uncategorized