Confucio on rites

«Confucius argued that under law, external authorities administer punishments after illegal actions, so people generally behave well without understanding reasons why they should; whereas with ritual, patterns of behavior are internalized and exert their influence before actions are taken, so people behave properly because they fear shame and want to avoid losing face. In this sense, “rite” is an ideal form of social norm.»

Releyendo algunas notas de Creación, de Gore Vidal. Una de las mejoras novelas que he leído.

How gvsig manages the snappers

Last week I paired together with Francisco Puga to review the status of opencadtools. As Fran is doing a great work in preparing the integration of opencadtools as default CAD tools in gvSIG, I wanted to know first hand how it was going. iCarto and Cartolab were kind enough to sponsor this pairing session. One of the results, apart from working with Fran -which is always motivating and enjoyable, per se-, was a deeper understanding on how snappers work in gvSIG, which is something I had asked myself sometimes. And, as one of the improvements of opencadtools is a followgeometry snapper, it seems a good goal to review that part of the project. Find below the summary:

CADToolAdapter class in extCAD extension maintains a list of snappers and layers to snap to from the editing layer. When the mouse is moved, the snappers are recalculated following this algorithm (note that the code below is the core of the method, some other parts/casts and boilerplate code is missing):

ArrayList snappers = SnapConfigPage.getActivesSnappers();
ILayerEdited layerInEdition =
ArrayList layersToSnap = layerInEdition.getLayersToSnap();

for (FLyrVect layer : layersToSnap) {

    // Getting the set of geometries within the envelope
    // The envelope is calculated based on the tolerance the user wants
    SpatialCache cache = layer.getSpatialCache();
    List geometries = cache.query(envelope);

    // Updating the nearest point
    for (Feature geomToSnap : geometries){
        for (int i=0; i distance){
                minimunDistance = distance;

This algorithm is executed every time the user move the mouse and is very quick if you have few layers to snap to. But, as the number of layer to check increases, the editing process becomes very slow. Besides, as a comment of software design, after reviewing this part of code, I like the way the snappers fit in gvsig cad tools. If you want to add a new snapper, just need to implement ISnapperVectorial interface and make getSnapToPoint method to return the nearest point to the position of the mouse. So, designing your own snappers is very easy!

By the way, if you feel like replying how other GIS applications (QGIS, uDig, …) manage the snappers, I’d be more than happy to hear and learn that!

On the sucess and failure of building software applications

Two stories on developing software applications. In both cases the client is the public administration, but the way every one was managed and build was quite different:
  • Lean from the trenches, de Henrik Kniberg. Tell the history of how the PUST was built: PUST is an acronym of “Polisens mobila Utrednings Stöd”, a national-wide application for Swedish policemen.
  • Who killed the virtual case file, a very instructive showcase on the famous failure of VCF, an application to manage cases developed by the FBI.