Jan Jezek a écrit :
> * Make Inner class under MappedTriangulatioFactory that will look like old
> MappedPosition and will be used just for generating map of source and
> destination triangles.
> OR
> * Rewrite TriangulationFactory to be able to work with new MappedPosition
> instead of DirectPosition.
>
> I prefer the first approach, but may be you can help me how to do this better.
> So what do you think?
A third approach is to make MappedPosition extends DirectPosition2D (or
GeneralDirectPosition) like you did :). But while convenient to implement, I'm
not sure if it is conceptually correct or not. For now I'm not sure because I
don't know yet the full builder code enough. This is why the old MappedPosition
is still around for now.
An other approach which should be efficient and avoid copy is:
* Changes the Triangulation factory code in order to work with
List<DirectPosition> instead of array of type DirectPosition[].
* Write a small class like the one below:
class MappedPositionList<DirectPosition> extends AbstractList {
private final List<MappedPosition> positions;
MappedPositionList(List<MappedPosition> positions) {
this.positions = positions;
}
public int size() {
return positions.size();
}
public DirectPosition get(int index) {
MappedPosition p = positions.get(index);
return p.getTargetPoint();
}
}
Thats all. As you can see, writing List wrappers is pretty easy (we are
probably
going to have a bunch of casts in the code with J2SE 1.4 instead of 1.5). We
may
add a 'boolean' argument in order to select between source and target points.
With such wrappers, there is no copy operation at all - we just create
different
"view" of the mapped position list. This view can be given to the triangulation
factory methods.
Thats why I usually like to recommand usage of Collections over arrays in API.
What do you think?
Martin
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel