Andrea Aime wrote:
> In general, to allow a client to describe and handle all the inputs
> and output of the processes there has to be some agreement on what
> data types are supported and how to handle multiplicity.

And I forgot to deal with multiplicity.

First off, if a parameter is marked as optional it's min cardinality
should be 0, not 1... or not?

Then there is the case of handling parameters whose multiplicity is
 > 1. I've seen two examples of that.
The first is in UnionFactory:

static final Parameter<Geometry> GEOM1 =
new Parameter<Geometry>("geom", Geometry.class, Text.text("Geometry"),
                        Text.text("Geometries to union"), true, 2, -1,
                         null, null);

The second is in RasterToVectorFactory:

public static final Parameter<Collection> OUTSIDE = new 
Parameter<Collection>("nodata", Collection.class, Text.text("Outside 
values"), Text.text("Collection of Double values representing NODATA or 
outside"), false, 0, -1, null, null);

Among the two I prefer the first approach, mainly because
it is explicit about the collection contents, but also because it's
clear that the parameter asks for multiple geometries, whilst
the second could be interpreted as something taking multiple collections.

There is also the issue of how to write a process that takes a
param whose has a multiplicity > 1. What is the process going to
explect? Imho, it should deal with:
- null, for no elements
- a single element for just one item
- a Collection for all other cases (including dealing with empty
   collection and single item collection)

Neither of the processes above actually fully respects that approach.
Union pretends a List<Geometry> (where it is said that it has to be
a geometry) whilst RasterToVector wants a List<Double>.

Wondering, maybe we can have Parameter make the conversion transparent
so that if the value is a single item it gets automatically wrapped
in a collection?

Cheers
Andrea

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to