Giuseppe Aruta a écrit :
> Hi Michael,
> a couple of question:
> 1) Is it possible to create a bean tool which automatically calculate the x,y 
> coordinates of a point layer and write them as attributes? This script will 
> be quite useful for GPS support.
>   
Sure, not very difficult,
I put it here after. If you want to test it and if it suits your needs, 
we can add it to the distribution.
> 2) One of the possible line od OJ development is the construction of a "model 
> buider" similar to one which in Sextante 
> (http://openjump.org/wiki/show/Google+Summer+Of+Code+Ideas+List), how 
> Beanshell can be useful for it?
>   
I did not explore sextante yet, but I like very much the idea of model 
builder.
As far as I can imagine a model builder, it uses interfaces with inputs, 
outputs and a methods to process data.
The processing part could be defined as a script to include methods 
which are not proposed by the basic model builder.
Exemple :
The model builder may propose a "filter a featureCollection", "union a 
featureCollection",  but miss a "explode a featureCollection containing 
geometryCollections". With beanshell, just do it yourself. It's just 
some thoughts, it may not be so easy to include scripting capabilities 
into such a model and its user interface.

Michaël

Here is the script to add XY attributes :

// This script adds a new layer from a selected one
// The new layer has two new attributes
// containing X and Y of a coordinate

import com.vividsolutions.jump.feature.*;
import com.vividsolutions.jump.workbench.model.StandardCategoryNames;

ll = wc.layerNamePanel.selectedLayers;
if (ll.length != 1) wc.workbench.frame.warnUser("Exactly one layer must 
be selected");
else {
  fc = ll[0].featureCollectionWrapper;
  fs = fc.featureSchema.clone();
  fs.addAttribute("X", AttributeType.DOUBLE);
  fs.addAttribute("Y", AttributeType.DOUBLE);
  resultFC = new FeatureDataset(fs);
  for (f : fc.features) {
    nf = new BasicFeature(fs);
    for (int i = 0 ; i < fs.attributeCount-2 ; i++){
        nf.setAttribute(i, f.getAttribute(i));
    }
    nf.setAttribute("X", f.geometry.coordinate.x);
    nf.setAttribute("Y", f.geometry.coordinate.y);
    resultFC.add(nf);
  }
  wc.layerManager.addLayer(StandardCategoryNames.RESULT, 
ll[0].name+"_XY", resultFC);
}

> Regards
>
> Peppe
>
> __________________________________________________
> Do You Yahoo!?
> Poco spazio e tanto spam? Yahoo! Mail ti protegge dallo spam e ti da tanto 
> spazio gratuito per i tuoi file e i messaggi 
> http://mail.yahoo.it 
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>
>   


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to